This project utilizes a PIC18F4580 microcontroller to read analog data from a moisture sensor and then sends this data via UART to an ESP32. The ESP32 hosts a web server that displays the moisture levels. Additionally, the system is designed to turn on a pump when the moisture levels fall below 20% and to indicate the moisture levels using three LEDs.
- PIC18F4580 Microcontroller
- ESP32 Module
- Moisture Sensor
- LEDs
- Pumps
The PIC18F4580 is configured to read the analog values from the moisture sensor using ADC. It then converts these values to a voltage percentage representation of the moisture levels. The UART communication is set up at a baud rate of 9600.
The ESP32 is set up as an access point with the SSID "Plant Status Monitor" and a predefined password. It hosts a web server that refreshes every 3 seconds to display the latest moisture levels.
- The PIC18F4580 continuously reads the moisture level from the sensor.
- The ADC value is converted to a percentage and sent over UART to the ESP32.
- The ESP32 updates the web server with the current moisture level.
- If the moisture level is below 20%, the PIC18F4580 activates the pump.
- The LEDs on the PIC18F4580 indicate the range of the moisture level:
- Red LED for low (0-19%)
- Yellow LED for medium (20-39%)
- Green LED for high (40-100%)
The web server displays the moisture level with a color code:
- Red for low moisture
- Orange for medium moisture
- Green for high moisture
- Connect the moisture sensor to the PIC18F4580.
- Connect the LEDs and the pump to the appropriate pins on the PIC18F4580.
- Set up the ESP32 with the provided code and connect it to the PIC18F4580 via UART.
- Power up the system and connect to the ESP32's WiFi network.
- Access the web server using the IP address displayed in the serial monitor.
The code for both the PIC18F4580 and the ESP32 is included in the project files. Ensure to configure the microcontroller and the module according to the pin definitions and settings provided in the code comments.
Ensure that all electrical connections are secure and that the pump is suitable for the voltage provided by the PIC18F4580.
This project is released under the MIT License.