Hi Guys I a very new newbie to this Arduino IDE programming.
I have a water controller in my greenhouse but I want to be able to control it in paralell with four relays for the four zones of the controller
I have looked up various sites and did a cut and paste of what I thought would work, but unfortunately I cannot get this to compile without some sort of error.
I think I have managed to get the Blynk mobile side of it working but the arduino side is the issue.
I am using the old legacy of Arduino IDE version arduino-1.8.19-windows as I am running on Windows 7.
I believe I have installed the required libraries for the ESP8266.
Currently the compiler stops at line 81 with the message:
" a function-definition is not allowed her before ‘{’ token "
Any assistance would be greatly appreciated.
Here is the code that I have come up with.
Hopefully someone with more experience can gleam over the program and point out the error or errors.
Any assistance would be greatly appreciated.
Regards Chrisk
// Sketch name - GHWater
// Does not work. Error at line 81
// This program allows the control of four seperate relays via the Mobile Blynk App
#include <dummy.h>
#define BLYNK_TEMPLATE_ID "xxxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxx"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char ssid[] = "xxxxxx";
char pass[] = "xxxxxx!";
char auth[] = "xxxxxxxxxxxxxxxi"
BLYNK_WRITE(V0)
{
int value = param.asInt();
Serial.println(value);
if (value == 0)
{
digitalWrite(D0, LOW); //Setting Digital PIN as LOW to turn OFF device if relay module is "active high"
Serial.println("Water Left OFF");
}
if (value == 0)
{
digitalWrite(D0, HIGH); //Setting Digital PIN as HIGH to turn ON device if relay module is "active high"
Serial.println("Water Left ON");
}
}
BLYNK_WRITE(V1)
{
int value = param.asInt();
Serial.println(value);
if (value == 1)
{
digitalWrite(D1, LOW);
Serial.println("Water Right OFF");
}
if (value == 0)
{
digitalWrite(D1, HIGH);
Serial.println("Water Right ON");
}
}
BLYNK_WRITE(V2)
{
int value = param.asInt();
Serial.println(value);
if (value == 1)
{
digitalWrite(D2, LOW);
Serial.println("Mist OFF");
}
if (value == 0)
{
digitalWrite(D2, HIGH);
Serial.println("Mist OFF");
}
}
BLYNK_WRITE(V3)
{
int value = param.asInt();
Serial.println(value);
if (value == 1)
{
digitalWrite(D3, LOW);
Serial.println("Enable OFF");
}
if (value == 0)
{
digitalWrite(D3, HIGH);
Serial.println("Enable ON");
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(D0, OUTPUT); //GPIO 16;
pinMode(D1, OUTPUT); //GPIO 05;
pinMode(D2, OUTPUT); //GPIO 04;
pinMode(D3, OUTPUT); //GPIO 00;
}
{
void loop()
Blynk.run();
}