![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dust Sesnsor PMS5003
Dependencies: DustSenzor NetServices ThingSpeakEthernet mbed
Fork of PMS5003 by
main.cpp@7:1da0a084cd69, 2015-11-29 (annotated)
- Committer:
- tsoic
- Date:
- Sun Nov 29 13:41:05 2015 +0000
- Revision:
- 7:1da0a084cd69
- Parent:
- 6:ebbde59c5a1d
- Child:
- 9:07f9279c30f7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
segundo | 0:2419d81ee03d | 1 | #include "mbed.h" |
tsoic | 6:ebbde59c5a1d | 2 | #include "iostream" |
tsoic | 6:ebbde59c5a1d | 3 | #include "ThingSpeak.h" |
tsoic | 6:ebbde59c5a1d | 4 | #include "Sensor.h" |
tsoic | 6:ebbde59c5a1d | 5 | #include "C12832.h" |
tsoic | 6:ebbde59c5a1d | 6 | #include "INA219.h" |
segundo | 0:2419d81ee03d | 7 | |
segundo | 2:16857d9ab50d | 8 | |
segundo | 2:16857d9ab50d | 9 | |
tsoic | 7:1da0a084cd69 | 10 | ThingSpeak ts("074MPWFODR7JHD1K"); |
tsoic | 6:ebbde59c5a1d | 11 | C12832 lcd(p5, p7, p6, p8, p11); |
tsoic | 7:1da0a084cd69 | 12 | Sensor current(p19,4.65); |
tsoic | 7:1da0a084cd69 | 13 | Sensor voltage(p20,16.23); |
tsoic | 6:ebbde59c5a1d | 14 | |
segundo | 2:16857d9ab50d | 15 | |
segundo | 0:2419d81ee03d | 16 | |
segundo | 0:2419d81ee03d | 17 | int main() { |
tsoic | 6:ebbde59c5a1d | 18 | INA219 ina219; |
tsoic | 6:ebbde59c5a1d | 19 | float U, I, ina[3]; |
tsoic | 6:ebbde59c5a1d | 20 | int i; |
tsoic | 6:ebbde59c5a1d | 21 | |
tsoic | 6:ebbde59c5a1d | 22 | lcd.cls(); |
tsoic | 7:1da0a084cd69 | 23 | lcd.locate(0,3); |
tsoic | 7:1da0a084cd69 | 24 | lcd.printf("Ethernet Connecting ! \n"); |
tsoic | 6:ebbde59c5a1d | 25 | ts.connect(); |
tsoic | 6:ebbde59c5a1d | 26 | lcd.printf("Ethernet Connected ! \n"); |
tsoic | 6:ebbde59c5a1d | 27 | wait(1); |
segundo | 2:16857d9ab50d | 28 | |
tsoic | 6:ebbde59c5a1d | 29 | while(1){ |
tsoic | 7:1da0a084cd69 | 30 | |
tsoic | 7:1da0a084cd69 | 31 | U = voltage.read(); |
tsoic | 7:1da0a084cd69 | 32 | I = current.read(); |
tsoic | 7:1da0a084cd69 | 33 | ina[0] = ina219.readRawReg(0x04);//* Current *// |
tsoic | 6:ebbde59c5a1d | 34 | ina[1] = ina219.readRawReg(0x02); //* Bus Voltage *// |
tsoic | 7:1da0a084cd69 | 35 | ina[2] = ina219.readRawReg(0x03);//* Power *// |
tsoic | 7:1da0a084cd69 | 36 | |
tsoic | 6:ebbde59c5a1d | 37 | lcd.cls(); |
tsoic | 7:1da0a084cd69 | 38 | lcd.locate(0,3); |
tsoic | 6:ebbde59c5a1d | 39 | lcd.printf("V = %.2f V \n",ina[1]); |
tsoic | 6:ebbde59c5a1d | 40 | lcd.printf("I = %.2f A \n",ina[0]); |
tsoic | 6:ebbde59c5a1d | 41 | lcd.printf("P = %.2f W \n",ina[2]); |
tsoic | 6:ebbde59c5a1d | 42 | |
tsoic | 6:ebbde59c5a1d | 43 | i = 1; |
tsoic | 6:ebbde59c5a1d | 44 | ts.setField(U, i++); |
tsoic | 6:ebbde59c5a1d | 45 | ts.setField(I, i++); |
tsoic | 7:1da0a084cd69 | 46 | ts.setField(I*U, i++); |
tsoic | 7:1da0a084cd69 | 47 | for(int j = 0 ; j<= 2; j++) |
tsoic | 6:ebbde59c5a1d | 48 | ts.setField(ina[j], i++); |
tsoic | 6:ebbde59c5a1d | 49 | |
tsoic | 6:ebbde59c5a1d | 50 | ts.putUp(); |
tsoic | 6:ebbde59c5a1d | 51 | wait(15); |
segundo | 2:16857d9ab50d | 52 | } |
segundo | 0:2419d81ee03d | 53 | } |