Need help for watering system

Hey, I’m trying to make a watering system using the code from Emilostuff – Emil Skydsgaard, 2020, who wrote it originally for an esp8266. After changing the code I now tried to compile it, but unfortunately, I always get an error message. Would be great if someone could help me :slight_smile:

(GitHub - Emilostuff/PlantKeeper: Automated Plant Watering System)

β€’ Hardware model + communication type: Esp32 with WiFi
β€’ Smartphone OS (iOS)
β€’ Blynk server

// Libraries
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include<Wire.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

// Networking
char auth[] = "Blynk token";   
char ssid[] = "Network name";
char pass[] = "Password";

// Blynk
BlynkTimer timer;
BlynkTimer timer1;
WidgetRTC rtc;

// System state
int plantSelect = 0;                            // plant 1 selected on default (index 0)
bool systemOn = 0;
bool systFlag = false;
long ontime;
long lastWater[4] = {0, 0, 0, 0};               // 0 means not set
bool pumpOn[4] = {false, false, false, false};

// Settings (can be adjusted from app)
int modes[4] = {0, 0, 0, 0};
int amount[4] = {0, 0, 0, 0};
int interval[4] = {0, 0, 0, 0};
int thresh[4] = {0, 0, 0, 0};
int minInterval[4] = {0, 0, 0, 0};

// sensor/ADC
ADS1115_WE adc(0x48);
float tf = 0.1;                                 // trust factor for smoothing filter
float sensor[4] = {100, 100, 100, 100};         // Set highest start value to avoid unwanted triggers
float sensorDry[4] = {2760, 2680, 2780, 2760};  // Reading from when fully emerged in water
float sensorWet[4] = {1460, 1210, 1510, 1500};  // Reading from when in 'dry' air


// BLYNK ///////////////////////////////////////

BLYNK_CONNECTED()
{
  // Synchronize unix-time on connection
  rtc.begin();
}


// IN-APP EVENT CALLS ///////////////////////
// for when the user presses any button in the app

// System on-off button event
BLYNK_WRITE(V7)
{
  // change system state
  systemOn = param.asInt();

  if (systemOn) {
    if (systFlag) {
      // system has just been turned on!
      systFlag = false;

      // set lastWater to now:
      ontime = now();
      Blynk.virtualWrite(V34, ontime, ontime, ontime, ontime);
      Blynk.syncVirtual(V34);
    }
    // system was turned on when connected -> do nothing
  } else {
    // system is off
    systFlag = true;
  }
}

Unfortunately I get this error

PlantKeeper_public:75:59: error: variable or field 'BlynkWidgetWrite7' declared void
PlantKeeper_public:75:24: error: 'BlynkReq' was not declared in this scope

Your sketch had no void setup or void loop.

Pete.

1 Like

hi pete, where should that start and end? :slight_smile:

I don’t understand the question.

Pete.

void setup() {// put your setup code here, to run once:}
void loop() {// put your main code here, to run repeatedly:}