WifiShield with arduino uno compiling error

If you are using the ESP8266 as a Wifi shield with the AT command set installed on the ESP, and the Uno as the host, then this will not work.

@adam is talking about overwriting the flash in the ESP module itself so you don’t even need an Uno.

Connect your Uno serial port RX to TX and TX to RX on the ESP. Note that the ESP pins are 5V tolerant, but if you want to be nice, put a 1K resistor inline between the Uno TX and the ESP RX. Also note that the ESP supply must be 3.3V. If you put 5V there, it will get hot.

You need this code if using the ESP as a shield (unreleased code):

/*
Cayenne ESP8266 Shield WiFi Example
Adapted from Blynk's ESP8266_Shield_HardSer Example

This sketch connects to the Cayenne server using an ESP8266 WiFi module as a shield connected
via a hardware serial to an Arduino.

You should install the ESP8266HardwareSerial.zip library via the Arduino IDE (Sketch->Include Library->Add .ZIP Library)
from the Cayenne extras/libraries folder (e.g. My Documents\Arduino\libraries\Cayenne\extras\libraries) to compile this example.

NOTE: Ensure a stable serial connection to ESP8266!
      Firmware version 1.0.0 (AT v0.22) or later is needed.
      You can change ESP baud rate. Connect to AT console and call:
          AT+UART_DEF=115200,8,1,0,0

For Cayenne Dashboard widgets using digital or analog pins this sketch will automatically
send data on those pins to the Cayenne server. If the widgets use Virtual Channels, data
should be sent to those channels using virtualWrites. Examples for sending and receiving
Virtual Channel data are under the Basics folder.
*/

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneESP8266Shield.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "AuthenticationToken";
// Your network name and password.
char ssid[] = "NetworkSSID";
char password[] = "NetworkPassword";

// Set ESP8266 Serial object
#define EspSerial Serial1
ESP8266 wifi(EspSerial);

void setup()
{
	Serial.begin(9600);
	delay(10);
	// Set ESP8266 baud rate

	EspSerial.begin(115200);
	delay(10);

	Cayenne.begin(token, wifi, ssid, password);
}

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

This code relies on your Arduino device having a second serial port. You will need to install the attached CayenneESP8266Shield.log to your Cayenne library directory and rename it with a .h extension. Also, don’t forget to install the ESP8266HardwareSerial library (rename attached as .zip)

I am working on kludging a way to use the SoftwareSerial library as well, but haven’t got around to it yet.

CayenneESP8266Shield.log (1.8 KB)

ESP8266HardwareSerial.log (11.3 KB)

Cheers,

Craig

2 Likes