Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By probono
#22444 This sketch emulates a Philips Hue bridge running on an ESP8266. Right now this is a proof-of-concept. Hue client apps can discover the emulated bridge and begin talking to it using the Hue protocol.

https://github.com/probonopd/ESP8266HueEmulator

Please note that currently only the bare minimum to advertise the emulated Hue bridge is implemented, but it is enough so that the http://chromaforhue.com OS X app can discover and communicate with the emulated bridge.

Contributions welcome!
User avatar
By DaniloFix
#25343 That's great news - I really hope this will evolve!

You think it would be possible to emulate a Hue light as well as the bridge? So that we could use the Hue interface to switch our own custom lights? That would be awesome :-)
User avatar
By AceOne
#32800 This seems like a brilliant project!

I tried this for my first ever ESP8266 test drive, and although I got pretty far, I am stuck trying to connect the client app. I have tried a bunch in the android play store none of which worked, and have even tried the Chroma OSX app with no joy. When Chroma tries to connect I get this repeated on serial monitor:

[code
]===
277930
requestedUri: /api/136IS5cwW9yG3yib
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
277953
{"groups":{},"scenes":{},"config":{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:DA:BD:4C","dhcp":true,"ipaddress":"192.168.2.109","netmask":"255.255.255.0","gateway":"192.168.2.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}},"lights":{"1":{"type":"Extended color light","name":"Hue LightStrips 1","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"2":{"type":"Extended color light","name":"Hue LightStrips 2","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"3":{"type":"Extended color light","name":"Hue LightStrips 3","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"4":{"type":"Extended color light","name":"Hue LightStrips 4","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"5":{"type":"Extended color light","name":"Hue LightStrips 5","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"6":{"type":"Extended color light","name":"Hue LightStrips 6","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"7":{"type":"Extended color light","name":"Hue LightStrips 7","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"8":{"type":"Extended
278152
[/code]

I can also ping the module (and it stops responding to pings for a handful of seconds when reset). So clearly I have it on the net and the clients are triggering some kind of response. If I close the Chroma app, the serial monitor goes silent.

Can you give a hint as how to connect the client and control some lights? Thanks!
User avatar
By andrew melvin
#32871 I took this work a little further, and made a lib out of it. that allows max of 255 lights, and 255 groups.. although i'd not recommend more than 16 groups as per the spec.

see here
https://github.com/sticilface/Esp8266-Hue

it works ok for some stuff... but the big issue at the moment is the fast speed at which a lot of clients send packets to the ESP. it is just not able to cope with such a high packet load. so animations are out. this works with the chroma app for mac fairly well.

The colour conversions are also way out.. some better way of converting between the hue, xy, of the huelight and rgb, hsl of neopixels is needed.