Grow box problem

hey thanks! its this small stupid problems that im not comfortable with… other syntax errors showed up lol trying to work on them.

stupid question: how to locate the erros on the project? anything related to those numbers in the beginning of the error?

oh god so many problems


// This #include statement was automatically added by the Particle IDE.
#include "PietteTech_DHT/PietteTech_DHT.h"

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"


// system defines
#define DHTTYPE  DHT11              // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN   2         	    // Digital pin for communications
#define DHT_SAMPLE_INTERVAL   600  // Sample every minute

//declaration
void dht_wrapper(); // must be declared before the lib initialization

// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = ""; //Set token from the Blynk app

char VERSION[64] = "0.04";

#define READ_INTERVAL 60000

// My garden setup
 // DHT11 Variables
unsigned int DHTnextSampleTime;	    // Next time we want to start sample
bool bDHTstarted;		    // flag to indicate we started acquisition
int n;                              // counter
  // Moisture variables
int humid1;
int moistureBreakpoint = 30;
bool extractionInverter = 0;
  // Temperature variables
int temperatureBreakpointLow  = 20;
int temperatureBreakpointHigh = 22;
bool heatingInProgress = false;
  // Timer variables
unsigned long Timer;
unsigned long milis;


void setup()
{
  
  Serial.begin(9600);
  delay(5000);
  Blynk.begin(auth);
  // Or specify server using one of those commands:
  //Blynk.begin(auth, ssid, pass, "server.org", 8442);
  //Blynk.begin(auth, ssid, pass, server_ip, port);

  pinMode(D1, OUTPUT); //Output for Water Pump relay 
  pinMode(D2, OUTPUT); //Output for Heater relay 
  pinMode(D3, OUTPUT); //Output for Extraction relay 
  // Initial timer setup
  Timer = millis();
  
   DHTnextSampleTime = 0;  // Start the first sample immediately

}


// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
    DHT.isrCallback();

    
      Serial.println("done setup");
    }

void loop()
{
  Blynk.run();

  // Main function that times and calls all of the other subfunctions
  growBoxMaster();
  
}

