G4 Temperature Humidity Soil Moisture Sensor - shalan/CSCE4301-WiKi GitHub Wiki
Temperature/Humidity/Soil Moisture Sensor
Github Repo/Source code: https://github.com/marlanader/Project2
Project Idea
This project is IoT oriented coded in C language. Our goal is to measure the temperature and humidity in the corridors of the department as well as the Soil moisture level in the plants and display them on the department’s screens.
Project Design and Implementation
The microcontroller is responsible for receiving data from the temp/humidity/soil moisture sensors using UART2, each sensor is physically connected to a specific GPIO (Temperature:A1, Humidity:D4, Soil Moisture:A3) along with a 10K resistor, common VCC and ground. Additionally, the microcontroller is connected to the esp32 by connecting the ESP RX2 with A7 of the microcontroller(TX of the UART2) and the TX2 with A2(RX of the UART2). Both the microcontroller and the ESP are connected to the laptop via USB (each having different port). As for the Soil Moisture Sensor, we received its data by using an ADC on CubeMX which is A3 and this ADC pin is connected to the Analog pin of the soil moisture sensor.
So the implementation goes as follows, we started by CubeMX to configure the pins on the microcontroller. After that the sensors measure data and then keil uVision is used to load the code on the microcontroller that receives these data from the sensors using UART that gets displayed on TeraTerm just to make sure that the data sent is correct. Then, the esp32 gets these data using its UART ( Serial2.read() function) and it gets connected to the wifi using the WIFI library and webserver using Arduino IDE and finally it displays the received data on the webserver using client.print().
Software Used
- Keil uVision: This is where the main code runs on the microcontroller
- Stm32CubeMX: Used for the microcontroller configurations
- TeraTerm: Used for debugging purposes to make sure the data sent from the microcontroller is correct
- Arduino IDE: Used to connect the ESP32 with the Webserver where data coming from the microcontroller is displayed
- Browser: Used to display the final results on esp32 Web Server
Hardware Components
- STM32L432KC
- ESP-WROOM-32
- DS18B20 Sunfounder Temperature Sensor
- DHT11 Sunfounder Humiture Sensor
- Soil Moisture Sensor AB054
- Jumper Wires
- 10K Resistors
- Power Supply (USB to Laptop)
- Breadboard
CUBEMX Configuration
.
Readings from the sensors
- Temperature Sensor: Displays the temperature in Celsius up to 2 decimal places
- Humidity Sensor: Displays the humidity as percentage up to 2 decimal places
- Soil Moisture Sensor: Displays the moisture level as a range from (0 to 4095) if it is less than or equal 2000 then the moisture level is 100% (water case) and if it greater than or equal 4000 then the moisture level is 0% (air case)
Debugging on TeraTerm
Limitations & Solutions
- Shortage of Raspberry Pi to display the data on Screen, as a result we were not able to display the data on the screen instead we displayed them on Webserver
- We didn't have any soil/plant to test its moisture level, instead we used a cup of water that should give max Moisture level (100%)
- The Soil Moisture Sensor is inaccurate, it gives inaccurate and inconsistent results for the soil moisture level
- Shortage of jumper wires, we inserted the esp and microcontroller in the breadboard but the pins are not totally inserted so there is a bit of misconnection