Awesome Open Source
Awesome Open Source

Welcome to OpenGrow!

OpenGrow is a complete IoT solution for autonomously maintaining and tracking the health of your plants.

Connected plants' soil moisture and ambient light levels are continuously monitored and recorded for users to view through a fully responsive web-application.

Also, OpenGrow plants are automatically watered using a PID control system who's setpoint and tolerance can be set at any-time by the user.

OpenGrow is easy to set-up and in this guide I will detail the steps to running OpenGrow in your own home.

You can also find my medium article on this project here.

Program firmware and assemble the circuit Add plants to your account Monitor data and update settings

Table of Contents

  1. System Architecture
  2. Parts List
  3. Web Application Set-Up
  4. ESP8266 NodeMCU Firmware
  5. STM32F4 Firmware
  6. Electrical Schematic
  7. Done!

System Architecture

This complete IoT solution can be broken up into 3 parts:

  1. Web Application (MERN Stack Application)
  2. MQTT Broker (NodeJS with Aedes Framework)
  3. Firmware & Electronics (FreeRTOS on STM32F4 and NodeMCU on ESP8266)

The following diagram illustrates interaction between these components.

Parts List

Following is a list of necessary components to make a single OpenGrow plant monitor. You can make as many plant monitors as you like! Any number of plants will work with your single MQTT broker and web application.

Part Quantity Description
STM NUCLEO-STM32F446 1 Evaluation board for the STM32F446RE processor based on ARM Cortex M4 core. Any STM43F4 series evaluation board will do here.
ESP8266 NodeMCU 1 Low-cost wi-fi integated microchip where we can run the NodeMCU firmware framework.
Digilent Pmod OLED: 128 x 32 Pixel Monochromatic OLED Display 1 Not a necessary component but cool to have! Not much trouble to modify code to work with any SSD1306 based display.
Soil Moisture Sensor 1 Capacitive soil moisture sensor which outputs an analog voltage signal.
Submersible Water Pump 1 Pushes water from an outlet where we attach some tubing leading into the potted plant.
3.3V and 5V Regulator Board 1 Provides 5V to nucleo board and 3.3V to power pump. This is not a necessary component but makes it simpler to follow my provided wiring schematic. You have plenty of options for power and really only need 3.3 V to power the STM32, ESP and pump (with at least 700 mA).
2N222A BJT* 1 Very popular and cheap transistor to switch our pump.
330 Ohm Resistor* 1 Placed at base of the transistor used to toggle the pump.
Photoresistor* 1 Resistance of this component is proportional to ambient light.
10 Kiloohm Resistor* 1 Used to create a voltage divider with the photoresistor where we can take analog voltage reading.

*A small kit like this is the best option for the last 4 components in this list.

Web Application Set-Up

Tech Stack

This full stack web application can be separated into the front-end and back-end.

The front-end is built with React Js framework, styled with Material UI and uses Redux for state management.

The back-end is built with Node Js and the express framework.

Installing Dependencies

Before proceeding, make sure that you have installed Node Js installed on your machine. You can then execute the following sequency of commands:

  1. Copy the repository to your machine.
git clone
  1. Enter the application directory and run the command 'npm install' to install the necessary back-end dependencies from node.
cd .\OpenGrow-IoT-Plant-Monitor\
cd .\application\
npm install
  1. From application directory enter src>client and run the command 'npm install' to install the front-end dependencies.
cd .\src\
cd .\client\
npm install
  1. In the application folder run the command 'npm run build' to compile the typescript code into javascript we can run in a browser.
cd ..
cd ..
npm run build

Your directory should appear as below when all is installed:

Filling Config Options

Navigate to application>config and open the 'default-rename.json' file. You will need to fill some parameters in this file to get up and running.

When you are done, you must remember to rename this file to 'default.json'!!

Mongo URI

First is the 'mongoUri' field. Your application needs a database to connect to and we must provide it here. Go to MongoDB's website and sign-in or create an account. You just need to create a free database for OpenGrow. There are many ways to do this (using Atlas, command line tool, mongoDB website).

When you have created a database, you can get a connection string that looks something like this:

Simply copy and paste this string into the 'mongoUri' value field of default.json.


Under MQTT file, choose a quality of service (qos) for messages sent by your web-application.

Note: I recommend using QoS of 1! With QoS 1 and 2 we have the availability of retained messages. For OpenGrow, this means you can adjust control setpoints from the web application and even if the electronics are not connected to your MQTT broker at that moment, the message will be delivered the next time they do connect.

Now choose a username and password for your MQTT broker. You may choose whatever you like. We must only make sure to give the same credentials when flashing firmware for the ESP8266 so it can connect!

Lastly, the URL for your MQTT broker which your web application uses to connect. In the file application>src>mqtt-broker>broker.ts the MQTT broker is set to run on local machine at port 1883. If you change this and run your broker elsewhere, make sure to update this URL.


The web-application allows multiple user accounts which are password protected. Json-web-tokens are used for authentication.

Follow the URL in the 'jwtSecret' field value to create an encryption string and add it.

Lastly, choose how long you want a user's login to remain valid before they need to login again. Default here is filled as '3h' (3 hours).

Run The Application and Create Plants

You are all set-up! Simply navigate into the 'application' folder and run the command 'npm run dev' to launch OpenGrow.

Now it is important to populate some plants in our database. To do this, make a put request to the route 'http://localhost:3000/api/plant/create'. We can use a service like Postman to do this. The response to our request includes ID of the new plant and the number of plants in our database. We will pass these IDs to our ESP firmware to identify our plants.

ESP8266 NodeMCU Firmware

Navigate into the 'esp8266' folder of this repo for details on uploading the ESP8266 NodeMCU firmware.

STM32F4 Firmware

Navigate into the 'stm32_rtos' folder of this repo for details on uploading the STM32F4 FreeRTOS firmware.

Electrical Schematic

Below is the simple wiring diagram to set up OpenGrow. You can choose to power the STM32 Nucleo board from a 5V power supply if you wish. All other components should be powered only by 3.3V.

Current is required mainly by the submersible pump (up to 300 mA) and the ESP8266 (up to 80 mA). Ensure that the power supply used can provide this.


Power-up your OpenGrow system and you are ready to go!

The blue LED on the ESP will blink slowly to indicate it is connected to your MQTT broker and logging data.

To support this project and future open source projects, consider buying me a coffee and/or starring this repository.

If you encounter any problems running this project, feel free to raise an issue. Pull requests are welcome.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Plus Plus (242,552
Internet Of Things (11,994
Firmware (10,424
Mqtt (7,941
Esp8266 (4,962
Full Stack (3,705
Nodemcu (1,599
Mqtt Broker (629
Iot Device (553
Stm32f4 (169