Need help connecting to Cayenne with ESP8266


#1

Hi I am using arduino uno and a generic 8 pin esp8266 (AI cloud inside) and the web dashboard
I am pretty sure I have prepared the 8266 correctly When the esp8266 is connected to the usb uart and I select generic 8266 under boards and select the appropriate port I get this message at the bottom of the ide


should it say none on com11?

I have just used the standard manual connection code, only changing the authority token, I am not sure if I should change anything else

after uploading I get this in the serial mon

on the dashboard it just sits waiting for the board to connect.

I think I can see the esp on my router, at the bottom

any help or advice would be great thanks


#2

If I remember correctly, the None on COM11 should be fine. Maybe just double check to see that the UART device is on COM11, but if the sketch is uploading to the ESP then you have nothing to worry about.

The connection type is where your issue is. See this post for a walk through on setting up the ESP.

It’s interesting that your router shows the ESP, but that could just be an old DHCP lease from a previous connection you made.


#3

When the esp8266 is connected to the usb uart and I select generic 8266 under boards and select the appropriate port I get this message at the bottom of the ide

what are you trying to upload in Arduino IDE regarding the ESP? You need a separate program to flash the AT instruction firmware not the Arduino IDE.

Also, your sketch looks like its using Ethernet as a connection method. This won’t work with the ESP.

Here is another post with steps how to setup the Uno and ESP8266 in addition to the link @adam provided.

Good luck & let us know how it goes. :slight_smile:


#4

I should also add that there is official support for ESP8266 boards now. Just select it as a device when adding a new device and follow directions on the screen.


#5

Hi I have succeeded in getting an uno connected to cayenne via seriel usb so that at least is a step in the right direction although I think I am on the wrong path. So I will explain what I am trying to do


images
the components are
nano
3 x pir
3 x IR transmitter diodes
1 x smoke flamable gas detector
1 x esp8266 AI inside
3 x power supply
1 x wifi 240v power relay
There are three parts to my project.
1 Smoke gas detection - smoke detector switches on periodically(save power/reduce heat) and test for smoke gas
2 PIR detects movement and switches on 240v wifi relay
3 I want to get rid of all my IR remote and do it from my phone. I will need the IR codes for my tv air con dvd etc. I have seen a project that does this, but I am unsure if the codes should be in the arduino sketch if cayenne can do that (I suspect that would be better arduino memory wise).

So which of the connection options to cayenne should I be using and will I be able to connect the 240v Wifi relay to Cayenne?
Any thoughts would be appreciated


#6

Be carefull, i see 1M(512k SPIFFS) if you use an ESP8266-01 (8 pins) you must configure your “Arduino tools” like this :

Flash size 512k(128k spiffs)

try this :wink:


#7

you still wanna be using the Arduino option in the “Add New” page. Here is a blank example sketch so you can see the setup on the software side. Your tx/rx of your esp will connect to the rx/tx of your nano and you need CH_PD (or EN on some chips) & 3.3v pins to be powered to a 3.3v power source, not 5v. Ground goes to ground obviously. You shouldn’t need to use anymore pins of the esp.

Follow the link above on how to install the AT firmware onto your esp. Thats the tricky part of the setup. However once you get the firmware on there you won’t need to mess with it again.

The “esp8266” option in the “Add New” page if for if you didn’t have a nano as your main controller and run everything right on the esp. This is easier but sounds like you need more pins than the ESP8266-01 has. If you looking to simplify you setup a little, get rid of the nano completely and use a WeMos D1 Mini or ESP8266 Thing from Sparkfun (esp8266-12 chips) for example and run your sketch directly on the D1 mini. You will also have better connectivity to Cayenne too this way.

#include <Arduino.h>
#include <CayenneESP8266Shield.h>

//#define CAYENNE_DEBUG SerialUSB        // Uncomment to show debug messages
//#define CAYENNE_PRINT SerialUSB  // you need software serial to use these

char token[] = "token";
char ssid[] = "wifi";
char password[] = "password";

#define EspSerial Serial   //port on which your ESP8266 is connected, on the nano, its Serial.
ESP8266 wifi(EspSerial);


void setup()
{
	EspSerial.begin(9600);  //baud rate of your esp
	delay(10);

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

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



CAYENNE_OUT(V25)  //monitor system uptime
{
	float time1 = (mills() / 1000) / 60;
	Cayenne.virtualWrite(V24, time1);
}

#8

I get an error compiling, I have both the cayenne and the cayenne mqtt libraries installed
Arduino: 1.8.4 (Windows 10), Board: “Arduino Nano, ATmega328”

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Jonathan\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Jonathan\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Jonathan\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10804 -build-path C:\Users\Jonathan\AppData\Local\Temp\arduino_build_320082 -warnings=none -build-cache C:\Users\Jonathan\AppData\Local\Temp\arduino_cache_909112 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2 -prefs=runtime.tools.avr-gcc.path=C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2 -verbose C:\Users\Jonathan\Documents\Arduino\cayespnano\cayespnano.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Jonathan\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Jonathan\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Jonathan\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10804 -build-path C:\Users\Jonathan\AppData\Local\Temp\arduino_build_320082 -warnings=none -build-cache C:\Users\Jonathan\AppData\Local\Temp\arduino_cache_909112 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2 -prefs=runtime.tools.avr-gcc.path=C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2 -verbose C:\Users\Jonathan\Documents\Arduino\cayespnano\cayespnano.ino
Using board ‘nano’ from platform in folder: C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12
Using core ‘arduino’ from platform in folder: C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12
WARNING: Category ‘’ in library UIPEthernet is not valid. Setting to 'Uncategorized’
Build options changed, rebuilding all
Detecting libraries used…
“C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10804 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\cores\arduino” “-IC:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\variants\eightanaloginputs” “C:\Users\Jonathan\AppData\Local\Temp\arduino_build_320082\sketch\cayespnano.ino.cpp” -o “nul”
“C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10804 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\cores\arduino” “-IC:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\variants\eightanaloginputs” “C:\Users\Jonathan\AppData\Local\Temp\arduino_build_320082\sketch\cayespnano.ino.cpp” -o "C:\Users\Jonathan\AppData\Local\Temp\arduino_build_320082\preproc\ctags_target_for_gcc_minus_e.cpp"
C:\Users\Jonathan\Documents\Arduino\cayespnano\cayespnano.ino:2:34: fatal error: CayenneESP8266Shield.h: No such file or directory

#include <CayenneESP8266Shield.h>

                              ^

compilation terminated.

exit status 1
Error compiling for board Arduino Nano.

this is my code

#include <Arduino.h>
#include <CayenneESP8266Shield.h>

//#define CAYENNE_DEBUG SerialUSB // Uncomment to show debug messages
//#define CAYENNE_PRINT SerialUSB // you need software serial to use these

char token[] = “0rdc15hylt”;
char ssid[] = “netgear06”;
char password[] = “tinyrosebud251”;

#define EspSerial Serial //port on which your ESP8266 is connected, on the nano, its Serial.
ESP8266 wifi(EspSerial);

void setup()
{
EspSerial.begin(9600); //baud rate of your esp
delay(10);

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

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

CAYENNE_OUT(V25) //monitor system uptime
{
float time1 = (mills() / 1000) / 60;
Cayenne.virtualWrite(V24, time1);
}


#9

Also I am using cayenne library 1.02 and I cant see cayenneESP8266Shield.h should I be using CayenneESP8266Wif.h?


#10

It’s a separate library. Let me see if I can find a link.


#11

Install this cayenne library and hardware serial library and it should work. Both are zip files.