ESP8266 HTTP Request Exception

Hello,

I am using the NodeMCU v3 (ESP 8266) and the Arduino libraries to program it.

I am attempting to make a HTTP request to my Hue light bridge to get the status of my lights however I get the following exception:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x4020f27c epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000030d depc=0x00000000

I assume this is because for some reason the HTTP request returns an empty body! This makes no sense as I can make the HTTP call to the same endpoint on my laptop and it works fine, and also I can make http calls to other websites via the ESP and they work fine.

My code is as follows:

bool HueManager::light_status(String ip, String id){

  • HTTPClient http;*

  • String url = "http://" + ip + "/api/" + bridgeAPIKey + "/lights/" + id;*

  • http.begin(url);*

  • int httpCode = http.GET();*

  • Serial.println(httpCode);*

  • String payload = http.getString();*

  • Serial.println(payload);*

  • http.end();*

  • delay(1000);*

  • return true;*

}

The response from the API looks a little like this:

{

  • "state": {*
  • "on": true,*
  • "bri": 254,*
  • "hue": 8402,*
  • "sat": 140,*
  • "effect": "none",*
  • "xy": [*
  • 0.4575,*
  • 0.4099*
  • ],*
  • "ct": 366,*
  • "alert": "none",*
  • "colormode": "xy",*
  • "mode": "homeautomation",*
  • "reachable": true*
  • },*
  • "swupdate": {*
  • "state": "noupdates",*
  • "lastinstall": "2020-12-07T14:25:15"*
  • },*
  • "type": "Extended color light",*
  • "name": "Office light",*
  • "modelid": "LCT010",*
  • "manufacturername": "Signify Netherlands B.V.",*
  • "productname": "Hue color lamp",*
  • "capabilities": {*
  • "certified": true,*
  • "control": {*
  • "mindimlevel": 1000,*
  • "maxlumen": 806,*
  • "colorgamuttype": "C",*
  • "colorgamut": [*
  • [*
  • 0.6915,*
  • 0.3083*
  • ],*
  • [*
  • 0.17,*
  • 0.7*
  • ],*
  • [*
  • 0.1532,*
  • 0.0475*
  • ]*
  • ],*
  • "ct": {*
  • "min": 153,*
  • "max": 500*
  • }*
  • },*
  • "streaming": {*
  • "renderer": true,*
  • "proxy": true*
  • }*
  • },*
  • "config": {*
  • "archetype": "sultanbulb",*
  • "function": "mixed",*
  • "direction": "omnidirectional",*
  • "startup": {*
  • "mode": "custom",*
  • "configured": true,*
  • "customsettings": {*
  • "bri": 254,*
  • "xy": [*
  • 0.4575,*
  • 0.4099*
  • ]*
  • }*
  • }*
  • },*
  • "uniqueid": "00:17:88:01:a8-0b",*
  • "swversion": "1.50.2_r30933",*
  • "swconfigid": "292E579A",*
  • "productid": "Philips-LCT010-1-A19ECLv4"*
    }

What am I missing?

Exception 9 is a memory alignment exception - the CPU attempted to read from mis-aligned data. For example, it tried to read a 32-bit value from an address with BOTH LSBs == 0.

What am I missing?

Well, aside from a whole lot of your code....

Use the ESP Exception decoder to see WHERE the access is being made. That should give you a clue what is wrong. Odds are, you're passing a bogus pointer somewhere.

RayLivingston:
Exception 9 is a memory alignment exception - the CPU attempted to read from mis-aligned data. For example, it tried to read a 32-bit value from an address with BOTH LSBs == 0.

Well, aside from a whole lot of your code....

Use the ESP Exception decoder to see WHERE the access is being made. That should give you a clue what is wrong. Odds are, you're passing a bogus pointer somewhere.

Appreciate the reply, however, I included all the code where the HTTP request is made!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.