Hardware question of my blynk project (Arduino+ESP8266 wifi shield)

Here there are:
The code:

#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

Thanks

Why do you have opening and closing curly brackets at the beginning and end of these lines of code?

Pete.

I don’t now! I thought it was a separate function.

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.

Pete.

Ok I have correct but there is the same mistake. Do you know where it might come from?
Thank you

You have a semicolon at the end of this line which shouldn’t be there.

Pete.

Thank you It is work!
Thank you very much for your help

It may now compile, but does your device actually connect to WiFi and Blynk, and stay online for any length of time?

Pete.

I will check

I haven’t compiled yet because I haven’t had much time. Should I complete the steps to configure the Wifi shield on page 14 ?

https://docs.google.com/document/d/1LFCe6MTNQh_0EBHRgc0f6n_hDLNUG8sFuM53oBJG8eE/view?pli=1

It’s the instructions on Page 11 that you need to follow, and you need to configure the Rx and Tx values to match those you are using here:

The first number in brackets is the Rx digital pin used by Software serial, the second is the Tx digital pin.

Pete.

ok !

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

Another thing: how come this message is displayed in the console?

iK
��21t{�i�4������

The baud rate is 9600 Bauds though.
I think it’s the serial.println lines but why is it unreadable?
Thanks

Yes, at start default Baud rate is set to 9600, and your serial monitor is set to 115200

So I need to set the flow rate to 115200?

I did the test on page 7 of this guide(7.1). But as soon as I press ENTER, the message disappears and there is no response.

Thank you for your help

I don’t know what that means.

Your credentials go here:

and here:

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…

[quote=“Amateur, post:33, topic:71839”]
Serial.begin(115200);
[/quote

Pete.

Ok thanks

I don’t know what that means.

Can you tell me how to connect the wifi shield with the blynk interface.
Thank you

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.

Pete.