amc2020:group_n:start
Differences
This shows you the differences between two versions of the page.
amc2020:group_n:start [2020/08/03 19:13] – jonas001 | amc2020:group_n:start [2023/01/05 14:38] (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=" |
| | ||
<a href=" | <a href=" | ||
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 | + | 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 |
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 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, | ||
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 | const char* mqtt_server | ||
- | 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 = " | const char* myname = " | ||
Line 211: | Line 215: | ||
PubSubClient mqttClient(espClient); | PubSubClient mqttClient(espClient); | ||
- | //Example Values: | ||
- | String val1= " | ||
- | String val2= " | ||
- | String val3= " | ||
- | String val4= " | ||
char Buffer[5]; | char Buffer[5]; | ||
Line 532: | Line 531: | ||
</ | </ | ||
+ | ==== 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. |
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | 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. | ||
+ | </ | ||
+ | < | ||
+ | The library for the DHT-22 temperature and humidity sensor is included and an object is created. The data pin, the number of measurements, | ||
+ | </ | ||
+ | < | ||
+ | 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, | ||
+ | </ | ||
+ | < | ||
+ | Here the pins used for communicating with the SN74HC595(N) shift register are defined, as well as the pin array for powering specific sensors. | ||
+ | </ | ||
+ | < | ||
+ | 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: | ||
+ | < | ||
+ | < | ||
+ | The I2C connection is started and the status register of the DS3231 is modified to reset the alarm. | ||
+ | </ | ||
+ | < | ||
+ | Then reading and writing to the ESP32' | ||
+ | </ | ||
+ | < | ||
+ | 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. | ||
+ | </ | ||
+ | < | ||
+ | A wake up source to wake up the ESP32 from deep sleep is defined. | ||
+ | </ | ||
+ | < | ||
+ | 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. | ||
+ | </ | ||
+ | < | ||
+ | The pins for controlling the shift register are configured as outputs. | ||
+ | </ | ||
+ | < | ||
+ | The sensors are turned on and off one after another and the measurements are done. The results are then printed to the serial monitor. | ||
+ | </ | ||
+ | < | ||
+ | The measurement results are transferred into the buffer which is then published under the respective topic. | ||
+ | </ | ||
+ | < | ||
+ | The ESP32 prints a success message and goes back into the deep sleep. | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | The function starts the DS18B20 sensors, take n number of measurements, | ||
+ | </ | ||
+ | < | ||
+ | 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. | ||
+ | < | ||
+ | This is the function for turning on certain pins from the shift register. | ||
+ | </ | ||
+ | < | ||
+ | The function resets the status register of the DS3231 and thus the alarm flag. | ||
+ | </ | ||
+ | < | ||
+ | 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. | ||
+ | </ | ||
+ | < | ||
+ | This function works like the WiFi function but is used to establish the connection to the MQTT broker. | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 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. | ||
^ {{: | ^ {{: | ||
Line 549: | Line 619: | ||
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, | 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, | ||
+ | |||
+ | ===== Video Summary ===== | ||
+ | |||
+ | < | ||
+ | <!== | ||
+ | ==> | ||
+ | </ | ||
+ | ^{{ : | ||
+ | |Video Summary of the Project| | ||
+ | |||
===== List of Detail Pages ===== | ===== List of Detail Pages ===== | ||
Line 558: | Line 638: | ||
* **[[amc2020: | * **[[amc2020: | ||
* **[[amc2020: | * **[[amc2020: | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ===== PHYSICS 2 VIDEO ===== | ||
+ | |||
+ | ^{{ : | ||
+ | |Physics 2 Video Submission| | ||
===== Group Information, | ===== Group Information, | ||
Line 563: | Line 659: | ||
[[test|Test]] | [[test|Test]] | ||
- | [[amc2020: | + | [[amc2020: |
Group members: Jonas Zender and Nepomuk | Group members: Jonas Zender and Nepomuk | ||
Line 584: | Line 680: | ||
<do jonas> | <do jonas> | ||
<do jonas> | <do jonas> | ||
+ | <do jonas> | ||
Nepomuk:\\ | Nepomuk:\\ |
amc2020/group_n/start.1596474802.txt.gz · Last modified: 2023/01/05 14:38 (external edit)