void growBoxMaster()
{
  // Check if we need to start the next sample
  if (millis() > DHTnextSampleTime) {
      
	if (!bDHTstarted) {		// start the sample
	    DHT.acquire();
	    bDHTstarted = true;
	}

 if (!DHT.acquiring()) {		// has sample completed?
  
  milis = millis();
  if(milis - Timer >= 1000UL)
  {
    Serial.println("********************* Timed pseudoloop execution *********************");
    moistureMaster();
    heatingMaster();
    Timer = millis();
  }
}

void moistureMaster()

  Serial.println("------- moistureMaster started -------");
  
  float humid = (float)DHT.getHumidity();
  int humid1 = (humid - (int)humid) * 100;
  
  char humidInChar[32];
  sprintf(humidInChar,"%0d.%d", (int)humid, humid1);
  

  // Converting moisture to virtual and sending to Blynk
  moistureVirtual();

  // Printing important values
  Serial.print("Moisture value - ");
  Serial.println(humid1);
  Serial.print("moistureBreakpoint - ");
  Serial.println(moistureBreakpoint);
  
  if((humid1 < moistureBreakpoint) && !extractionInverter)
  {
    startExtraction();
  }
  else if (((humid1 < moistureBreakpoint) && extractionInverter))
  {
    stopExtraction();
  }
  else if((humid1 >= moistureBreakpoint) && !extractionInverter)
  {
    stopExtraction();
  }
  else if((humid1 >= moistureBreakpoint) && extractionInverter)
  {
    startExtraction();
  }
  
  Serial.print("extractionInverter - ");
  Serial.println(extractionInverter);
  
}

void startExtraction()
{
  digitalWrite(2, HIGH);
  Blynk.virtualWrite(25, 1023);
  Serial.println("Extraction - started");
}

void stopExtraction()
{
  digitalWrite(2, LOW);
  Blynk.virtualWrite(25, 0);
  Serial.println("Extraction - stoped");
}

void heatingMaster()
{
  Serial.println("------- heatingMaster started -------");

  getTemperature();

  if(temp1 < temperatureBreakpointLow && !heatingInProgress)
  {
    heatingInProgress = true;
    startHeating();
  }
  if(temp1 >= temperatureBreakpointHigh && heatingInProgress) 
  {
    heatingInProgress = false;
    stopHeating();
  }

  Serial.print("temperatureRealValue - ");
  Serial.println(temperatureRealValue);

  Serial.print("heatingInProgress - ");
  Serial.println(heatingInProgress);

  Serial.print("temperatureBreakpointLow - ");
  Serial.println(temperatureBreakpointLow);

  Serial.print("temperatureBreakpointHigh - ");
  Serial.println(temperatureBreakpointHigh);
}

void startHeating()
{
  digitalWrite(3, HIGH);
  Blynk.virtualWrite(24, 1023);
  Serial.println("Heating - started");
}

void stopHeating()
{
  digitalWrite(3, LOW);
  Blynk.virtualWrite(24, 0);
  Serial.println("Heating - stoped");
}

void getTemperature()
{
    float temp = (float)DHT.getCelsius();
  int temp1 = (temp - (int)temp) * 100;

  char tempInChar[32];
  sprintf(tempInChar,"%0d.%d", (int)temp, temp1);
  
  Blynk.virtualWrite(26, tempInChar);
}


// Getting value of irigationInverter from virtual pin 1
BLYNK_WRITE(V1)
{
  bool pinData = param.asInt();
  extractionInverter = pinData;
}

// Getting value of moistureBreakpoint from virtual pin 2
BLYNK_WRITE(V2)
{
  int pinData = param.asInt();
  moistureBreakpoint = pinData;
}

// Getting value of temperatureBreakpointLow from virtual pin 4
BLYNK_WRITE(V4)
{
  int pinData = param.asInt();
  temperatureBreakpointLow = pinData;
}

// Getting value of temperatureBreakpointHigh from virtual pin 5
BLYNK_WRITE(V5)
{
  int pinData = param.asInt();
  temperatureBreakpointHigh = pinData;
}

void moistureVirtual()
{
  Blynk.virtualWrite(2, humidInChar);
 
}

  n++;  // increment counter
  bDHTstarted = false;  // reset the sample flag so we can take another
  DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;  // set the time for next sample
}



errors:

In file included from blynk/BlynkParticle.h:14:0,
                 from blynk/BlynkSimpleParticle.h:14,
                 from blynk/blynk.h:2,
                 from blynkt.cpp:5:
blynk/BlynkApiParticle.h:90:6: warning: #warning "analogInputToDigitalPin not defined => Named analog pins will not work" [-Wcpp]
     #warning "analogInputToDigitalPin not defined => Named analog pins will not work"
      ^
