Blynk Plants Grow Box


I just (finnaly) finished my Grow Box and wanna share it.

Wemos D1 mini Pro;
3 x DS18B20 One Wire Temperature Sensors;
SI70 - RH & Temp Sensor;
4 Relay module Board
1 TIPP31C for each Fan (For speed control)

Automatic lamps temperature (I used COB lights with a large radiator cooled by 2 12V fans);
Setting up the box temperature by large 12V fan that blows in air driven by a TIPP31C transistor;
Setting up the upper box temperature by a medium 12V fan that blows out the air driven by other transistor;
Setting up the RH inside the box with a piezo “mist maker”;
Setting up timers for light schedule;
Silent buttons for all the fans;

I will be more than glad for opinions and improvements. I must mention that I am at the very low knowledge of programming world so… I will really be happy if you can see something wrong or something that it could be better.

Thank you!


#define BLYNK_PRINT Serial  // Comment this out to disable prints and save space
//#define BLYNK_DEBUG
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <SPI.h>
#include <Si7021.h>
#define ONE_WIRE_BUS 0    //Data wire plugged to pin (DS18B20 sensor)

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Si7021 si7021;
SimpleTimer timer;

//int test;
int ledsFanSilentModeButton;
int ledsTimerState;
int ledsTimer = 16; //Lamp relay pin for timer widget
int fanInPin = 13;
int fanOutPin = 12;
int boxFansTimerState;
int fanInSilentModeButton;
int fanOutSilentModeButton;
int inMinSetTemp;
int outMinSetTemp;
int humidifierPin = 14; //Humidifier relay pin
int rhSetValue;

char auth[] = "f427bbd267894a08bdd4219axxf46ab1"; //Put your Auth Token in the Blynk App here
char ssid[] = "Vecinu' de deasupra";
char pass[] = "individual";

WidgetLED onOffLedsLed(V20);
WidgetLED humidifierStateLed(V21);
  ledsTimerState = param.asInt();
  ledsFanSilentModeButton = param.asInt();
  fanInSilentModeButton = param.asInt();
  fanOutSilentModeButton = param.asInt();
  inMinSetTemp = param.asInt();
  outMinSetTemp = param.asInt();
  rhSetValue = param.asInt();

