amc2020:group_n:wifi
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amc2020:group_n:wifi [2020/07/28 17:55] – [3.3 Results] jonas001 | amc2020:group_n:wifi [2023/01/05 14:38] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | < | ||
+ | <a href=" | ||
+ | <span style=" | ||
+ | ↩ Back to the main page | ||
+ | </ | ||
+ | </a> | ||
+ | </ | ||
+ | </ | ||
+ | |||
====== ESP32 Connection to WiFi and MQTT ====== | ====== ESP32 Connection to WiFi and MQTT ====== | ||
===== 1. About MQTT ===== | ===== 1. About MQTT ===== | ||
- | MQTT stands for Message Queuing Telemetry Transport and is publish-subscribe network protocol for transporting messages between different devices. It was first developed in 1999 and is very popular for IoT (Internet of Things) applications. | + | MQTT stands for Message Queuing Telemetry Transport and is a publish-subscribe network protocol for transporting messages between different devices. It was first developed in 1999 and is very popular for IoT (Internet of Things) applications. |
The core of an MQTT network is a server also called MQTT broker. Other devices, called clients, can connect through WiFi to the broker and publish or subscribe to certain topics. The broker receives the messages that are published by the clients and sorts them by their topics. Clients can also subscribe to topics; if a new message is published under a certain topic, the broker redirects this message to all clients that are subscribed to that topic. | The core of an MQTT network is a server also called MQTT broker. Other devices, called clients, can connect through WiFi to the broker and publish or subscribe to certain topics. The broker receives the messages that are published by the clients and sorts them by their topics. Clients can also subscribe to topics; if a new message is published under a certain topic, the broker redirects this message to all clients that are subscribed to that topic. | ||
Line 19: | Line 29: | ||
===== 2. Setup ===== | ===== 2. Setup ===== | ||
- | For testing MQTT and developing a working program structure, it was not necessary to connect any of the sensors. Instead, 4 example String objects were used which would be of the same format as the results from the sensor measurements. Furthermore, | + | For testing MQTT and developing a working program structure, it was not necessary to connect any of the sensors. Instead, 4 example String objects were used which would be of the same format as the results from the sensor measurements. Furthermore, |
The goal was to wake the ESP32 up from deep sleep by using the DS3231 interrupt signal (once a minute for testing). Then reset the alarm, start the WiFi connection and connect to the mqtt broker and, if successful, publish the example data to four different topics and go back into deep sleep. Therefore, the ESP32 needs to be connected to the DS3231 as shown in the [[amc2020: | The goal was to wake the ESP32 up from deep sleep by using the DS3231 interrupt signal (once a minute for testing). Then reset the alarm, start the WiFi connection and connect to the mqtt broker and, if successful, publish the example data to four different topics and go back into deep sleep. Therefore, the ESP32 needs to be connected to the DS3231 as shown in the [[amc2020: | ||
Line 166: | Line 176: | ||
Timer= millis()+1000; | Timer= millis()+1000; | ||
Serial.print(" | Serial.print(" | ||
+ | mqttClient.connect(" | ||
} | } | ||
| | ||
Line 200: | Line 211: | ||
</li> | </li> | ||
<li> | <li> | ||
- | | + | |
</li> | </li> | ||
<li> | <li> | ||
Line 287: | Line 298: | ||
</li> | </li> | ||
<li> | <li> | ||
- | The function < | + | The function < |
</li> | </li> | ||
<li> | <li> | ||
Line 305: | Line 316: | ||
^{{: | ^{{: | ||
|**//Figure 3//** Results after executing the code with the ESP32. The left side shows the MQTT.fx client receiving the 4 test messages; the result can be seen in the console at the bottom left (message posted in Test 1 was " | |**//Figure 3//** Results after executing the code with the ESP32. The left side shows the MQTT.fx client receiving the 4 test messages; the result can be seen in the console at the bottom left (message posted in Test 1 was " | ||
+ | |||
+ | After the successful testing with the placeholder variables, the sketches for measurement and for MQTT transmission were combined to see if the transmission of sensor data would work as expected. The results were observed in the serial monitor and MQTT.fx (figure 4). | ||
+ | \\ | ||
+ | All sensors delivered plausible data, the temperature measurement values were all within 0.6°C of each other while measuring the room temperature. All measurements were transmitted successfully with MQTT once a minute due to the DS3231 interrupt. | ||
+ | |||
+ | ^{{: | ||
+ | |**//Figure 4//** Transmission of sensor data of DHT-22 and DS18B20 using MQTT. The left side shows the published measurement values in MQTT.fx; the right side shows the same results in the Arduino IDE's serial monitor.| | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <a href=" | ||
+ | <span style=" | ||
+ | Back to the top ⤴ | ||
+ | </ | ||
+ | </a> | ||
+ | </ | ||
+ | </ | ||
+ | </ |
amc2020/group_n/wifi.1595951737.txt.gz · Last modified: 2023/01/05 14:38 (external edit)