Need help with connecting Wifi shield with Blynk


Hi guys,
I’m really new in all this Arduino stuff with very poor coding skills so please be gentle…
I’m trying to control a servo manually (using push button) and also via Wifi (using blynk). I’m using Arduino Uno + Wifi shield.
Please see my sketch, when I’m trying to run this code the serial shows shows:
Connecting to again and again.
I see many topics describing the same issue and I tried to follow the instructions but still facing the same issue.

I tried to change it to use Blynk.config(wifi, auth) in the setup and also to connect to hotspot instead of my router but still the same issue… Can you help me understand what am I doing wrong?

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <SPI.h>
#include <BlynkSimpleWifi.h>
#include <LiquidCrystal.h>
#include <Servo.h>

LiquidCrystal lcd(A5, A4, A3, A2, A1, A0); /*Initialize the LCD and
                                        tell it which pins is
                                        to be used for communicating*/

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////WiFi code
// Set password to "" for open networks.
char ssid[] = "123";
char pass[] = "123";

int status = WL_IDLE_STATUS;     // the Wifi radio's status

////////////////////////////////////////////////////////////////////////////////////////////////////////////////Servo code
int button = 2; //button pin, connect to ground to move servo
int press = 0;
Servo servo;
boolean toggle = true;

/////////////////////////////////Blynk + servo

void setup() {
  // initialize serial:

  // attempt to connect using WPA2 encryption:
  Serial.println("Attempting to connect to WPA network...");
  Blynk.begin(auth, ssid, pass);
  lcd.print("Trying to");

  ////Servo code
  pinMode(button, INPUT); //arduino monitor pin state
  servo.attach(6); //pin for servo control signal
  digitalWrite(5, HIGH); //enable pullups to make pin high

  // if you're not connected, stop here:
  if ( status != WL_CONNECTED) { 
    Serial.println("Couldn't get a wifi connection");
    lcd.print("Couldn't connect");
  // if you are connected, print out info about the connection:
  else {
    Serial.println("Connected to network");
    lcd.print("Connected to");

void loop() {
press = digitalRead(button);
  if (press == LOW)
      toggle = !toggle;
      toggle = !toggle;
  delay(500);  //delay for debounce;  


Hmmmm, where to begin?

Let’s start with the way the code you posted displays. You didn’t use backticks at the beginning and end, as explained in the pre-populated text that you deleted. Edit your posts I g the pencil icon at the bottom and add the required backticks and cpp…


Then there’s your void loop. Read this:

I’m not familiar with the Wi-Fi shield you’re using, but I’m guessing it’s the equivalent of an ESP-01 connected via serial to your Uno, acting as a Wi-Fi modem.
If that’s the case then you have a problem, because the UNO has only one serial UART and you’re using that for your serial debug messages.
The normal solution would be to use softwareserial to emulate a second serial port and use this for communication with your Wi-Fi shield. You may have some jumpers available on your shield to allow this, but as I said, I’m not familiar with your hardware and I’d guess that there are dozens of similar shields out there - all of which will work slightly differently.

You’d be better using one of the simple sketches in the Sketch Builder:
to get a basic sketch running first, then take it from there.



Thanks Pete.

  1. ok. done - sorry :slight_smile:
  2. I’m using this: WiFi shield, and I used the simple sketch generator for the code.

Any suggestions?


Okay, so it’s an SPI communication protocol rather than serial.

Use the simple Blynk blink code to get things working, rather than including all that LCD and Servo stuff.



Thanks mate…

Still, same results:
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
//_, /////_
__/ v0.5.4 on Arduino Uno

[10122] Connecting to
[21166] Connecting to
[31168] Connecting to
[41170] Connecting to


Try adding #define BLYNK_DEBUG as the very first line of your code and seeing what that gives in your serial monitor.

If you decide to post the results then use backticks at top and bottom again.



This is the results I’m getting:

[2023] WiFi firmware: 1.0.0
[2024] Connecting to 123
[12025] IP: my IP
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.4 on Arduino Uno

[12147] Connecting to
[23192] Connecting to
[33195] Connecting to
[43197] Connecting to
[53199] Connecting to
[63201] Connecting to
[73203] Connecting to
[83205] Connecting to
[93207] Connecting to


Doesn’t look like full Blynk debug output to me.

Are you sure you added #define BLYNK_DEBUG as the very first line of your code?



Yes. Do I need to leave the: #define BLYNK_PRINT Serial under this line?


OK. I see it’s necessary…
Maybe it has something to do with one of the libraries?
I had some trouble with downloading the <BlynkSimpleWifi.h> folder. It didn’t work with the last git file I downloaded, I needed to look for an older version.


Yes, that’s fine.



You could try re-installing, but I think you’d get compile errors if it wasn’t installed. You could try using verbose messages in Arduino IDE preferences and make sure that if you’re getting messages saying that multiple libraries were found that the one which is being used is the correct one.



Thanks a lot for your help!
I tried to use ESP8266 instead of using the WiFi Shield and it worked!
Maybe it has something to do with the WiFi Shield firmware.

Now I need to learn how to control the Servo using the Timer widget in the app and I’m done.

Thanks again :slight_smile:


That is the 2nd time recently I have seen this referenced attempt… :thinking:

Well a bit of advice from that other topic… the Timer Widget only outputs a 0 or 1, so look at using the timer in the Eventor, or better yet, just use the timer to call a function that runs the desired servo commands accordingly.

Feel free to create a new topic with details if you require further suggestions.