#define BLYNK_TEMPLATE_ID "Template ID"
#define BLYNK_TEMPLATE_NAME "Name"
#define BLYNK_AUTH_TOKEN "" //??
#define BLYNK_PRINT Serial //??
#define BLYNK_FIRMWARE_VERSION "0.1.0" //??
#define BLYNK_PRINT Serial //??
#define BLYNK_DEBUG //??
#define APP_DEBUG //??
#define DHT11_PIN 6
#include<SoftwareSerial.h>
#include <ESP8266_Lib.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include "DHT.h"
char ssid[] = "ssid";
char pass[] = "pass";
int Relaispin = 7;
const int seuilHumidite = 400;
DHT dht(6, DHT11);
SoftwareSerial EspSerial(2, 3);
#define ESP8266_BAUD 9600);
ESP8266 wifi(&EspSerial);
void setup() {
pinMode(DHT11, INPUT);
pinMode(Relaispin, OUTPUT);
pinMode(Relaispin, LOW);
digitalWrite(DHT11, LOW);
{
Serial.begin(115200);
EspSerial.begin(ESP8266_BAUD);
delay(10); //??
Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass); // On peut également spécifier le serveur : //??
//Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}
}
BLYNK_WRITE(V0) { // Executes when the value of virtual pin 0 changes
if (param.asInt() == 1) {
digitalWrite(7, HIGH); // Set digital pin 2 HIGH // execute this code if the switch widget is now ON
} else {
// execute this code if the switch widget is now OFF
digitalWrite(7, LOW); // Set digital pin 2 LOW
}
}
void loop() { //Ce qui se répette tout le temps
Blynk.run();
digitalWrite(DHT11, HIGH);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidite: ");
Serial.println(h);
Serial.print("Temperature: ");
Serial.println(t);
delay(90000); // Attendre 90 secondes soit 1 min et 30 s
int valeurHumidite = analogRead(DHT11);
if (valeurHumidite < seuilHumidite) {
digitalWrite(Relaispin, HIGH);
Serial.println("Pompe allumée. Arrosage en cours...");
} else {
digitalWrite(Relaispin, LOW);
Serial.println("Pompe éteinte.");
}
}
And the error message:
sketch_sep1a.ino: In function 'void setup()': 31:33: error: expected primary-expression before ')' token
EspSerial.begin(ESP8266_BAUD);
^
exit status 1
Compilation error: expected primary-expression before ')' token
No, these lines are supposed to be pair of void setup, and functions begin with the name of the function and brackets that contain the parameters that are passed to the function.
Hello,
I can’t connect the Arduino Uno and the shield to the wifi to use blynk.
How should I do it?
I tested from a phone, but it doesn’t detect the shield. I saw that you can connect with a QR code. How should I do it if I use this option?
Here is my code: Could you tell me if I have to put my credentials for this line?
Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass);
#define BLYNK_TEMPLATE_ID "Template ID"
#define BLYNK_TEMPLATE_NAME "Name"
#define BLYNK_AUTH_TOKEN "" //??
#define BLYNK_PRINT Serial //??
#define BLYNK_FIRMWARE_VERSION "0.1.0" //??
#define BLYNK_PRINT Serial //??
#define BLYNK_DEBUG //??
#define APP_DEBUG //??
#define DHT11_PIN 6
#include<SoftwareSerial.h>
#include <ESP8266_Lib.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include "DHT.h"
char ssid[] = "ssid";
char pass[] = "pass";
int Relaispin = 7;
const int seuilHumidite = 400;
DHT dht(6, DHT11);
SoftwareSerial EspSerial(2, 3);
#define ESP8266_BAUD (9600)
ESP8266 wifi(&EspSerial);
void setup() {
pinMode(DHT11, INPUT);
pinMode(Relaispin, OUTPUT);
pinMode(Relaispin, LOW);
digitalWrite(DHT11, LOW);
Serial.begin(115200);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass); // On peut également spécifier le serveur :
//Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}
BLYNK_WRITE(V0) { // Executes when the value of virtual pin 0 changes
if (param.asInt() == 1) {
digitalWrite(7, HIGH); // Set digital pin 2 HIGH // execute this code if the switch widget is now ON
} else {
// execute this code if the switch widget is now OFF
digitalWrite(7, LOW); // Set digital pin 2 LOW
}
}
void loop() { //Ce qui se répette tout le temps
Blynk.run();
digitalWrite(DHT11, HIGH);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidite: ");
Serial.println(h);
Serial.print("Temperature: ");
Serial.println(t);
delay(90000); // Attendre 90 secondes soit 1 min et 30 s
int valeurHumidite = analogRead(DHT11);
if (valeurHumidite < seuilHumidite) {
digitalWrite(Relaispin, HIGH);
Serial.println("Pompe allumée. Arrosage en cours...");
} else {
digitalWrite(Relaispin, LOW);
Serial.println("Pompe éteinte.");
}
}
Thank you
You’ve told your Arduino to send debug messages to your serial monitor at 115200 baud, and you need to set your serial monitor on your PC to recieve data at the same baud rate…
You upload the code to the Arduino and if the code, the credentials, the jumper settings on the WiFi board and the communication settings (baud rate etc) are correct then it will connect to your WiFi and then to the Blynk server.
At that point, it will appear as “online” in the Blynk web console and in the Blynk app.
At each stage of the process, your serial monitor will show you the progress, and messages relating to any problems that are encountered.
So, it’s essential that you have your serial monitor set-up and working correctly.