blynkt.cpp: In function 'void growBoxMaster()':
blynkt.cpp:100:20: error: 'moistureMaster' was not declared in this scope
   if (millis() > DHTnextSampleTime) {
                    ^

In file included from ./inc/application.h:45:0,
                 from blynkt.cpp:2:
../wiring/inc/spark_wiring_usbserial.h:94:16: error: expected initializer before '_fetch_global_serial'
 #define Serial _fetch_global_serial()
                ^

blynkt.cpp:108:3: note: in expansion of macro 'Serial'
   
   ^
blynkt.cpp:149:1: error: a function-definition is not allowed here before '{' token
     stopExtraction();
 ^

blynkt.cpp:156:1: error: a function-definition is not allowed here before '{' token
   Serial.print("extractionInverter - ");
 ^

blynkt.cpp:163:1: error: a function-definition is not allowed here before '{' token
   digitalWrite(2, HIGH);
 ^

blynkt.cpp:255:1: error: expected '}' at end of input
   int pinData = param.asInt();
 ^

make[1]: *** [../build/target/user/platform-6blynkt.o] Error 1
make: *** [user] Error 2

Well, usually they indicate line number and place in the code on that line (e.g. 60:8 means line 60, 8th character). But, be warned weary traveller! Because it’s so delicate in that sense a typ-o on line 8 can influence the compiler in such a way that it comes with an error on line 20.

You have to look carefully for things like missing brackets, too much, weird end of code of line. Because the compiler can only interpret the way it has learned from its “masters” (e.g. the hum-aans who made it, to quote Quark), they can’t have rules for every contingency. Therefor, debugging is a nasty, time consuming, but unfortunately highly needed task. It sucks, I’ll give you that, but it’s the best way to learn from your own mistakes :wink:

2 Likes

ahah totally! i’ve learnt a lot in a shot time regarding coding, a lot due to blynk and this forum but yeah its hard to learn the basics when you’re so hyped about a project ahah i’m only missing this part :disappointed: ill give it a try! thanks man, you’re always around here helping!

Hey i got it to compile! yay!!

I’m now having trouble to add 3 physical toggle buttons to control the extraction, heating and lighting… i’ve declared them as INPUTS but not really sure how to add to the conditions in moistureMaster and heatingMaster and set a condition regarding the lighting ( relay output D3)

code

/* MeLion GrowBox 0.1 */
// This #include statement was automatically added by the Particle IDE.
#include "PietteTech_DHT/PietteTech_DHT.h"
#include "blynk/blynk.h"
// system defines
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define DHTTYPE  DHT11              // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN   0         	    // Digital pin for communications
#define DHT_SAMPLE_INTERVAL   600  // Sample every minute
//declaration
void dht_wrapper(); // must be declared before the lib initialization

// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

// globals
unsigned int DHTnextSampleTime;	    // Next time we want to start sample
bool bDHTstarted;		    // flag to indicate we started acquisition
int n;                              // counter
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = ""; //Set token from the Blynk app

char VERSION[64] = "0.04";

#define READ_INTERVAL 60000

// My garden setup
  // Moisture variables
int humid1;
int moistureBreakpoint = 30;
bool extractionInverter = 0;
int moistureValueVirtual;
  // Temperature variables
int temp1;
int temperatureBreakpointLow  = 20;
int temperatureBreakpointHigh = 22;
bool heatingInProgress = false;
  // Timer variables
unsigned long Timer;
unsigned long milis;

void setup()
{
  
  Serial.begin(9600);
  delay(5000);
  Blynk.begin(auth);

 DHTnextSampleTime = 0;  // Start the first sample immediately

}


// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
    DHT.isrCallback();

// Inputs
  pinMode(A1, INPUT); //Input for Extraction button
  pinMode(A2, INPUT); //Input for Heating button
  pinMode(A3, INPUT); //Input for Lighting button
// Outputs
  pinMode(1, OUTPUT); //Output for Extraction Fan relay 
  pinMode(2, OUTPUT); //Output for Heater relay 
  pinMode(3, OUTPUT); //Output for Led Lighting relay 
  
  
  // Initial timer setup
  Timer = millis();

  Serial.println("done setup");
}

void loop()
{
  Blynk.run();

 // Check if we need to start the next sample
  if (millis() > DHTnextSampleTime) {
      
	if (!bDHTstarted) {		// start the sample
	    DHT.acquire();
	    bDHTstarted = true;
	}

 if (!DHT.acquiring()) {		// has sample completed?

  float temp = (float)DHT.getCelsius();
  int temp1 = (temp - (int)temp) * 100;

  char tempInChar[32];
  sprintf(tempInChar,"%0d.%d", (int)temp, temp1);



  float humid = (float)DHT.getHumidity();
  int humid1 = (humid - (int)humid) * 100;
  
  char humidInChar[32];
  sprintf(humidInChar,"%0d.%d", (int)humid, humid1);
  
  // Converting moisture to virtual and sending to Blynk
  moistureVirtual();
 

  n++;  // increment counter
  bDHTstarted = false;  // reset the sample flag so we can take another
  DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;  // set the time for next sample
 }
 
}

 

  // Main function that times and calls all of the other subfunctions
  growBoxMaster();
  
}

void growBoxMaster()
{
  milis = millis();
  if(milis - Timer >= 1000UL)
  {
    Serial.println("********************* Timed pseudoloop execution *********************");
    moistureMaster();
    heatingMaster();
    Timer = millis();
  }
}

void moistureMaster()
{
  Serial.println("------- moistureMaster started -------");
  


  // Printing important values
  Serial.print("humid1 - ");
  Serial.println(humid1);
  Serial.print("moistureBreakpoint - ");
  Serial.println(moistureBreakpoint);
  
  if((humid1 < moistureBreakpoint) && !extractionInverter)
  {
    startExtraction();
  }
  else if (((humid1 < moistureBreakpoint) && extractionInverter))
  {
    stopExtraction();
  }
  else if((humid1 >= moistureBreakpoint) && !extractionInverter)
  {
    stopExtraction();
  }
  else if((humid1 >= moistureBreakpoint) && extractionInverter)
  {
    startExtraction();
  }
  
  Serial.print("extractionInverter - ");
  Serial.println(extractionInverter);
  
}

void startExtraction()
{
  digitalWrite(1, HIGH);
  Blynk.virtualWrite(25, 1023);
  Serial.println("Extraction - started");
}

void stopExtraction()
{
  digitalWrite(1, LOW);
  Blynk.virtualWrite(25, 0);
  Serial.println("Extraction - stoped");
}

void heatingMaster()
{
  Serial.println("------- heatingMaster started -------");

  getTemperature();

  if(temp1 < temperatureBreakpointLow && !heatingInProgress)
  {
    heatingInProgress = true;
    startHeating();
  }
  if(temp1 >= temperatureBreakpointHigh && heatingInProgress) 
  {
    heatingInProgress = false;
    stopHeating();
  }

  Serial.print("temp1 - ");
  Serial.println(temp1);

  Serial.print("heatingInProgress - ");
  Serial.println(heatingInProgress);

  Serial.print("temperatureBreakpointLow - ");
  Serial.println(temperatureBreakpointLow);

  Serial.print("temperatureBreakpointHigh - ");
  Serial.println(temperatureBreakpointHigh);
}

void startHeating()
{
  digitalWrite(2, HIGH);
  Blynk.virtualWrite(24, 1023);
  Serial.println("Heating - started");
}

void stopHeating()
{
  digitalWrite(2, LOW);
  Blynk.virtualWrite(24, 0);
  Serial.println("Heating - stoped");
}

void getTemperature()
{
  
  Blynk.virtualWrite(26, temp1);
}

// Getting value of extractionInverter from virtual pin 1
BLYNK_WRITE(V1)
{
  bool pinData = param.asInt();
  extractionInverter = pinData;
}

// Getting value of moistureBreakpoint from virtual pin 2
BLYNK_WRITE(V2)
{
  int pinData = param.asInt();
  moistureBreakpoint = pinData;
}

// Getting value of temperatureBreakpointLow from virtual pin 4
BLYNK_WRITE(V4)
{
  int pinData = param.asInt();
  temperatureBreakpointLow = pinData;
}

// Getting value of temperatureBreakpointHigh from virtual pin 5
BLYNK_WRITE(V5)
{
  int pinData = param.asInt();
  temperatureBreakpointHigh = pinData;
}

void moistureVirtual()
{
  Blynk.virtualWrite(23, humid1);

}

cheers!

@bernas_123 by physical “toggle” buttons do you means momentary switches?

Read the button status, set a global variable and check the value of the global variable in your moistureMaster and heatingMaster functions.

See Wemos d1 & blynk for a sample sketch that uses interrupts for button presses (probably worth you reading the whole thread).

thank you, going to check it out! i was thinking of using momentary pushbuttons but i think its easier to use switches

is this correct? i want to add a switch or a button (the easiest way) just to check if things are working, for the lights, fans and heating and resume the operations when i switch off or press again, no matter what the temp and humidity are

int heatingButton 

...
 pinMode(A2, INPUT); //Input for heating button

...

