My Wifi-Shield wont connenct to the Internet?

Ahem. I believe step 7 requires I see some dance moves… LOL.

Cheers,

Craig

1 Like

@kreggly thanks for the advice, I succeeded actually in using the sketch you posted above. I wasn’t actually clear with my error; the problem I’m facing is connecting my arduino mega to cayenne using the adafruit or nodemcu shields. Both shields give an error, the same error avr.
Is there any other way to connect the arduino mega to cayenne using the shield? Any guides?
Thanks in advance for your generous help. I’ve been googling all day.

@shramik_salgaonkar thanks, already used this and it doesn’t even compile, stops at avr error, may it’s only me. The problem is that it doesn’t even compile not to mention loading, there should be something that I’m missing, I’ve installed all possible libraries. A little bit frustrated :disappointed: I’ve to move my board to a position that I need only wifi no lan.

select arduino mega board in tools > boards > arduino mega.
connect your esp to serial 1 pins on your mega.
follow step 1 in properly in Cayenne-MQTT-Arduino/ESP8266Shield.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub

@njueric,

Ok, so compiling and programming the Mega with the ESPShield sketch is successful? And you are having problems programming the shields, correct? And your intention is to use the ESP as a shield on the Mega?

What are you programming the ESPs with? Note that you need to program the shields with an AT command firmware. That might be the issue.

Cheers,

Craig

@kreggly hi once more, below you’ll find the results of what i have trying to compile ESP8266 in Arduino IDE.

Arduino Compile example ESP8266
_Archiving built core (caching) in: C:\Users\HP\AppData\Local\Temp\arduino_cache_179205\core_
core_esp8266_esp8266_huzzah_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M1M_23389078ed712a9cdacb703d60a0f757.a
Sketch uses 276011 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 35420 bytes (43%) of dynamic memory, leaving 46500 bytes for local variables. Maximum is 81920 bytes.

Arduino Compile example ESP8266Shield
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.

Hope it’s clear now. My main problem is that i can’t compile the above example in the Arduino IDE.

exit status 1
Error compiling for board Adafruit HUZZAH ESP8266.

The ESPShield sketch is for an AVR series board like the Uno or the Mega. You cannot put it in a Huzzah which is an ESP.

If you are intending to put this in a Mega, select the Mega board from the drop down boards menu and recompile.

Craig

@kreggly you’ve been so helpful, finally i got the code loaded to the arduino mega and the code esp8266 also loaded to the shield and finally it connected to cayenne and i can add widgets to the cayenne dashboard. it was so nice as the widgets were responding on/off in cayenne dashboard.
The nice part of the story is this, i tried to connect some leds on the arduino on channel 24 and 26 but no connection, the arduino mega seems not to be responding. i connected tx/rx from the shield to the arduino rx/tx and even inverted the tx/rx but nothing.
Any idea of what i’m doing wrong?

1 Like

you have to connect it the shield rx/tx to tx1/rx1 of the mega.

if you did this how were you able to connect with cayenne?

can you post the code.

@shramik_salgaonkar , Hi sorryy for the late reply due to daily job. here’s the code i used;

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

// WiFi network info.
char ssid[] = “xx”;
char wifiPassword[] = “xx”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = “xx”;
char password[] = “xx”;
char clientID[] = “xx”;

// Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega.
#define EspSerial Serial1

ESP8266 wifi(&EspSerial);

void setup()
{
_ Serial.begin(9600);_
_ delay(10);_

_ // Set ESP8266 baud rate_
_ EspSerial.begin(115200);_
_ delay(10);_

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

void loop()
{
_ Cayenne.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.
CAYENNE_OUT_DEFAULT()
{
_ // 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_IN_DEFAULT()
{
_ CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());_
_ //Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);_
}

are you able to connect the device to cayenne? where is the code for led?

@shramik_salgaonkar ,
Hi, I’m able to connect to cayenne and create widgets like led, and giving a trial on screen on/off works, but from here the corresponding channel doesn’t work on my esp8266 nor arduino mega.
I used the drag and drop method for the widgets not by code. Is this where my error is?

yes when you add a button widget on cayenne dashboard you need to add a few lines of codes to read it.
example: you add a button widget to turn on/off led with channel 1, then you need to add this code below your code.

CAYENNE_IN(1)
{
  int x = getValue.asInt();
digitalWrite(5, x);
)

where x stores the value of the button and turns on/off led connected to pin 5 of arduino.

@shramik_salgaonkar hi, is there any complete code where i can find some buttons and temperature already in the code. i’m not a coder that’s why i seek for drag and drop platforms

Adding a New Device using MQTT have a look at step 4 and 5 for adding sensor and actuator. this will give an outline of how cayenne works.
for temperature code if you are using a DTH11/22 sensor DHT11/DHT22 - temperature and humidity sensor