WifiShield with arduino uno compiling error


#21

Hmmmm, this is a new one to me. I think it is because it is not actually an ESP8266, thus the libraries aren’t recognizing it correctly and trying to do AVR things that aren’t compatible as the ESPs are not AVR based.

You could try removing the ESP8266 board from the boards manager, and use the additional boards json from the following link to install perhaps an updated version that includes this board. https://www.tindie.com/products/doit/espduinowifi-arduino-uno-r3/

UPDATE: I looked at the link and yes, they replaced the Generic ESP8266 Module in the file with the ESPDuino. I don’t recommend doing the above as they are using an old version. Just try setting it to Generic ESP module and see if it compiles for you.

@bestes, does anyone at “home office” have one of these boards?

Cheers,

Craig


#22

Hello Kreggly!

I´m trying to do your example.
I use a Arduino UNO + ESP8266-01.
I done exactly what you said, but I have some issue with the serial between UNO and the ESP.
With the code you post, I will have the error: “‘Serial1’ was not declared in this scope”

//#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[] = "*****";
// Your network name and password.
char ssid[] = "*****";
char password[] = "*****";

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

void setup()
{ .......

I also install the library ESP8266HardwareSerial.zip like you said, I got 3 files “ESP8266.cpp”, “ESP8266_HardSer.h” and the “README.md”. But I´m not sure how I should use it… maybe I miss some detail!
Where I define the rx and tx pins to serial between UNO + ESP?

Thanks a lot!
AS


#23

Hi @andreijrs,

You don’t have a separate serial port on the UNO, so you need to disable the debug port and use Serial to connect to the ESP shield. You don’t need to define pins as it is knows them already. They are the ones labelled RX and TX on the board. Just note when programming that you disconnect the ESP from the UNO so there are no confilcts, then reconnect after programming.

You can try adding a second serial port with the software serial library if you want to keep debug, but note that the UNO doesn’t have much program space if you plan on adding more user code.

See here:

/*
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[] = "";
char ssid[] = "";
char password[] = "";


// Set ESP8266 Serial object
#define EspSerial Serial
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();
}

Cheers,

Craig


ESP8266 Wifi + 1 Relay Configuration
#24

Hi @kreggly!
Thanks for your help.
At this moment I want a second serial port for debug, my code is something like:

#include <CayenneESP8266Shield.h>

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

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(7, 8); // RX, TX

// Set ESP8266 Serial object
ESP8266 wifi(EspSerial);

void setup() {...

Why I still have an error here?!

ESP8266 wifi(EspSerial);

“no matching function for call to ‘ESP8266::ESP8266(SoftwareSerial&)’”

Can you please help?

Thanks you!


#25

@andreijrs,

Looks like the ESP8266 library has no handler for SoftwareSerial.

Craig


#26

hi @adam @kreggly
i had gone through all above discussion but trying for espharware serial
"Zip doesn’t contain a library" is generated by ardino ide
link may have been broken or file corrupted as it seems like


#27

@HamnaBazmi,

The file I attached is a zip file renamed a log file so it can be attached.Restore the extention to .zip, unzip it and copy the folder to your Arduino libraries directory.

@andreijrs,

Did you get this working for you?

If you want debug, maybe try this. Compiles fine for me:

/*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
#include <CayenneESP8266Shield.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "";
char ssid[] = "";
char password[] = "";

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

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

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

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

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

ESP8266 Wifi + 1 Relay Configuration
ESP8266 Wifi + 1 Relay Configuration
#28

Thnx will get u back soon


#29

Thanks @kreggly!
I will try it soon, and tell, if or how, it works with me.


#30

Hi @andreijrs
Will wait for you
Come back ASAP☺


#31

@kreggly

i am having problem with the rename of above file…
when i rename the above file, then also the file type is not changing i.e file type .h and .zip…it only showing text file after renaming also…

so whenever i want to attach .zip library file from ardunio, computer not able to recognise the renamed file…because its extension is still as text document even after changing to .h and .zip…

pls help


#32

Hopefully soon we will have these files in the library so you won’t have to do this.

If you are on Windows, I think the issue you are facing is that you need to set your view settings in your file explorer to show extensions. Then you can actually chamge the extension.

I am mobile right now, but Google is your friend too.

Cheers,

Craig


#34

@kreggly
successfully compiled your code…


#35

Hi @vin3yasukhadeve

Squeeeeeeeeee!!!

Great news.

Although code is free to everyone. I am not the owner, only the encourager :slight_smile:

Cheers,

Craig


#37

@kreggly
Got connected to cayenne using ESP8266…

GREAT SUCCESS FOR ME…

please give one suggestion…
in our college cyberoam login is there…we have given separate id to use internet services.after connected to the wifi, login page is appear, in which we have to fill login info to acess the internet…

firstly, i connected to my college wifi.it got connected but i am not able to access internet because of login problem(i dnt know how to enter login details after connecting esp8266 to arduino)…

then
i tried by using mobile internet…got succeed…

please help me to connect using college cyberroam network


#38

Sorry @vin3yasukhadeve,

That is a very specific thing that is really beyond the scope of what Cayenne does.

However, if we could find a generic method, it would be exciting to have this functionality.

Honestly though, it’s probably pretty tough to do as your ESP would have to be able to work with SSL certificates in order to submit your login information.

Cheers,

Craig


#40

Hi @vin3yasukhadeve,

Are the analog reads good?

I could see an issue with the DHT read as I believe this sensor takes as much as 2 seconds to return with valid data.

Check here for how to error check your return values:

Cheers,

Craig


#41

hi,
after uploading the code the device does not get connected to the dashboard .
the serial monitor output:
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE


#42

Hi Craig,

I’m using Arduino Uno with ESP-01, I have compiled your program without error.
Unfortunately, I cannot see my device connected to Wifi Router.

I’m sure my ESP-01 is ok, because when I use the code: AT+CWJAP=“MyRouter”,“Password” it says:
WIFI CONNECTED
WIFI GOT IP

I have tried to connect ESP-01 first to the wifi, upload your sketch without error but the device didn’t connect to cayenne.
I have tried to remove connection with AT+CWJAP=" “,” " disconnect the wifi with AT+CWQAP, upload your sketch again, but no luck.
Is there any prerequisite required with AT Command to the ESP-01 before I upload the sketch?

@vin3yasukhadeve can you help me by paste your successful scripts here? I just want to double check if I was missing something. Thanks.


#43

@willy,

Have you connected any of your devices to Cayenne yet on your wifi network?

If not, try this to confirm your router isn’t blocking the outbound port.

Cheers,

Craig