Device is online but wont control LED

Apologies - very new to this, I am trying to simply control an LED over the internet. I have tried numerous differetn sketches but no success yet.

I am using an arduino uno with Osoyoo ESP8266 WIFI shield which stacks on top. I am trying to set it up using Blynk 2.0, I have set up the account etc and designed a template with one switch on it and I have managed to get the device to appear online but it just wont control my LED. I have the latest Blynk libary installed and using the Blynk server.

Im sorry - I am sure this is a very simple question, I have tried many example bits of code from the Blynk library but just get error messages. So I followed a youtube video to get me to this point below.

#define BLYNK_TEMPLATE_ID "My template ID from Blynk dashboard"

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "My auth code";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "My wifi router";
char pass[] = "My password";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
 #include <SoftwareSerial.h>
 SoftwareSerial EspSerial(4, 5); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V0, value);

void setup()
  // Debug console
  pinMode(V0, OUTPUT);


  // Set ESP8266 baud rate

  Blynk.begin(auth, wifi, ssid, pass);

void loop()

What do you see in your serial monitor when you run this code?


Hi Pete,

this is what the serial monitor offers…

/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
//_, /////_
__/ v1.1.0 on Arduino Uno


[658] Connecting to BT-SKATMF
[3864] AT version: 1 2016 20:04:45)
SDK version:
Ai-Thinker Technology Co. Ltd.
Dec 2 2016 14:21:16
[4964] Failed to enable MUX
[8160] +CIFSR:STAIP,“”
[8169] Connected to WiFi
[18512] Ready (ping: 43ms).

When you post serial output or compiler error messages you should use triple backticks at the beginning and end, the same as when you post code.

Your sketch has no code to control an LED. Are you doing this via a digital datastream?
If so, how have you configured this datastream, and what type of widget is it connected to, and how have you configured that widget?


Apologies for not using the backticks.

So again I followed a tutorial online setting up a digital datastream usiing a virtual pin (v0) and integer datatype - then connected to a switch widget with the datastream connected.

Okay, the code above is triggered each time the V0 datastream value changes, in other words each time you change the switch widget state in the app. However, the incoming value from that switch widget is simply being written straight back to that switch widget here…

So the switch is telling your device that it is now ON, and your device is telling the switch to turn ON.

It’s not clear from what you’ve sais whether you are trying to control a physical LED connected to your board, or an LED widget in the app.

If it’s an LED widget then that would need its own datastream (not V0) and you’d need to be changing the line of code above to update that datastream.

If you’re trying to control a physical LED then whatever pin that is connected to needs to be declared as an OUTPUT pin in a pinMode statement, and you need to be using a digitalWrite command to control the pin.


1 Like

Pete you absolute legend!! Thanks so much - have got it to work!! Literally taken me most of the day!! Haha!! I can go to sleep easy tonight!

Thanks for taking the time to answer to a total newbie - wouldnt think I spend all day coding in R for my day job!!

Very best wishes - much appreciated

1 Like