void setup() {
  Blynk.begin(auth, ssid, pass); //insert here your SSID and password
  sensors.begin(); //DS18B20 temp. sensors
  sensors.setResolution(10);   //More on resolution:
  timer.setInterval(1000, readTemps);   //DS18B20 Data reading interval
  pinMode(ledsTimer, OUTPUT);
  pinMode(fanInPin, OUTPUT);
  pinMode(fanOutPin, OUTPUT);
  pinMode(humidifierPin, OUTPUT);
  Blynk.syncVirtual(V0, V51, V52, V53, V20, V40, V41, V42);

void readTemps() {
  float ledTemp = sensors.getTempCByIndex(0); //Stores temperature. Change to getTempFByIndex(0) for F.
  float tempTavan = sensors.getTempCByIndex(1);
  float tempDataLogger = sensors.getTempCByIndex(2);
  float boxTemp = si7021.getTemperatureFromPreviousHumidityMeasurement();
  float boxRH = si7021.measureHumidity();
  Blynk.virtualWrite(V1, tempTavan); //DS18B20 temperatures
  Blynk.virtualWrite(V2, ledTemp);
  Blynk.virtualWrite(V3, tempDataLogger);
  Blynk.virtualWrite(V4, boxRH);
  Blynk.virtualWrite(V5, boxTemp);

  //------------PWM Global Fans automatic Settings-------------//
  int ledsFanPin = 15;
  const int fanSpeedOff = 0;
  const int fanSpeedIdle = 60;
  const int fanSpeed20 = 100;
  const int fanSpeed40 = 200;
  const int fanSpeed60 = 400;
  const int fanSpeed80 = 800;
  const int fanSpeed100 = 1024;
  int ledsFanCtrlTemp;
  int inFanCtrlTemp;
  int outFanCtrlTemp;

  //-----------Leds Timer-----------//
  if (ledsTimerState == 1) {
    digitalWrite(ledsTimer, HIGH);
  } else {
    digitalWrite(ledsTimer, LOW);;

  //-----Leds Fan silent Mode button-----//
  if (ledsFanSilentModeButton) {
    ledsFanCtrlTemp = 15;
  } else {
    ledsFanCtrlTemp = ledTemp;
  //-------Fan in Silent Mode button------//
  if (fanInSilentModeButton == 1) {
    inFanCtrlTemp = 15;
  } else {
    inFanCtrlTemp = boxTemp;

  //------Fan Out Silent Mode Button------//
  if (fanOutSilentModeButton == 1) {
    outFanCtrlTemp = 15;
  } else {
    outFanCtrlTemp = tempTavan;

  //---------------LED fan automatic control------------------//
  if (ledsFanCtrlTemp <= 30) {
    analogWrite(ledsFanPin, fanSpeedOff);
    Blynk.virtualWrite(V30, "OFF");
  else if (ledsFanCtrlTemp == 33) {
    analogWrite(ledsFanPin, fanSpeedIdle);
    Blynk.virtualWrite(V30, "IDLE");
  else if (ledsFanCtrlTemp == 35) {
    analogWrite(ledsFanPin, fanSpeed20);
    Blynk.virtualWrite(V30, "20%");
  else if (ledsFanCtrlTemp == 37) {
    analogWrite(ledsFanPin, fanSpeed40);
    Blynk.virtualWrite(V30, "40%");
  else if (ledsFanCtrlTemp == 40) {
    analogWrite(ledsFanPin, fanSpeed60);
    Blynk.virtualWrite(V30, "60%");
  else if (ledsFanCtrlTemp == 45) {
    analogWrite(ledsFanPin, fanSpeed80);
    Blynk.virtualWrite(V30, "80%");
  else if (ledsFanCtrlTemp >= 50) {
    analogWrite(ledsFanPin, fanSpeed100);
    Blynk.virtualWrite(V30, "100%");

  //-----------------Fan In automatic control-------------------//
  if (inFanCtrlTemp < inMinSetTemp) {
    analogWrite(fanInPin, fanSpeedOff);
    Blynk.virtualWrite(V31, "OFF");
  else if (inFanCtrlTemp == inMinSetTemp) {
    analogWrite(fanInPin, fanSpeedIdle);
    Blynk.virtualWrite(V31, "IDLE");
  else if (inFanCtrlTemp == inMinSetTemp + 1) {
    analogWrite(fanInPin, 512);
    Blynk.virtualWrite(V31, "50%");
  else if (inFanCtrlTemp >= inMinSetTemp + 2) {
    analogWrite(fanInPin, 1023);
    Blynk.virtualWrite(V31, "100%");

  //--------------------Fan Out Automatic Control-----------------//
  if (outFanCtrlTemp < outMinSetTemp) {
    analogWrite(fanOutPin, fanSpeedOff);
    Blynk.virtualWrite(V32, "OFF");
  else if (outFanCtrlTemp == outMinSetTemp) {
    analogWrite(fanOutPin, 19);
    Blynk.virtualWrite(V32, "IDLE");
  else if (outFanCtrlTemp == outMinSetTemp + 1) {
    analogWrite(fanOutPin, 40);
    Blynk.virtualWrite(V32, "50%");
  else if (outFanCtrlTemp >= outMinSetTemp + 2) {
    analogWrite(fanOutPin, fanSpeed20);
    Blynk.virtualWrite(V32, "80%");

  //--------------------RH Automatic Control---------------------//
  if (rhSetValue > boxRH) {
    digitalWrite(humidifierPin, HIGH);
    digitalWrite(humidifierPin, LOW);;
void loop() {;;



that looks pretty hefty for a couple of plants…so what exactly are you going to grow there?

1 Like


1 Like

…Im apparently not the only one with that thought…


No, you’re certainly not. Thinking of lilies and remains :slight_smile:

1 Like

Very cool box. Love it!

Show us your “lilies” when they are “ready” :wink:

1 Like

i’m sure that it will be tomatoes… or not XD

African broccoli :sunglasses:?

I have to agree with @pavel here: it really is a cool box! Nice project and yet another awesome example of how blynk can be put to good use (just like the bbq )

1 Like

A bbq, a broccoli grow box… we need a beer cooler and we can start the pool party :sunglasses:

1 Like


It’s already there :wink: :beers:


epic :heart_eyes:

Well if all is done then i’ll carry the ox chops… these are from my town, 1kg each with four to five centimeters of thick :crazy_face:

1 Like

Thank you guys! I will not grow anything illegal!
After today’s tests it seems that with this particular line:

WidgetLED humidifierStateLed(V21);

When the humidity must rise and turn on the humidifier relay (that works without led widget) I get a watchdog reset.

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
[4937] Connecting to Vecinu' de deasupra
[5439] Connected to WiFi
[5439] IP:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.3 on Arduino

  Give Blynk a Github star! =>

[5452] Connecting to
[5598] Ready (ping: 35ms).

 ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

Don’t know why because the led widget for lamp timer works perfect…
I know maybe it is not a blynk related problem but could you give me a hand.

Try replacing this line:

humidifierStateLed.on(); with Blynk.virtualWrite(V21, 255);

and this line:; with Blynk.virtualWrite(V21, 0);

See if it helps. WDT reset can be produced by doubling virtual pin functions in your code, but this is not the case here, as far as I can see.

1 Like

Seems to work for now! Thank you very much!

1 Like

Do you happen to live in the Netherlands? As its perfectly legal to grow upto 5 african broccoli’s in your home.

and in other countries it is legal if it will be used for therapeutic purposes under medical prescription

hi i am trying to do this project in blynk 2.0 i am getting widget error what should i do do i need a separate library for the widget

Impossible to say based on the information you’ve provided.