hwsdf
Dependencies: C12832 hw4f HW4 MQTT
Fork of HW4 by
main_2.cpp@24:4b8390b87ab3, 2018-01-06 (annotated)
- Committer:
- Hyoeunchoi
- Date:
- Sat Jan 06 11:53:19 2018 +0000
- Revision:
- 24:4b8390b87ab3
ss
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hyoeunchoi | 24:4b8390b87ab3 | 1 | /* // change this to 1 to output messages to LCD instead of serial |
Hyoeunchoi | 24:4b8390b87ab3 | 2 | #define logMessage printf |
Hyoeunchoi | 24:4b8390b87ab3 | 3 | #define MQTTCLIENT_QOS2 1 |
Hyoeunchoi | 24:4b8390b87ab3 | 4 | |
Hyoeunchoi | 24:4b8390b87ab3 | 5 | #include <string> |
Hyoeunchoi | 24:4b8390b87ab3 | 6 | #include "mbed.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 7 | #include "easy-connect.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 8 | #include "MQTTNetwork.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 9 | #include "MQTTmbed.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 10 | #include "MQTTClient.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 11 | #include "TCPSocket.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 12 | #include "DHT22.h" |
Hyoeunchoi | 24:4b8390b87ab3 | 13 | |
Hyoeunchoi | 24:4b8390b87ab3 | 14 | #define WIFI_HW_RESET_PIN D4 |
Hyoeunchoi | 24:4b8390b87ab3 | 15 | |
Hyoeunchoi | 24:4b8390b87ab3 | 16 | #define MQTT_BROKER_ADDR "192.168.0.10" |
Hyoeunchoi | 24:4b8390b87ab3 | 17 | #define MQTT_BROKER_PORT 1883 |
Hyoeunchoi | 24:4b8390b87ab3 | 18 | |
Hyoeunchoi | 24:4b8390b87ab3 | 19 | DigitalOut wifiHwResetPin(WIFI_HW_RESET_PIN); |
Hyoeunchoi | 24:4b8390b87ab3 | 20 | DigitalOut led2(LED2); |
Hyoeunchoi | 24:4b8390b87ab3 | 21 | DHT22 dht22(D7); |
Hyoeunchoi | 24:4b8390b87ab3 | 22 | Serial pc(USBTX, USBRX, 115200); |
Hyoeunchoi | 24:4b8390b87ab3 | 23 | |
Hyoeunchoi | 24:4b8390b87ab3 | 24 | int main(int argc, char* argv[]) |
Hyoeunchoi | 24:4b8390b87ab3 | 25 | { |
Hyoeunchoi | 24:4b8390b87ab3 | 26 | pc.printf("starting...\r\n"); |
Hyoeunchoi | 24:4b8390b87ab3 | 27 | while(1){ |
Hyoeunchoi | 24:4b8390b87ab3 | 28 | double temp; |
Hyoeunchoi | 24:4b8390b87ab3 | 29 | if(dht22.sample()){ |
Hyoeunchoi | 24:4b8390b87ab3 | 30 | temp=dht22.getTemperature()/10.0; |
Hyoeunchoi | 24:4b8390b87ab3 | 31 | pc.printf("temperature: %3.1f\r\n",temp); |
Hyoeunchoi | 24:4b8390b87ab3 | 32 | } |
Hyoeunchoi | 24:4b8390b87ab3 | 33 | } |
Hyoeunchoi | 24:4b8390b87ab3 | 34 | } |
Hyoeunchoi | 24:4b8390b87ab3 | 35 | */ |