void heatingMaster()
{
  Serial.println("------- heatingMaster started -------");

  getTemperature();

  if(temp1 < temperatureBreakpointLow && !heatingInProgress && heatingButton = HIGH)
  {
    heatingInProgress = true;
    startHeating();
  }
 if(temp1 < temperatureBreakpointLow && !heatingInProgress && heatingButton = LOW)
  {
    heatingInProgress = false;
    stopHeating();
  }
  if(temp1 >= temperatureBreakpointHigh && heatingInProgress && heatingButton = LOW) 
  {
    heatingInProgress = false;
    stopHeating();
  }

No it is not.

  if((temp1 < temperatureBreakpointLow) && (!heatingInProgress) && (heatingButton == HIGH))
  {
    heatingInProgress = true;
    startHeating();
  }
 if((temp1 < temperatureBreakpointLow) && (!heatingInProgress) && (heatingButton == LOW))
  {
    heatingInProgress = false;
    stopHeating();
  }
  if((temp1 >= temperatureBreakpointHigh) && (heatingInProgress) && (heatingButton == LOW)) 
  {
    heatingInProgress = false;
    stopHeating();
  }

Not = but ==, if you put = you are set one variable to equal another variable as opposed to comparing them. I also like to see brackets around each condition.

Try it and see how it goes.

i think i got it, it compiles well!

another question: I’m thinking of using the rtc widget to set a schedule for the lighting but i haven’t stated any function like for the other “masters” since I’ll be sending directly to the digital pin of the relay, how can i set a led widget when the relay is HIGH?

is anything like this?

bool ledRelayState = 0

...

void LightingMaster()
{
Blynk.virtualWrite(23, ledRelayState);
}

BLYNK_WRITE(V1){
    if (param.asInt()){       
        digitalWrite(ledRelayState, HIGH);
    } else {
        digitalWrite(ledRelayState, LOW);
    }
}

many thanks for all the help guys, I’ll be posting pictures of the setup soon:slight_smile:

You need a ; after = 0 but even though bools represent 0 and 1 they are referenced as false and true, so it would be:

bool ledRelayState = false;

Which virtual pin is the LED on and what is V1 and V23?

Doesn’t quite look right.

Combine them, even easier :wink:

BLYNK_WRITE(V1){
    if (param.asInt()){       
        digitalWrite(ledRelayState, HIGH);
        Blynk.virtualWrite(23, HIGH);
    } else {
        digitalWrite(ledRelayState, LOW);
        Blynk.virtualWrite(23, LOW);
    }
}

V1 would be the input from the rtc widget and v23 would be the output for the led widget, i think that @Lichtsignaal did it! Im going to try it! Thanks guys! Really apreciated your help!

The RTC widget, if you use the Blynk one instead of a hardware one, is a different story, but yes. I prefer to use virtual pins because you are much more flexible in what you do. You can set for example two relays high with one button.

Yeah Vpins rock, im starting to realize the potential in them and im going to make a few changes in the project to simplify things. What do you mean regarding blynks rtc widget? I e as planning to use the input from it and give it to a function to close or open a relay…

Blynk has an RTC widget so you don’t need a hardware part anymore to get the time from the Interwebz. It’s really nice to use and saves a couple bucks on hardware, but I’m not sure if you use a hardware RTC, so I thought I’d mention it :slight_smile:

Yeah blynk’s rtc ftw ahah next its try and figure out how to make a weak and day conter. im taking a few days off for vacations and i’ll be back with the full code and pics (i hope). Thanks guys

Im having problems getting through these errors, i’ve making changes after setting the dashboard on my phone, if i anyone could help me it would be great…

/* MeLion GrowBox 0.1 */
// This #include statement was automatically added by the Particle IDE.
#include "PietteTech_DHT/PietteTech_DHT.h"
#include "blynk/blynk.h"
// system defines
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define DHTTYPE  DHT11              // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN   0         	    // Digital pin for communications
#define DHT_SAMPLE_INTERVAL   600  // Sample every minute
//declaration
void dht_wrapper(); // must be declared before the lib initialization

// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

// globals
unsigned int DHTnextSampleTime;	    // Next time we want to start sample
bool bDHTstarted;		    // flag to indicate we started acquisition
int n;                              // counter
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = ""; //Set token from the Blynk app

char VERSION[64] = "0.04";

#define READ_INTERVAL 60000

// My garden setup
bool shutdownButton = 1;
  // Moisture variables
int humid1;
int moistureBreakpoint = 60;
bool extractionInProgress = false;
int moistureValueVirtual;
bool extractionButton = 0;
  // Temperature variables
int temp1;
int temperatureBreakpointLow  = 20;
int temperatureBreakpointHigh = 23;
bool heatingInProgress = false;
bool heatingButton = 0;
  // Lighting variables
bool lightingButton = 0;
  // Timer variables
unsigned long Timer;
unsigned long milis;

void setup()
{
  
  Serial.begin(9600);
  delay(5000);
  Blynk.begin(auth);

 DHTnextSampleTime = 0;  // Start the first sample immediately

}


// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
    DHT.isrCallback();


// Outputs
  pinMode(D1, OUTPUT); //Output for LED Lighting relay 
  pinMode(D2, OUTPUT); //Output for Extraction fan relay 
  pinMode(D3, OUTPUT); //Output for Heater relay 
  
  
  // Initial timer setup
  Timer = millis();

  Serial.println("done setup");
}

