User Tools

Site Tools


amc2020:group_n:start

Differences

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

Link to this comparison view

amc2020:group_n:start [2020/08/03 19:10] – [3. Results] jonas001amc2020:group_n:start [2021/08/24 17:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +Group N: Jonas Zender (21125) and Nepomuk
 +
 ====== Garden Pond Monitoring Station ====== ====== Garden Pond Monitoring Station ======
  
Line 29: Line 31:
   <!--<a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:level" target="_blank"><div style="position: absolute; left: 35.47%; top: 48.26%; width: 3.59%; height: 8.31%; background-color: rgba(0,0,0, 0);"></div></a>-->   <!--<a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:level" target="_blank"><div style="position: absolute; left: 35.47%; top: 48.26%; width: 3.59%; height: 8.31%; background-color: rgba(0,0,0, 0);"></div></a>-->
      
-  <!--<a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:pond" target="_blank"><div style="position: absolute; left: 44.69%; top: 37.00%; width: 46.25%; height: 45.31%; background-color: rgba(,0,0, 0);"></div></a>-->+  <a href="https://wiki.eolab.de/lib/exe/fetch.php?media=amc2020:group_n:pond.jpg" target="_blank" title="Pond"><div style="position: absolute; left: 44.69%; top: 37.00%; width: 46.25%; height: 45.31%; background-color: rgba(,0,0, 0);"></div></a>
      
   <a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:sn74hc595n" target="_blank" title="SN74HC595(N) Shift Register"><div style="position: absolute; left: 11.72%; top: 54.42%; width: 9.84%; height: 9.65%; background-color: rgba(,0,0, 0);"></div></a>   <a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:sn74hc595n" target="_blank" title="SN74HC595(N) Shift Register"><div style="position: absolute; left: 11.72%; top: 54.42%; width: 9.84%; height: 9.65%; background-color: rgba(,0,0, 0);"></div></a>
Line 102: Line 104:
 The DS18B20 is a digital temperature sensor which comes in different packages, one of which being mounted inside a waterproof metal probe with a cable (1m) attached to it, which made it optimal for measuring the temperature in the pond. For measuring, two DS18B20s were used, one for measuring the temperature of the water close to the surface of the pond, and another for measuring at the bottom. This way it is possible to track how the sun’s irradiance (or its absence) influences the temperatures in different locations and how the values develop over the course of a day. The DS18B20 is a digital temperature sensor which comes in different packages, one of which being mounted inside a waterproof metal probe with a cable (1m) attached to it, which made it optimal for measuring the temperature in the pond. For measuring, two DS18B20s were used, one for measuring the temperature of the water close to the surface of the pond, and another for measuring at the bottom. This way it is possible to track how the sun’s irradiance (or its absence) influences the temperatures in different locations and how the values develop over the course of a day.
  
-It uses a 1-Wire communication protocol, but in contrast to the DHT-22, each device that can communicate with this protocol has a unique 64-bit address, such that each sensor can be addressed individually. Therefore, it is possible to connect a huge number of sensors and read their data using only a single GPIO of the MCU. Like the DHT-22, it has an open-drain output which means that a pullup-resistor is necessary; the DS18B20 has no external pullup resistor, so an external one is needed. But as all the sensors can be in the same data-bus, only a single pullup resistor is necessary for the whole data bus.+It uses a 1-Wire communication protocol, but in contrast to the DHT-22, each device that can communicate with this protocol has a unique 64-bit address, such that each sensor can be addressed individually. Therefore, it is possible to connect a huge number of sensors and read their data using only a single GPIO of the MCU. Like the DHT-22, it has an open-drain output which means that a pullup-resistor is necessary; the DS18B20 has no internal pullup resistor, so an external one is needed. But as all the sensors can be in the same data-bus, only a single pullup resistor is necessary for the whole data bus.
  
 The DS18B20 also has the option to configure the measurement resolution from 9 bits to 12 bits. A lower resolution saves time during measurement but compromises the accuracy of the results. As measurements are only taken hourly, not continuously, the highest resolution was chosen as decreasing the measurement time was not as important as yielding accurate results. After determining the sensor’s addresses, test measurements were taken which were in line with those of the DHT-22. The DS18B20 also has the option to configure the measurement resolution from 9 bits to 12 bits. A lower resolution saves time during measurement but compromises the accuracy of the results. As measurements are only taken hourly, not continuously, the highest resolution was chosen as decreasing the measurement time was not as important as yielding accurate results. After determining the sensor’s addresses, test measurements were taken which were in line with those of the DHT-22.
Line 186: Line 188:
  
 The test results of the individual project sections can be found on the detail pages. After experimenting with the different modules and functions, their respective codes were combined to give the complete program code: The test results of the individual project sections can be found on the detail pages. After experimenting with the different modules and functions, their respective codes were combined to give the complete program code:
 +
 +==== 3.1 Code ====
  
 <file c++ ESP32_Pond_Station.ino> <file c++ ESP32_Pond_Station.ino>
Line 198: Line 202:
  
 //Local Wifi //Local Wifi
-const char* password = "0726606423178450";      +const char* password = "******************";      
-const char* ssid = "WLAN-WCFUNW";                +const char* ssid = "*********";                
  
-//EOLAB+//MQTT Server
 const char* mqtt_server   = "hsrw.space"; const char* mqtt_server   = "hsrw.space";
-const char* mqtt_username = "user"; +const char* mqtt_username = "****"; 
-const char* mqtt_password = "mqtt";+const char* mqtt_password = "****";
 const unsigned int mqtt_bufsize = 100;     const unsigned int mqtt_bufsize = 100;    
 const char* myname = "GroupN";     const char* myname = "GroupN";    
Line 211: Line 215:
 PubSubClient mqttClient(espClient);                PubSubClient mqttClient(espClient);               
  
-//Example Values:                         
-String val1= "Hello"; 
-String val2= "World"; 
-String val3= "Hey"; 
-String val4= "ESP32"; 
 char Buffer[5];                                    char Buffer[5];                                   
  
Line 532: Line 531:
 </file> </file>
  
 +==== 3.2 Overview for the Code ====
  
-After setting up the module, programming the DS3231 accordingly and uploading the code to the ESP32, the results could be seen in the pond monitoring station dashboard in Grafana. For testing outdoors, the components need to be isolated safely to not get into contact with the water from the pond, which was not yet done. Therefore, for testing, the measurements were taken indoors in 1-minute intervals during a hot summer day. The results of those measurements can be seen in figure 4. The temperature spike from the bottom water temperature sensor was due to holding the probe in the hand, the following drop was due to the sensor being placed in a colder glass of water for a short moment to test the responsiveness of the sensor. As can be seen, the sensor needs approximately 5 - 7 minutes to really get into thermal equilibrium with its environment+An elaborate explanation of the different code sections can be found in the detail pages. The following is just to give a short overview and explain the main program. 
 + 
 +<html> 
 +<ol> 
 +    <li> 
 +        The first section contains all necessary libraries, variables definitions and creates the necessary objects for the WiFi connection, MQTT connection and the deep sleep of the ESP32. 
 +    </li> 
 +    <li> 
 +        The library for the DHT-22 temperature and humidity sensor is included and an object is created. The data pin, the number of measurements, and the sensor type are defined and the variables for taking up and averaging the values are declared. 
 +    </li> 
 +    <li> 
 +        The 1-Wire bus library and the library for the DS18B20 digital temperature sensors are included and the previously determined addresses of the two sensors are defined. Afterwards the number of measurements, the bus pin, the temperature variables and the delay time for a certain resolution are configured. 
 +    </li> 
 +    <li> 
 +        Here the pins used for communicating with the SN74HC595(N) shift register are defined, as well as the pin array for powering specific sensors. 
 +    </li> 
 +    <li> 
 +        The main program runs completely within the setup because after executing the code once, the ESP32 goes back into deep sleep. The following steps are executed: 
 +        <ul> 
 +            <li> 
 +                The I2C connection is started and the status register of the DS3231 is modified to reset the alarm. 
 +            </li> 
 +            <li> 
 +                Then reading and writing to the ESP32's flash memory is started to check how often the MCU already restarted due to connection issues to prevent an endless loop draining the battery. 
 +            </li> 
 +            <li> 
 +                The serial connection is started so that the serial monitor can be used to see what is going on in the ESP32. The serial commands can also be left out when the station is working fine. 
 +            </li> 
 +            <li> 
 +                A wake up source to wake up the ESP32 from deep sleep is defined.  
 +            </li> 
 +            <li> 
 +                The connection to the local WiFi network and to the MQTT broker are established and it is checked if they are working as they should. 
 +            </li> 
 +            <li> 
 +                The pins for controlling the shift register are configured as outputs. 
 +            </li> 
 +            <li> 
 +                The sensors are turned on and off one after another and the measurements are done. The results are then printed to the serial monitor. 
 +            </li> 
 +            <li> 
 +                The measurement results are transferred into the buffer which is then published under the respective topic. 
 +            </li> 
 +            <li> 
 +                The ESP32 prints a success message and goes back into the deep sleep. 
 +            </li> 
 +        </ul> 
 +    </li> 
 +    <li> 
 +        The function starts the DS18B20 sensors, take n number of measurements, averages the result and writes it into a String. 
 +    </li> 
 +    <li> 
 +        For the DHT-22 the function works the same way as for the DS18B20, but it also checks if the results received from the sensor are plausible and should be considered. 
 +    <li> 
 +        This is the function for turning on certain pins from the shift register.  
 +    </li> 
 +    <li> 
 +        The function resets the status register of the DS3231 and thus the alarm flag. 
 +    </li> 
 +    <li> 
 +        The WiFi connection is established and the connection status is checked. In case it does not work, there is a timeout after which the ESP32 restarts to try it again. After 3 unsuccessful tries it goes back into deep sleep to not drain the batteries. 
 +    </li> 
 +    <li> 
 +        This function works like the WiFi function but is used to establish the connection to the MQTT broker. 
 +    </li> 
 +</ol> 
 +</html> 
 + 
 +==== 3.3 Results in Grafana ==== 
 + 
 +After setting up the module, programming the DS3231 accordingly and uploading the code to the ESP32, the results could be seen in the pond monitoring station dashboard in Grafana. For testing outdoors, the components need to be isolated safely to not get into contact with the water from the pond, which was not yet done. Therefore, for testing, the measurements were taken indoors in 1-minute intervals during a hot summer day. The results of those measurements can be seen in figure 4. The temperature spike from the bottom water temperature sensor was due to holding the probe in the hand, the following drop was due to the sensor being placed in a colder glass of water for a short moment to test the responsiveness of the sensor. As can be seen, the sensor needs approximately 5 - 7 minutes to really get into thermal equilibrium with its environment.
  
 ^ {{:amc2020:group_n:pond_monitoring_station_data_logger_graphana_light_theme.png?800&direct|Figure 4}}  ^ ^ {{:amc2020:group_n:pond_monitoring_station_data_logger_graphana_light_theme.png?800&direct|Figure 4}}  ^
Line 550: Line 620:
 At the pond, the connection of the ESP32 to the local WiFi network might not be good enough for data transmission. Before installing the station, the signal strength at the pond should be tested. In case that it is insufficient, some of the ESP32 modules, especially the Wrover-modules, offer the possibility of soldering an IPEX connector to it; some already have one connected in place. The IPEX connector makes it possible to attach an external antenna which increases the signal strength. However, it is not possible to use an external antenna if the PCB antenna is still connected. To change the antenna used by the ESP32, the small 0Ω SMD resistor connecting PCB antenna and MCU must be removed and connected to the IPEX connector instead. As the components are very small, it might not be easy to do that. At the pond, the connection of the ESP32 to the local WiFi network might not be good enough for data transmission. Before installing the station, the signal strength at the pond should be tested. In case that it is insufficient, some of the ESP32 modules, especially the Wrover-modules, offer the possibility of soldering an IPEX connector to it; some already have one connected in place. The IPEX connector makes it possible to attach an external antenna which increases the signal strength. However, it is not possible to use an external antenna if the PCB antenna is still connected. To change the antenna used by the ESP32, the small 0Ω SMD resistor connecting PCB antenna and MCU must be removed and connected to the IPEX connector instead. As the components are very small, it might not be easy to do that.
  
 +===== Video Summary =====
 +
 +<html>
 +<!==
 +==>
 +</html>
 +^{{ :amc2020:group_n:amc2020_groupn_jzender_video_v1.0.mp4?800 |Video Summary}}^
 +|Video Summary of the Project|
 +
 +
 +===== List of Detail Pages =====
 +
 +  * **[[dht22|DHT-22 Air Temperature and Humidity Sensor]]**
 +  * **[[ds18b20|DS18B20 Waterproof Temperature Sensor]]**
 +  * **[[SN74HC595N|SN74HC595(N) Shift Register]]**
 +  * **[[DS3231RTC|DS3231 Real Time Clock]]**
 +  * **[[amc2020:group_n:deepsleep|ESP32 Deep Sleep]]**
 +  * **[[amc2020:group_n:wifi|Testing Wifi and MQTT]]**
 +
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +
 +===== PHYSICS 2 VIDEO =====
 +
 +^{{ :amc2020:group_n:phy2_2020_group_n_video.mp4?800 | Physics 2 Video}}^
 +|Physics 2 Video Submission|
  
 ===== Group Information, Testing & To Do ===== ===== Group Information, Testing & To Do =====
Line 555: Line 659:
 [[test|Test]] [[test|Test]]
  
-[[amc2020:group_n:tutorial|Image Tutorial]]+[[amc2020:group_n:tutorial|Interactive Image Tutorial]]
  
 Group members: Jonas Zender and Nepomuk Group members: Jonas Zender and Nepomuk
Line 576: Line 680:
 <do jonas>Build a casing for the station</do>\\ <do jonas>Build a casing for the station</do>\\
 <do jonas>Perform test measurements at the pond</do>\\ <do jonas>Perform test measurements at the pond</do>\\
 +<do jonas>Create a video about the station</do>\\
  
 Nepomuk:\\ Nepomuk:\\
amc2020/group_n/start.1596474633.txt.gz · Last modified: 2021/08/24 17:34 (external edit)