TaChing Yu
/
Wifi_LM35
1
main.cpp@1:b4da0411aab0, 2016-09-04 (annotated)
- Committer:
- yu10078999
- Date:
- Sun Sep 04 08:23:52 2016 +0000
- Revision:
- 1:b4da0411aab0
- Parent:
- 0:49ecbaeff0e4
- Child:
- 2:a5d1974bd7c9
2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yu10078999 | 0:49ecbaeff0e4 | 1 | #include "mbed.h" |
yu10078999 | 0:49ecbaeff0e4 | 2 | |
yu10078999 | 0:49ecbaeff0e4 | 3 | AnalogIn lm35(A0); |
yu10078999 | 0:49ecbaeff0e4 | 4 | Serial esp8266(D6, D7);//tx, rx |
yu10078999 | 1:b4da0411aab0 | 5 | char i; |
yu10078999 | 0:49ecbaeff0e4 | 6 | |
yu10078999 | 0:49ecbaeff0e4 | 7 | int main() { |
yu10078999 | 0:49ecbaeff0e4 | 8 | float val,tempC,tempF; |
yu10078999 | 0:49ecbaeff0e4 | 9 | while(1) |
yu10078999 | 0:49ecbaeff0e4 | 10 | { |
yu10078999 | 0:49ecbaeff0e4 | 11 | val=lm35.read(); |
yu10078999 | 0:49ecbaeff0e4 | 12 | tempC=(val*2.8f*100); |
yu10078999 | 0:49ecbaeff0e4 | 13 | tempF=(9.0f*tempC)/5.0f + 32.0f; |
yu10078999 | 0:49ecbaeff0e4 | 14 | printf("%.2f\n%.2f\n",tempC,tempF); |
yu10078999 | 1:b4da0411aab0 | 15 | i=tempC; |
yu10078999 | 1:b4da0411aab0 | 16 | esp8266.putc(i); |
yu10078999 | 0:49ecbaeff0e4 | 17 | wait(2); |
yu10078999 | 0:49ecbaeff0e4 | 18 | } |
yu10078999 | 0:49ecbaeff0e4 | 19 | } |