void loop()
{
  Blynk.run();

 // Check if we need to start the next sample
  if (millis() > DHTnextSampleTime) {
      
	if (!bDHTstarted) {		// start the sample
	    DHT.acquire();
	    bDHTstarted = true;
	}

 if (!DHT.acquiring()) {		// has sample completed?

  float temp = (float)DHT.getCelsius();
  int temp1 = (temp - (int)temp) * 100;

  char tempInChar[32];
  sprintf(tempInChar,"%0d.%d", (int)temp, temp1);

  float humid = (float)DHT.getHumidity();
  int humid1 = (humid - (int)humid) * 100;
  
  char humidInChar[32];
  sprintf(humidInChar,"%0d.%d", (int)humid, humid1);
  
  // Converting moisture to virtual and sending to Blynk
  moistureVirtual();
 
  n++;  // increment counter
  bDHTstarted = false;  // reset the sample flag so we can take another
  DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;  // set the time for next sample
 }
 
}

 

  // Main function that times and calls all of the other subfunctions
  growBoxMaster();
  
}

void growBoxMaster()
{
  milis = millis();
  if(milis - Timer >= 1000UL)
  {
    Serial.println("********************* Timed pseudoloop execution *********************");
    
    shutdownMaster();
    moistureMaster();
    heatingMaster();
    lightingMaster();
    Timer = millis();
  }
}

void shutdownMaster()
{
  Serial.println("------- shutdownMaster started -------");


  if(!shutdownButton)
  {
      startShutdown();
  }
    // Printing important values
  Serial.print("shutdownButton - ");
  Serial.println(shutdownButton);
}

void startShutdown()
{
  digitalWrite(1, LOW);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  Blynk.virtualWrite(28, 1023);
  Serial.println("SHUTDOWN");
}



void moistureMaster()
{
  Serial.println("------- moistureMaster started -------");
  
  
  if((humid1 > moistureBreakpoint) && (!extractionInProgress) && (extractionButton = HIGH))
  {
    extractionInProgress = true;
    startExtraction();
  }
  if ((humid1 > moistureBreakpoint) && (!extractionInProgress) && (extractionButton = LOW))
  {
    extractionInProgress = true;
    startExtraction();
  }
  if((humid1 < moistureBreakpoint) && (extractionInProgress) && (extractionButton = HIGH))
  {
    extractionInProgress = true;
    startExtraction();
  }
  if ((humid1 < moistureBreakpoint) && (extractionInProgress) && (extractionButton = LOW))
  {
    extractionInProgress = false;
    stopExtraction();
  }
  
  Serial.print("humid1 - ");
  Serial.println(humid1);

  Serial.print("extractionInProgress - ");
  Serial.println(extractionInProgress);

  Serial.print("moistureBreakpoint - ");
  Serial.println(moistureBreakpoint);

}

