petehwu / holberton_end_of_year

Automated soil moisture monitoring system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hippocamp Soil moisture monitoring system

Description

Holberton School End of Year project.

A website utilizing Internet Connected Arduino sensors to monitor and record soil moisture levels.

In this project we use the ESP32 Arduino chip connected to capacitative moisture sensor to measure the moisture level of soil. The sensors are connected to the internet using the WiFi capability of the ESP32 chip. The sensors are connected to a node.js web server using Socket.IO to enable two-way communication. The sensors are programmed to automatically send data to the server at one minute intervals. In addition, the sensors are programmed to send data to the server immediately if a large increase in moisture level is detected.

This system consists of a nginx server acting as a proxy to route traffic. The nginx server is connected to a node.js server using express andSocket.IO and a gunicorn/Flask server. The node.js server is used to serve all web content and maintain websocket connections to the sensors while the gunicorn/Flask server is used to serve API requests to obtain data from the backend database. The backend database that stores all data is a MySql database server.

System Architecture and data flow:

  1. The Node.js server waits for connections from any sensor or web client.
  2. The moisture sensor connects to the nginx server via https and then is routed to the Node.js server and a socket.IO web socket connection is created and maintained by the Node.js server.
  3. The moisture sensors are programmed to send data to the server every 60 seconds.
  4. When the Node.js server receives data from the sensors the data is written to the MySql database.
  5. When a web client(browser) connects to the website, the request is routed to the node.js server to serve the page and the .html is sent to the client.
  6. The web client(browser) processes the data that is sent from the server and establishes a socket.IO connection with the node.js server
  7. After the websocket connection is established with the web client(browser), the node.js server sends a broadcast to the client to load data.
  8. The javascript code on the web client(browser) makes an API request to the server.
  9. The gunicorn server responds to the API call and returns data
  10. The browser processes the data that is returned from the API call and generates some dynamic content(sensor data information and formatting) and displays the result to the user.
  11. If the user clicks on a button on the web client(browser), the page will send a message to the node.js server via the socket.IO websocket connection
  12. When the node.js server receives the message from the web client it will send out a broadcast to all devices coded with an id to the sensor that needs to be activated.
  13. All devices will receive the broadcast but only the intended device will respond because of the id that is sent with the broadcast.

System Setup and software used:

Ubuntu 18.04
MySql 5.7.25
node.js
express
socket.IO
Python 3 Flask
gunicorn
Arduino IDE

Authors

Cameron Eng
Peter Wu

About

Automated soil moisture monitoring system.


Languages

Language:C++ 66.5%Language:JavaScript 13.2%Language:Python 10.0%Language:HTML 7.8%Language:CSS 2.5%