Course project · 2024
IoT Watering
An Arduino reads soil moisture and runs a pump. An ESP8266 brings it online. A server on a Raspberry Pi stores the readings, and a web page shows them live and changes the settings.
- Team
- 6 people
- Time
- Nov–Dec 2024
- Course
- Microcomputers (CO3006)
- Code
- GitHub ↗
- Stack
- Arduino
- ESP8266
- C++
- Node.js
- Next.js
- Raspberry Pi
01 / My part
What I did
I wrote the ESP8266 firmware and the custom protocol, the Arduino control logic, the Node.js server and the Next.js web page.
02 / System
From sensor to browser
The Arduino reads the moisture sensor and switches the pump through a relay. The ESP8266 gives it Wi-Fi. The server on the Raspberry Pi stores the readings, and the web page shows them live.
03 / Highlights
Engineering highlights
- Protocol A binary protocol of my own. Each packet starts with a one-byte opcode, and a moisture reading is two bytes. JSON would be several times larger on the 9600-baud serial link between the Arduino and the ESP8266.
- Debugging On the dormitory network, the ESP8266 could not keep a WebSocket connection, but plain TCP worked. The likely cause was a firewall that filters at the application layer, so I moved the device to TCP.
- Reliability When the Wi-Fi or the connection drops, the device reconnects by itself. When the Arduino detects a fault, it resets the ESP8266 through its EN pin.
- Control Watering starts when the moisture falls below a lower limit and stops at an upper limit. The limits, the sensor calibration and the report interval change from the web page.
04 / Result
The device and the dashboard
The test rig, and the web page with the live reading, the target range and the history.