My Wifi-Shield wont connenct to the Internet?

Hey I bought the following: Wifi-Shield but it wont connect to the Internet?

Only the WiFi Shield Sketch works to upload the WiFi Shield 101 Sketch is to big to upload and on the Arduino ESP8266 WiFi Sketch it says: exit Status 1 “Serial1” was not declared it this scope

I have the WiFi Shield on top of my Arduino and the Arduion is plugged in with USB…

Of corse i changed the WiFi SSID and Password to my own but it still does not work…

Someone can help me?

(Sry for the English i am German…)

Hi @CommanderKSK,

Can you post the code you’re using?
Also, can you share screenshots or copy/paste the errors you’re seeing?


The complete Error Message is to long and reaches the limit here to post… ^^


Uno has no Serial1, only Serial.

This is the sketch you need:

This sketch connects to the Cayenne server using an ESP8266 WiFi module as a shield connected via a hardware serial to an Arduino.
The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
1. Install the library via the Arduino IDE (Sketch->Include Library->Add .ZIP Library) from the Cayenne extras/libraries
   folder (e.g. My Documents\Arduino\libraries\CayenneMQTT\extras\libraries) to compile this example.
2. Connect the ESP8266 as a shield to your Arduino. This example uses the Serial1 hardware serial pins available on the Mega. You can also try 
   using a software serial, though it may be less stable.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
NOTE: This code requires ESP8266 firmware version 1.0.0 (AT v0.22) or later.

//#define CAYENNE_DEBUG       // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Uno only has the one serial port, so... NO DEBUG FOR YOU
#include <CayenneMQTTESP8266Shield.h>

// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "wifiPassword";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

// Set ESP8266 Serial object. Uno only has the one serial port
#define EspSerial Serial

ESP8266 wifi(&EspSerial);

void setup()

	// Set ESP8266 baud rate

	Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);

void loop()

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
	// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
	Cayenne.virtualWrite(0, millis());
	// Some examples of other functions you can use to send data.
	//Cayenne.celsiusWrite(1, 22.0);
	//Cayenne.luxWrite(2, 700);
	//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
	CAYENNE_LOG("Channel %u, value %s",, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");

You can use the software serial library if you really really need debug later.



For software serial debug printing, you can add this, and connect the defined pins to an external USB to Serial port adapter.

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(7, 8); // RX, TX
#define CAYENNE_PRINT DebugSerial  // Comment this out to disable prints and save space


Ok thx @kreggly
The Code works to upload but it still dont connect to the internet and when i choose Tools->Serial Monitor i get something back it is not good but better as bevor ^^
I get “⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮” back from 9600
and “AT” from 115200

i paste in my ssid,password,clientID,clientpw,clientuser so normaly it is right or?

When i plug in the power suply the WiFi LED is flashing for like a third of a second an then the LED is off if this info will help?

Of course you get AT. Serial port is used for ESP communication.

If you still have the PC connected to it, you may be interfering with ESP comms. Might want to try powering the Uno externally without the USB connection.


Already tryed but same result it does not connect to the wifi…

Do you have AT firmware in your ESP?

I dont know what you mean?
I installed all librarys i think

@kreggly ok wait i followed this guide to flash the shield itself to see if it works: Guide

Now the Shield without the Arduino is connected to the WiFi.

But i dont think it works this way with cayenne?..

I also have the same problem using the ESP8266 Nodemcu with arduino Mega. The shield works perfectly because I can load simple codes directly to the shield and from the serial monitor it responds but when I try the above sketch it doesn’t even compile continuous error as below;

C:\Users\HP\Documents\Arduino\libraries\Cayenne-MQTT-Arduino-master\src/CayenneMQTTESP8266Shield.h:36:2: error: #error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting.

_ #error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting._

_ ^_

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Can someone help me with this error?


I can compile it (to the Arduino) but when the shield is on top of the Arduino you have to select the Arduino as Microcontroller and not the NodeMCU 1.0 (ESP-12E Module) :slight_smile:

It works to compile but the shield don’t connect to the WiFi…

I think something is missing or the shield isn’t “talking” properly with the Arduino…
I have absolutely no clue

Node MCU firmware is not compatible with the ESP Shield Library. If you want to use the shield here, you need to reprogram it with an AT compatible firmware.

You can follow steps 7-13 from this link with your serial dongle. Pay particular attention to step 7. I want to see your best dance moves.



Oh nice thx i will try it out and post here if i was successful :slight_smile:

@kreggly no way out using my adafruit board i now have the following error anyway to solve this?

C:\Users\HP\Documents\Arduino\libraries\ESP8266SerialLibrary\ESP8266.cpp:22:26: fatal error: avr/pgmspace.h: No such file or directory

_ #include <avr/pgmspace.h>_

_ ^_

compilation terminated.

exit status 1
Error compiling for board Adafruit HUZZAH ESP8266.

thanks for any help on this


If you have an Adafruit Huzzah, then this is not the sketch you’re looking for. <>Place Star Wars meme here<>

The library you are referencing in this sketch only applies to AVR boards like the Uno or Mega.

You need this one:

Cayenne-MQTT-Arduino/ESP8266.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub



@njueric follow this Adding a New Device using MQTT

…or that :stuck_out_tongue:

WOW @kreggly you are truly the best!!!

I flashed the AT-Firmware with the guide you postet and uploadet the sketch to my Arduino you postet bevor and it works!
My Arduino is connected to the WiFi and i see the temporary widget in the Dashboard.

THX! :smile: :blush: