User Tools

Site Tools


amc2020:group_n:wifi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
amc2020:group_n:wifi [2020/07/28 17:59] jonas001amc2020:group_n:wifi [2021/08/24 17:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +<html>
 +  <left>
 +    <a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:start"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        &#8617 Back to the main page
 +      </span>
 +    </a>
 +  </left>
 +</html>
 +
 ====== 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 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 166: Line 176:
       Timer= millis()+1000;       Timer= millis()+1000;
       Serial.print(".");       Serial.print(".");
 +      mqttClient.connect("ESP32Client"); 
     }     }
          
Line 200: Line 211:
         </li>         </li>
         <li>         <li>
-            For the ESP32, the password and the SSID of the local WiFi network need to be given as pointers of the type <b><font face="Courier New"><font style="color:#0098A3">const char</font></font></b>. The asterisks need to be replaced by the actual password and SSID.+            The password and the SSID of the local WiFi network that the ESP32 connects to are defined here. The asterisks need to be replaced by the actual SSID/password for the sketch to work.
         </li>         </li>
         <li>         <li>
Line 287: Line 298:
         </li>         </li>
         <li>         <li>
-            The function <b><font face="Courier New">mqttClient.<font style="color:#CD5307">connect</font>()</font></b> establishes the connection with the broker. If the ESP32 is used, it needs <b><font face="Courier New"><font style="color:#008883">"ESP32Client"</font></font></b> as argument.+            The function <b><font face="Courier New">mqttClient.<font style="color:#CD5307">connect</font>()</font></b> establishes the connection with the broker. If the ESP32 is used, <b><font face="Courier New"><font style="color:#008883">"ESP32Client"</font></font></b> is used as argument.
         </li>         </li>
         <li>         <li>
Line 305: Line 316:
 ^{{:amc2020:group_n:mqtttest.jpg?direct&800|Figure 3}}^ ^{{:amc2020:group_n:mqtttest.jpg?direct&800|Figure 3}}^
 |**//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 "Hello"). The right side shows the Arduino IDE's serial monitor during the process.| |**//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 "Hello"). The right side shows the Arduino IDE's serial monitor during the process.|
 +
 +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.
 +
 +^{{:amc2020:group_n:mqtttest_sensors.jpg?direct&800|Figure 4}}^
 +|**//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.|
 +
 +<html>
 +  <center>
 +    <span>
 +    <a href="javascript:self.scrollTo(0,0)"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        Back to the top &#10548
 +      </span>
 +    </a>
 +    </span>
 +  </center>
 +</html>
amc2020/group_n/wifi.1595951960.txt.gz · Last modified: 2021/08/24 17:34 (external edit)