amc:ss2025:group-g:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amc:ss2025:group-g:start [2025/07/29 22:41] – [3. Results] 29478_students.hsrw | amc:ss2025:group-g:start [2025/07/29 23:57] (current) – [Explanation Video] 29478_students.hsrw | ||
---|---|---|---|
Line 65: | Line 65: | ||
- | The prototype (Figure 3.1) successfully read the data collected from the sensors and sent it over MQTT to the Ubidots MQTT broker; the data received by the server was then available to be displayed in the dashboard (Figure 3.2). The air temperature and humidity sensor used was a DHT11 unit since it showed more accurate results than the DHT22 unit available when compared to a more expensive reference unit. The microcontroller used was the ESP32S3 connected directly to the host computer, since the more specific board did not function as intended, as will be discussed in the next chapter. | + | The prototype (Figure 3.1) successfully read the data collected from the sensors and sent it over MQTT to the Ubidots MQTT broker; the data received by the server was then available to be displayed in the dashboard (Figure 3.2). The air temperature and humidity sensor used was a DHT11 unit since it showed more accurate results than the DHT22 unit available when compared to a more expensive reference unit. The microcontroller used was the ESP32S3 connected directly to the host computer, since the more specific board did not function as intended, as will be discussed in the next chapter. |
+ | |||
+ | The code developed for it is shown below with comments where needed. | ||
{{ : | {{ : | ||
Line 72: | Line 74: | ||
{{ : | {{ : | ||
+ | < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | // Defining sensor variables | ||
+ | #define DHTPIN 4 | ||
+ | #define DHTTYPE DHT11 | ||
+ | #define SOILPIN 5 | ||
+ | #define LDRPIN 6 | ||
+ | DHT dht(DHTPIN, DHTTYPE); | ||
+ | |||
+ | // Defining MQTT/ | ||
+ | #define TOKEN " | ||
+ | #define WIFINAME " | ||
+ | #define WIFIPASS " | ||
+ | #define DEVICE_LABEL " | ||
+ | #define VAR_LABEL_1 " | ||
+ | #define VAR_LABEL_2 " | ||
+ | #define VAR_LABEL_3 " | ||
+ | #define VAR_LABEL_4 " | ||
+ | Ubidots client(TOKEN); | ||
+ | bool connected = false; | ||
+ | |||
+ | // Defining sleep variables | ||
+ | #define uS_FACTOR 1000000 | ||
+ | #define PUBLISH_FREQUENCY 60 | ||
+ | RTC_DATA_ATTR int bootCount = 0; | ||
+ | |||
+ | const int airStd = 3550; | ||
+ | const int waterStd = 1560; | ||
+ | int soilMoistPerc = 0; | ||
+ | int soilMoist = 0; | ||
+ | int hum = 0; | ||
+ | float tempC = 0; | ||
+ | int light = 0; | ||
+ | int lightPerc = 0; | ||
+ | const int minLight = 0; | ||
+ | const int maxLight = 3409; | ||
+ | |||
+ | |||
+ | // Auxiliary Function for Ubidots connection | ||
+ | void callback(char *topic, byte *payload, unsigned int length) | ||
+ | Serial.print(" | ||
+ | Serial.print(topic); | ||
+ | Serial.print(" | ||
+ | for (int i = 0; i < length; i++) { | ||
+ | Serial.print((char)payload[i]); | ||
+ | } | ||
+ | Serial.println(); | ||
+ | } | ||
+ | |||
+ | void soilMoistPrint(int soil_moisture, | ||
+ | soilMoistPerc = map(soil_moisture, | ||
+ | |||
+ | if (soilMoistPerc < 0) { | ||
+ | soilMoistPerc = 0; | ||
+ | } | ||
+ | else if (soilMoistPerc > 100) { | ||
+ | soilMoistPerc = 100; | ||
+ | } | ||
+ | Serial.print(" | ||
+ | Serial.print(soilMoistPerc); | ||
+ | Serial.println(" | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void dhtOutPrint(int humidity, float temperature_C) { | ||
+ | if (isnan(humidity) | isnan(temperature_C)) { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | else { | ||
+ | Serial.print(" | ||
+ | Serial.print(humidity); | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.println(temperature_C); | ||
+ | |||
+ | } | ||
+ | | ||
+ | } | ||
+ | |||
+ | void lightOutPrint(int light, int minimum, int maximum) | ||
+ | lightPerc = map(light, minimum, maximum, 0, 100); | ||
+ | Serial.print(" | ||
+ | Serial.print(lightPerc); | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | Serial.begin(115200); | ||
+ | delay(1000); | ||
+ | dht.begin(); | ||
+ | |||
+ | ++bootCount; | ||
+ | Serial.println(" | ||
+ | esp_sleep_enable_timer_wakeup(PUBLISH_FREQUENCY * uS_FACTOR); | ||
+ | |||
+ | client.setDebug(true); | ||
+ | client.wifiConnection(WIFINAME, | ||
+ | client.begin(callback); | ||
+ | |||
+ | if (!connected) | ||
+ | Serial.println(" | ||
+ | connected = client.connect(); | ||
+ | } | ||
+ | | ||
+ | Serial.println(connected); | ||
+ | |||
+ | light = analogRead(LDRPIN); | ||
+ | // | ||
+ | | ||
+ | hum = dht.readHumidity(); | ||
+ | tempC = dht.readTemperature(); | ||
+ | // | ||
+ | |||
+ | soilMoist = analogRead(SOILPIN); | ||
+ | // | ||
+ | | ||
+ | if (connected) { | ||
+ | client.add(VAR_LABEL_1, | ||
+ | client.add(VAR_LABEL_2, | ||
+ | client.add(VAR_LABEL_3, | ||
+ | client.add(VAR_LABEL_4, | ||
+ | client.ubidotsPublish(DEVICE_LABEL); | ||
+ | client.loop(); | ||
+ | } | ||
+ | |||
+ | Serial.println(" | ||
+ | Serial.flush(); | ||
+ | esp_deep_sleep_start(); | ||
+ | |||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | | ||
+ | } | ||
+ | </ | ||
====== 4. Discussion ====== | ====== 4. Discussion ====== | ||
'' | '' | ||
Line 99: | Line 241: | ||
There are many improvements that could be done to the project, both in hardware and software. Regarding hardware, the quality of the sensors could use improvements, | There are many improvements that could be done to the project, both in hardware and software. Regarding hardware, the quality of the sensors could use improvements, | ||
- | Regarding software, there are some different options that could also work well, such as the use of Node-RED, a SQL or Non-SQL database, and another dashboard web server such as Grafana, as to make the project more substantial and improve historic analysis capabilities, | + | Regarding software, there are some different options that could also work well, such as the use of Node-RED, a SQL or Non-SQL database, and another dashboard web server such as Grafana, as to make the project more substantial and improve historic analysis capabilities, |
+ | |||
+ | This prototype mostly is a proof of concept of the viability and ease of use of such a device. If developed and refined, an enclosure could be designed as to protect the contents of the box while at the same time allowing for the proper measurements to be done, meaning an opening for the light sensor and concerns with heating of the components which could affect the temperature readings. | ||
+ | |||
+ | ====== 5. Conclusion ====== | ||
+ | '' | ||
- | ====== 5.Conclusion ====== | ||
- | '' | ||
The case study of the Smart Mini Weather Station illustrates the integration of sensors, communications of IoT devices, and real-time data display as a low-cost and practical system for environmental monitoring. The prototype was able to gather the requisite data like air temperature, | The case study of the Smart Mini Weather Station illustrates the integration of sensors, communications of IoT devices, and real-time data display as a low-cost and practical system for environmental monitoring. The prototype was able to gather the requisite data like air temperature, | ||
This project was useful in demonstrating core concepts of measurement and control systems, as this device literally put those concepts to work. It showed the viability of using low-powered electronics and simple sensors for better environmental monitoring. This system has the potential to be adapted for smart agriculture, | This project was useful in demonstrating core concepts of measurement and control systems, as this device literally put those concepts to work. It showed the viability of using low-powered electronics and simple sensors for better environmental monitoring. This system has the potential to be adapted for smart agriculture, | ||
In a nutshell, this project was useful in creating real-world simulations with the Internet of Things, sensor networks, and data systems, as the knowledge is very useful in a technology-driven economy. | In a nutshell, this project was useful in creating real-world simulations with the Internet of Things, sensor networks, and data systems, as the knowledge is very useful in a technology-driven economy. | ||
- | ====== Limitations ====== | + | The prototype Smart Mini Weather Station had some noteworthy features, but the following limitations should also be considered. |
- | '' | + | |
- | The prototype | + | |
- | • Power Source: An obvious concern is the device’s first iteration, powered by a computer’s USB port, which makes the device unsuitable for outdoor or remote usage. | + | * Power Source: An obvious concern is the device’s first iteration, powered by a computer’s USB port, which makes the device unsuitable for outdoor or remote usage. |
- | • Sensor accuracy: The older version of the device was outfitted with a DHT11 sensor, which had inferior accuracy. | + | * Sensor accuracy: The older version of the device was outfitted with a DHT11 sensor, which had inferior accuracy. |
- | • Management of Battery Life and Power: Integrate a rechargeable battery while utilizing the low power modes of the ESP32 to make the device portable and conserve energy. | + | * Management of Battery Life and Power: Integrate a rechargeable battery while utilizing the low power modes of the ESP32 to make the device portable and conserve energy. |
- | • Protective Casing: Create a protective enclosure of the device that will guard it from rain, dust, and extreme temperatures. | + | * Protective Casing: Create a protective enclosure of the device that will guard it from rain, dust, and extreme temperatures. |
- | • Alerts: Notify users of issues such as dry soil and perform advanced data analysis, suggesting resolutions based on the collected data. | + | * Alerts: Notify users of issues such as dry soil and perform advanced data analysis, suggesting resolutions based on the collected data. |
- | • Enhanced Dashboard: Add mobile compatibility, | + | * Enhanced Dashboard: Add mobile compatibility, |
- | • Enhanced Functionality: | + | * Enhanced Functionality: |
+ | |||
+ | ====== Explanation Video ====== | ||
+ | |||
+ | The videos showing the explanation and demo are zipped below. Also included is the schematic file showing how everything is connected. Uploaded here for the size of the zipped file is still too large for Moodle. | ||
+ | |||
+ | {{ : | ||
====== References ====== | ====== References ====== | ||
- | '' | + | '' |
1.Anemometer Working Principle Circuit Digest. (2019). *Anemometer - Wind Speed Sensor Working and Applications*.[https:// | 1.Anemometer Working Principle Circuit Digest. (2019). *Anemometer - Wind Speed Sensor Working and Applications*.[https:// | ||
Line 126: | Line 275: | ||
2.Fritzing – Circuit Design Tool Fritzing.org. (n.d.). *Fritzing: Open-source Electronics Design Software*.[https:// | 2.Fritzing – Circuit Design Tool Fritzing.org. (n.d.). *Fritzing: Open-source Electronics Design Software*.[https:// | ||
- | '' | + | '' |
3.Pandey, S. K., Srivastava, S., Singh, V. K., & Kumar, V. (2025, May 24). ESP32-Based Weather Station. ResearchGate. ResearchGate | 3.Pandey, S. K., Srivastava, S., Singh, V. K., & Kumar, V. (2025, May 24). ESP32-Based Weather Station. ResearchGate. ResearchGate | ||
- | 4.Ganesan, S., Lean, C. P., Li, C., Yuan, K. F., et al. (2024). IoT-Enabled Smart Weather Stations: Innovations, | + | 4.Ganesan, S., Lean, C. P., Li, C., Yuan, K. F., et al. (2024). IoT-Enabled Smart Weather Stations: Innovations, |
+ | |||
+ | '' | ||
+ | |||
+ | 5.Smarthon. (n.d.). Digital light sensor. Smarthon Docs. Retrieved July 29, 2025, from https:// | ||
+ | |||
+ | 6.Espressif Systems. (n.d.). Boot mode selection. Espressif Documentation. Retrieved July 29, 2025, from https:// | ||
+ | |||
+ | 7.Espressif Systems. (2023). ESP32 datasheet (Version 3.6). https:// | ||
+ | |||
+ | 8.Last Minute Engineers. (n.d.). ESP32 sleep modes & power consumption. Retrieved July 29, 2025, from https:// | ||
+ | |||
+ | 9.Espressif Systems. (n.d.). Current consumption measurement for ESP32 modules. Espressif Documentation. Retrieved July 29, 2025, from https:// | ||
+ | |||
+ | 10.Adafruit. (n.d.). DHT11/22 temperature and humidity sensors. Adafruit Learning System. Retrieved July 29, 2025, from https:// | ||
+ | |||
+ | 11.Espressif Systems. (n.d.). ESP32 sleep modes. Espressif Documentation. Retrieved July 29, 2025, from https:// | ||
+ | |||
--- | --- | ||
amc/ss2025/group-g/start.1753821707.txt.gz · Last modified: 2025/07/29 22:41 by 29478_students.hsrw