void startExtraction()
{
  digitalWrite(2, HIGH);
  Blynk.virtualWrite(25, 1023);
  Serial.println("Extraction - started");
}

void stopExtraction()
{
  digitalWrite(2, LOW);
  Blynk.virtualWrite(25, 0);
  Serial.println("Extraction - stoped");
}

void heatingMaster()
{
  Serial.println("------- heatingMaster started -------");

  
  getTemperature();

  
  if((temp1 < temperatureBreakpointLow) && (!heatingInProgress) && (!heatingButton))
  {
    heatingInProgress = true;
    startHeating();
  }
  else if((temp1 < temperatureBreakpointLow) && (!heatingInProgress) && (heatingButton))
  {
    heatingInProgress = false;
    stopHeating();
  }
  else if((temp1 >= temperatureBreakpointHigh) && (heatingInProgress) && (!heatingButton))
  {
    heatingInProgress = false;
    stopHeating();
  }
  else if((temp1 >= temperatureBreakpointHigh) && (heatingInProgress) && (heatingButton))
  {
    heatingInProgress = true;
    startHeating();
  }
  
  Serial.print("temp1 - ");
  Serial.println(temp1);

  Serial.print("heatingInProgress - ");
  Serial.println(heatingInProgress);

  Serial.print("temperatureBreakpointLow - ");
  Serial.println(temperatureBreakpointLow);

  Serial.print("temperatureBreakpointHigh - ");
  Serial.println(temperatureBreakpointHigh);
  
  Serial.print("heatingButton - ");
  Serial.println(heatingButton);
}

void startHeating()
{
  digitalWrite(3, HIGH);
  Blynk.virtualWrite(24, 1023);
  Blynk.virtualWrite(21, HIGH);
  Serial.println("Heating - started");
}

void stopHeating()
{
  digitalWrite(3, LOW);
  Blynk.virtualWrite(24, 0);
  Blynk.virtualWrite(21, LOW);
  Serial.println("Heating - stoped");
}

void getTemperature()
{
  
  Blynk.virtualWrite(26, temp1);
}

void LightingMaster()
{
  Serial.println("------- heatingMaster started -------");

  
  if(!lightingButton)
  {
    startLighting();
  }
  else if(lightingButton)
  {
    stopLighting();
  }
  
  Serial.print("lightingButton - ");
  Serial.println(lightingButton);
}

void startLighting()
{
  digitalWrite(1, HIGH);
  Blynk.virtualWrite(22, 1023);
  Serial.println("Lighting - started");
}

void stopLighting();
{
  digitalWrite(1, LOW);
  Blynk.virtualWrite(22, 0);
  Serial.println("Lighting - stopped");
}


// Getting value of moistureBreakpoint
BLYNK_WRITE(V2)
{
  int pinData = param.asInt();
  moistureBreakpoint = pinData;
}


// Getting value of temperatureBreakpointLow
BLYNK_WRITE(V4)
{
  int pinData = param.asInt();
  temperatureBreakpointLow = pinData;
}


// Getting value of temperatureBreakpointHigh
BLYNK_WRITE(V5)
{
  int pinData = param.asInt();
  temperatureBreakpointHigh = pinData;
}


// Getting value of shutdownButton
BLYNK_WRITE(V6)
{
  bool pinData = param.asInt();
  shutdownButton = pinData;
}


// Getting value of extractionButton
BLYNK_WRITE(V6)
{
  int pinData = param.asInt();
  extractionButton = pinData;
}


// Getting value of LightingButton
BLYNK_WRITE(V7)
{
  bool pinData = param.asInt();
  lightingButton = pinData;
}


// Getting value of heatingbutton
BLYNK_WRITE(V8)
{
    int pinData = param.asInt();
  heatingButton = pinData;
}


void moistureVirtual()
{
  Blynk.virtualWrite(20, humid1);

}

errors:

                 from blynk/BlynkSimpleParticle.h:14,
                 from blynk/blynk.h:2,
                 from blynkt.cpp:4:
