Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to solve this problem... its occurred in connect() function when connecting to adafruite cloud. #3

Open
vikasdhote3 opened this issue Nov 6, 2016 · 2 comments

Comments

@vikasdhote3
Copy link

//showing in serial terminal//
Adafruit IO Example
Connecting to Khush
.......
WiFi connected
IP address:
192.168.1.3
Connecting to Adafruit IO...
Exception (3):
epc1=0x4000bee5 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40230347 depc=0x00000000

ctx: cont
sp: 3ffef3b0 end: 3ffef5f0 offset: 01a0

stack>>>
3ffef550: 34313032 00000001 3ffe866d 40203d08
3ffef560: 40105072 3ffee3b8 3ffee3b8 40202e7a
3ffef570: 402302b4 0000000b 3ffee594 402032b5
3ffef580: 3ffe866c 0000001c 4023028c 3ffee5c0
3ffef590: 402302b4 3ffee3b8 3ffee594 40201cfc
3ffef5a0: 0301a8c0 00ffffff 0101a8c0 3ffee5c0
3ffef5b0: 402302b4 3ffee4a4 3ffee594 40201df2
3ffef5c0: 3ffe8668 0301a8c0 feefeffe feefeffe
3ffef5d0: 3fffdad0 00000000 3ffee5b8 402037b0
3ffef5e0: feefeffe feefeffe 3ffee5d0 40100718
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
////////////////////////////////////////////////
// programme is////
/***************************************************
Adafruit ESP8266 Lamp Controller Module

Must use ESP8266 Arduino from:
https://github.com/esp8266/Arduino
Works great with Adafruit's Huzzah ESP board:
----> https://www.adafruit.com/product/2471
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Tony DiCola for Adafruit Industries.
Adafruit IO example additions by Todd Treece.
MIT license, all text above must be included in any redistribution
****************************************************/

// Libraries
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"

// Lamp pin
const int lamp_pin = 14;

// WiFi parameters
#define WLAN_SSID "Khush"
#define WLAN_PASS "HelloSid@2014"

// Adafruit IO
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883
#define AIO_USERNAME "VIKAS3"
#define AIO_KEY "5942c3f898904046ab8bfc49ab1a4dbf"

// Functions
void connect();

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;

// Store the MQTT server, client ID, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM = AIO_KEY DATE TIME;
const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM = AIO_KEY;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);

/****************************** Feeds ***************************************/

// Setup a feed called 'lamp' for subscribing to changes.
// Notice MQTT paths for AIO follow the form: /feeds/
const char LAMP_FEED[] PROGMEM = AIO_USERNAME "/feeds/lamp";
Adafruit_MQTT_Subscribe lamp = Adafruit_MQTT_Subscribe(&mqtt, LAMP_FEED);

/*************************** Sketch Code ************************************/

void setup() {

// Set lamp pin to output
pinMode(lamp_pin, OUTPUT);

Serial.begin(115200);

Serial.println(F("Adafruit IO Example"));

// Connect to WiFi access point.
Serial.println(); Serial.println();
delay(10);
Serial.print(F("Connecting to "));
Serial.println(WLAN_SSID);

WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(F("."));
}
Serial.println();

Serial.println(F("WiFi connected"));
Serial.println(F("IP address: "));
Serial.println(WiFi.localIP());

// listen for events on the lamp feed
mqtt.subscribe(&lamp);

// connect to adafruit io
connect();

}

void loop() {

Adafruit_MQTT_Subscribe *subscription;

// ping adafruit io a few times to make sure we remain connected
if(! mqtt.ping(3)) {
// reconnect to adafruit io
if(! mqtt.connected())
connect();
}

// this is our 'wait for incoming subscription packets' busy subloop
while (subscription = mqtt.readSubscription(1000)) {

// we only care about the lamp events
if (subscription == &lamp) {

  // convert mqtt ascii payload to int
  char *value = (char *)lamp.lastread;
  Serial.print(F("Received: "));
  Serial.println(value);

  // Apply message to lamp
  String message = String(value);
  message.trim();
  if (message == "ON") {digitalWrite(lamp_pin, HIGH);}
  if (message == "OFF") {digitalWrite(lamp_pin, LOW);}

}

}

}

// connect to adafruit io via MQTT
void connect() {

Serial.print(F("Connecting to Adafruit IO... "));

int8_t ret;

while ((ret = mqtt.connect()) != 0) {

switch (ret) {
  case 1: Serial.println(F("Wrong protocol")); break;
  case 2: Serial.println(F("ID rejected")); break;
  case 3: Serial.println(F("Server unavail")); break;
  case 4: Serial.println(F("Bad user/pass")); break;
  case 5: Serial.println(F("Not authed")); break;
  case 6: Serial.println(F("Failed to subscribe")); break;
  default: Serial.println(F("Connection failed")); break;
}

if(ret >= 0)
  mqtt.disconnect();

Serial.println(F("Retrying connection..."));
delay(5000);

}

Serial.println(F("Adafruit IO Connected!"));

}

@vikasdhote3 vikasdhote3 changed the title how to solve this problem... its occurred in connection() function when connecting to adafruite cloud. how to solve this problem... its occurred in connect() function when connecting to adafruite cloud. Nov 6, 2016
@mrvisual
Copy link

You need to remove all references to PROGMEM. Here is the replacement:

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
 
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
// Setup feeds for temperature & humidity
Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/temperature");

Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/humidity");

from Adafruit

-- Johannes

@Netopnu
Copy link

Netopnu commented May 12, 2017

Hi johannes,

The replacement you oploadet is for the "temperature" and "humidity" project!?

I'm new, could you pleace give me the code where the lines is changed?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants