![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dust Sesnsor PMS5003
Dependencies: DustSenzor NetServices ThingSpeakEthernet mbed
Fork of PMS5003 by
main.cpp
- Committer:
- tsoic
- Date:
- 2015-11-20
- Revision:
- 6:ebbde59c5a1d
- Parent:
- 5:1e77bdd1a639
- Child:
- 7:1da0a084cd69
File content as of revision 6:ebbde59c5a1d:
#include "mbed.h" #include "iostream" #include "ThingSpeak.h" #include "Sensor.h" #include "C12832.h" #include "INA219.h" ThingSpeak ts("074MPWFODR7JHD1K", 6); C12832 lcd(p5, p7, p6, p8, p11); Sensor current(p19,4); Sensor voltage(p20,24); int main() { INA219 ina219; float U, I, ina[3]; int i; lcd.cls(); lcd.locate(0,3); ts.connect(); lcd.printf("Ethernet Connected ! \n"); ts.getIP(); wait(1); while(1){ voltage.read(); current.read(); U = voltage.calc(); I = current.calc(); ina[0] = ina219.readRawReg(0x04); //* Current *// ina[1] = ina219.readRawReg(0x02); //* Bus Voltage *// ina[2] = ina219.readRawReg(0x03); //* Power *// lcd.cls(); lcd.locate(0,3); lcd.printf("V = %.2f V \n",U); lcd.printf("I = %.2f A \n",I); lcd.printf("P = %.2f W \n", U*I); lcd.locate(0,14); lcd.printf("V = %.2f V \n",ina[1]); lcd.printf("I = %.2f A \n",ina[0]); lcd.printf("P = %.2f W \n",ina[2]); i = 1; ts.setField(U, i++); ts.setField(I, i++); for(int j = 0 ; j<= 3; j++) ts.setField(ina[j], i++); ts.putUp(); wait(15); } }