VirtualWrite causing loss of connection with esp8266

Hi Everyone.

Id like to start by saying ive only started playing with esp8266 and Blynk today so still learning as I go. Also im trying to use a nano with atmega168. (Up at work this week with it so cant try better Arduinos till im home next week).

So I started with the arduino over usb example. Using all virtual pins, 8 outputs controlled but buttons with another button to turn them all off. Plus using virtual write to turn off all 8 buttons on app.

So i then started with the example to use esp8266 as a shield. Copyed over what i did earlier. To get it to fix under 16k i had to usr BLYNK_NO_BUILTIN , BLYNK_NO_FLOAT, and BLNK_NO_INFO. Also disabled BLYNK_PRINT. Still using softwareserial at 9600. Couldn’t get it to work with hardware serial.

The issue is when it does a virtualWrite it loses connection. Im wondering if its because of what ive disabled ?

@Sprocket IMHO ESP as a WiFi shield is a bit of a nightmare and should be avoided if at all possible.

Paste your formatted sketch and we can see if you have the basics set up correctly.

Nano only has one Serial device so hardware serial will not be available, that is for Mega’s etc.

I guess that explains why they are so cheap :smile: I’ll have to look into other options in future. maybe a Arduino Yun?

I just tried dropping baud rate to 4800, no luck though. Also tried cutting it back to just a single vi
rtualwrite.

/* Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial
#define BLYNK_NO_BUILTIN   // Disable built-in analog & digital pin operations
#define BLYNK_NO_FLOAT
#define BLYNK_NO_INFO
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "d3572c04xxxxxxxxxxxxxxxxx";
char ssid[] = "TelstraBE76B7";
char pass[] = "";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(10, 11); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 4800
 ESP8266 wifi(&EspSerial); 

BLYNK_WRITE(V0) 
{
int i=param.asInt();
if (i==1) 
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
Blynk.virtualWrite(V1, LOW); 
Blynk.virtualWrite(V2, LOW); 
Blynk.virtualWrite(V3, LOW); 
Blynk.virtualWrite(V4, LOW); 
Blynk.virtualWrite(V5, LOW); 
Blynk.virtualWrite(V6, LOW); 
Blynk.virtualWrite(V7, LOW); 
Blynk.virtualWrite(V8, LOW); 
}
}

BLYNK_WRITE(V1) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(2, LOW);
  }
else  
  {
  digitalWrite(2, HIGH);
  }
}

BLYNK_WRITE(V2) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(3, LOW);
  }
else  
  {
  digitalWrite(3, HIGH);
  }
}

BLYNK_WRITE(V3) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(4, LOW);
  }
else  
  {
  digitalWrite(4, HIGH);
  }
}

BLYNK_WRITE(V4) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(5, LOW);
  }
else  
  {
  digitalWrite(5, HIGH);
  }
}

BLYNK_WRITE(V5) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(6, LOW);
  }
else  
  {
  digitalWrite(6, HIGH);
  }
}

BLYNK_WRITE(V6) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(7, LOW);
  }
else  
  {
  digitalWrite(7, HIGH);
  }
}

BLYNK_WRITE(V7) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(8, LOW);
  }
else  
  {
  digitalWrite(8, HIGH);
  }
}

BLYNK_WRITE(V8) 
{
int ia=param.asInt();
if (ia==1) 
  {
    digitalWrite(9, LOW);
  }
else  
  {
  digitalWrite(9, HIGH);
  }
}

void setup()
{
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  pinMode(3, OUTPUT);
  digitalWrite(3, HIGH);
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);
  pinMode(6, OUTPUT);
  digitalWrite(6, HIGH);
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);
  pinMode(8, OUTPUT);
  digitalWrite(8, HIGH);
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
 Blynk.run();
}

I was trying to suggest dropping all the Arduino stuff as ESP’s are far better for IOT projects.
You certainly don’t have to think about baud rates down at 4800 and lack of memory with an ESP.
If you really need an Arduino in your project consider “ESP with an Arduino shield” i.e. attach the weak MCU to the mega powerful MCU that has inbuilt WiFi rather than the opposite route you are currently using.

Ahh yes, I see your point. Definetly will be doing that for future projects. Would it possible to do this with the ESP-01 that im using now is this project? I didnt think of trying due to lack of gpio’s

I just tried this on an atmega328, and it works fine. Lack of memory on the nano must have been the issue.