blynk/BlynkApiParticle.h:90:6: warning: #warning "analogInputToDigitalPin not defined => Named analog pins will not work" [-Wcpp]
     #warning "analogInputToDigitalPin not defined => Named analog pins will not work"
      ^
blynkt.cpp:16:1: error: expected unqualified-id before 'else'
 else if(lightingButton);
 ^

blynkt.cpp: In function 'void growBoxMaster()':
blynkt.cpp:131:20: error: 'lightingMaster' was not declared in this scope
 }
                    ^

blynkt.cpp: In function 'void LightingMaster()':
blynkt.cpp:290:18: error: 'stopLighting' was not declared in this scope
 }
                  ^

blynkt.cpp: At global scope:
blynkt.cpp:305:1: error: expected unqualified-id before '{' token
     startLighting();
 ^

In file included from blynk/BlynkApi.h:17:0,
                 from blynk/BlynkApiParticle.h:14,
                 from blynk/BlynkParticle.h:14,
                 from blynk/BlynkSimpleParticle.h:14,
                 from blynk/blynk.h:2,
                 from blynkt.cpp:4:
blynkt.cpp: In function 'void BlynkWidgetWrite6(BlynkReq&, const BlynkParam&)':
This looks like an error in blynk library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
blynk/BlynkHandlers.h:155:10: error: redefinition of 'void BlynkWidgetWrite6(BlynkReq&, const BlynkParam&)'
     void BlynkWidgetWrite ## pin (BlynkReq& request, const BlynkParam& param)
          ^

blynk/BlynkHandlers.h:163:31: note: in expansion of macro 'BLYNK_WRITE_2'
 #define BLYNK_WRITE(pin)      BLYNK_WRITE_2(pin)
                               ^
blynkt.cpp:345:1: note: in expansion of macro 'BLYNK_WRITE'
 
 ^
This looks like an error in blynk library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
blynk/BlynkHandlers.h:155:10: error: 'void BlynkWidgetWrite6(BlynkReq&, const BlynkParam&)' previously defined here
     void BlynkWidgetWrite ## pin (BlynkReq& request, const BlynkParam& param)
          ^

blynk/BlynkHandlers.h:163:31: note: in expansion of macro 'BLYNK_WRITE_2'
 #define BLYNK_WRITE(pin)      BLYNK_WRITE_2(pin)
                               ^
blynkt.cpp:337:1: note: in expansion of macro 'BLYNK_WRITE'
 
 ^
make[1]: *** [../build/target/user/platform-6blynkt.o] Error 1
make: *** [user] Error 2
Error: Could not compile. Please review your code.

Wow sorry but your code is messy :sweat:
What board are you using? I will try to compile it here with changes.
A few things I can see though:

  • Put everything in dht_wrapper() (pinMode(), timer and serial output) in setup() and ditch the function all together.
  • Put vars with values in setup(), not just with the #defines.
  • In loop() put if(Blynk.connected()){blynk.run(); );
  • Take all the DHT stuff out of loop and put it in a function with a 2sec timer so you’re not calling it thousands of times a sec when the DHT only transmits every 2 seconds anyway.
  • Define your pins above setup(). I see that in your startShutdown() function you have digitalWrite’s with direct pin numbers. Replace these with definitions.This is more in line of best practice for coding. Also helps if you need to change the pins for whatever reason later. Change it in one place.
  • Many of your declaring errors will go away if you put the loop() as the very last thing in the sketch.
    I find that the best order of a sketch is:

defines
global vars declarations
setup()
blynk_writes()
void functions for your project
loop()

So try reorganizing the layout of your sketch to be more in line with this concept.

Hope this helps!

1 Like

The LightingMaster is easy, you spelled it with a capital L naming the function, but you are calling it with a lowercase L. :slight_smile:

But I do agree with @Jamin. If you clean it up a bit and adhere to what is become to known as the golden Blynk standard it’ll look much nice and will be easier to maintain and more fun to deal with! :smile:

1 Like