Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: QEI MFRC522 HTS221 IoTKit BMP180 MQTT
Fork of MQTTPublish by
Diff: main.cpp
- Revision:
- 24:d2f0599798a1
- Parent:
- 23:4d8f3061890e
- Child:
- 25:5e982d03e7d1
--- a/main.cpp Sun Sep 02 16:32:36 2018 +0000 +++ b/main.cpp Mon Sep 03 18:33:01 2018 +0000 @@ -21,6 +21,11 @@ MQTT::Message message; // I/O Buffer char buf[100]; + +// Klassifikation +char cls[3][10] = { "low", "middle", "high" }; +int type = 0; + // UI OLEDDisplay oled( PTE26, PTE0, PTE1); DigitalOut led1( D10 ); @@ -94,7 +99,14 @@ hum_temp.read_id(&id); hum_temp.get_temperature(&temp); hum_temp.get_humidity(&hum); - sprintf( buf, "0x%X,%2.2f,%2.1f", id, temp, hum ); + if ( type == 0 ) + temp -= 5.0f; + else if ( type == 2 ) + temp += 5.0f; + sprintf( buf, "0x%X,%2.2f,%2.1f,%s", id, temp, hum, cls[type] ); + type++; + if ( type > 2 ) + type = 0; publish( mqttNetwork, client, topicTEMP ); // alert Tuer offen @@ -104,7 +116,7 @@ // nur einmal Melden!, bis Reset if ( alert.read() == 0 ) { - sprintf( buf, "door open" ); + sprintf( buf, "alert: hall" ); message.payload = (void*) buf; message.payloadlen = strlen(buf)+1; publish( mqttNetwork, client, topicALERT );