Hi guys , I am new with arduino uno and also this kind of electronic stuff . I not really sure where to upload the code . to arduino or esp8266? Do I need to change the programmer on tools ?
I have problem :
if I upload the coding1 to esp8266 , it has connection but the relay doesn’t response
if I upload my other coding to arduino , the is no connection at all
I hope you all can help me
I already review some of the topic similar to mine but it didn’t solve the problem
coding for esp8266 ( board generic module esp 8266)
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth key";
// Your WiFi credentials.
// Set password to "" for open networks.
const char ssid[] = "wifi name";
const char pass[] = "wifi pass";
int relay_1 = 2;
void setup()
{
pinMode(relay_1,OUTPUT);
digitalWrite(relay_1,V1);
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, "wifi name ", "wifi pass"); //insert here your SSID and password
while (Blynk.connect() == false)
{
// Wait until connected
}
Serial.print(" Blynk Setup ");
// Setup a function to do reconnection attempts once a minute
}
BLYNK_WRITE(V1)
{
pinMode(relay_1,OUTPUT);
if(digitalRead(relay_1)==LOW) //Low = on relay
{
digitalWrite(relay_1,HIGH); // high = relay is switch off
Serial.print(" Pin set to HIGH (OFF) ");
}
else //else if relay is off
{
digitalWrite(relay_1,LOW); //will be set to on
Serial.print(" Pin set to LOW (ON) ");
}
pinMode(relay_1,INPUT);
}
void reconnectBlynk()
{
if (!Blynk.connected())
{
if (Blynk.connect())
{
Serial.print(" Blynk Reconnected ");
}
else
{
Serial.print(" Blynk Not reconnected ");
}
}
}
void loop()
{
if(Blynk.connected())
{
Blynk.run();
}
}
ESP8266 with AT firmware essentially becomes just a simple a WiFi to Serial adapter, so all your code is installed on the UNO and in the App you set the device as UNO and connection method as WiFi.
it looks like you are using an ESP-01, so unless you have managed to flash it already with something else, it should already have the correct (or correct enough) AT firmware. You will need to set its BAUD rate to 9600 BAUD as per the documentation.
Aside from the AT firmware, you don’t upload anything else to the ESP-01… you upload to the Arduino through the Arduino’s USB port and connect to Blynk Cloud through the ESP (as an WiFi adapter).