more G-Labs products

Author Topic: ESP8266 Wifi sensor node success  (Read 6032 times)

June 09, 2015, 01:29:25 PM
Read 6032 times

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Just thought I would report a successful integration of an ESP8266 Wifi node to HG.  I am using the ~$10 Adafruit Huzzah version https://www.adafruit.com/product/2471    I installed Arduino bootloader to the ESP8266 following their instructions; this allows using the Arduino IDE/code/programming. 

It is running a tiny web server with two "webpages"; one html shows status for viewing on tablet browser in the house.  Second reports json data for easy parsing in HG.  Currently I have HG poll this json data every second and then RaiseEvent when something changes.

I have it in my garage, currently with a couple cheap door/window magnetic reed switches for the garage doors, and a DHT11 temperature humidity sensor.  Working great except the DHT11 humidity sensor is way off.

To do... maybe have the ESP8266 post to HG via a WebServiceCall so I don't have to poll every second.  Add more sensors to the ESP8266: motion detect, better humidity sensor, maybe another door switch to an outside fence gate, etc  :-) 


June 09, 2015, 08:47:07 PM
Reply #1

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Ok nice. And thanks to tell us.

It's a little bit like MySensor but more simple because :
  • Use of WiFi network instead of created new one (but wifi not very reliable..) => No gateway to add on HG
  • The ESP8266 integrate the network chip
Perhaps you can share too your script in that part of the forum :
http://www.homegenie.it/forum/index.php?board=3.0

June 10, 2015, 01:24:32 PM
Reply #2

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
I need to figure out how to report the ESP8266's wifi signal strength via the web server, but it seems to be working great in my garage which is opposite end of my house from router.  I'd like to clean up my script and make it a little more generic and implement without polling before I publish it.  The important part inside the polling loop is very simple:

Code: [Select]
  var json = Net.WebService(webserviceurl).GetData(); 
  int door1=json.door1;  //open=1   closed=0
  if(door1!=PrevDoor1)
  {
    Program.RaiseEvent(module1, "Sensor.DoorWindow", door1.ToString(), "Garage Door 1");
    PrevDoor1=door1;
  }

I am planning to buy more of these, great deal at $10 :-)  Oh, sparkfun has a similar product called "Thing", it is $16 (but also has builtin micro-usb connector and lipo charger). https://www.sparkfun.com/products/13231  I was about to buy the thing, when a comment on their site pointed me to the adafruit huzzah.


June 10, 2015, 04:55:03 PM
Reply #3

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Does this have to be plugged in or is the battery life "reasonable"?  The MySensor devices seem to have a 6 month up to 1 year life span on a set of batteries.  WiFi is relatively power hungry so I'm curious if battery power is even an option.

June 10, 2015, 06:20:34 PM
Reply #4

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
I was going to mention battery life as a drawback; I honestly don't know the specs but I am sure it is more than the NRF24 MySensor implementations.  I mainly like that is an all in one solution at great price.  I have my ESP8266 powered from a spare 5v AC/DC adapter.

If there were a commercial single board Arduino/NRF24 already out there, I probably would have ordered that a few weeks ago.  I know there are several user designed boards in the works, but they didn't seem ready for prime time.

June 11, 2015, 12:29:51 AM
Reply #5

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I am currently using an Uno + 3400 chip based superheterodyne 433MHz board + Ethernet shield + BMP180 (soon) for my setup to receive incoming 433 sensors.  But, I want to add a sensor on my water meter down the road, so I'm leaning towards an integrated solution for that.  My current best option is the Moteino with the high power chip.  Supposedly it has really good range and power consumption is pretty good too depending on your polling frequency presumably.

The big down side is that you have to develop your own protocol whereas WiFi is already ready to run.  If you have power available, the Huzzah is half the price and looks easier to use.

September 14, 2015, 01:21:52 PM
Reply #6

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Update:

I still have the Adafruit Huzzah ESP8266 in my garage.  It now has:
-2 magnetic reed sensors for garage doors - one problem eventually popped up with these and had to get the magnet closer to the sensor, seems to be working fine again.
-DHT22 temperature/humidty sensor - little more expensive than DHT11 but more accurate
-cheap motion sensor
-red LED on ESP8266 flashes when movement detected

To Do:
-some sort of box/enclosure and clean up wires
-another door sensor for outside fence gate

With some of the updates to the Arduino "firmware" and/or new libraries for DHT, I get some resets.  Originally it would run for weeks without resetting.  Now I get reset every day on average.

Another issue I have is the Analog to Digital Converter on the ESP8266, it only has one.  And, any time I try to do a simple analog read via Arduino API, it makes the ESP8266 reset very frequently.  So that is negative of this Adafruit Huzzah as compared to a real Arduino +Ethernet shield (or Arduino+ESP8266-01).
« Last Edit: September 14, 2015, 01:38:22 PM by kevin1 »

December 16, 2015, 04:02:46 PM
Reply #7

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Couple questions came up on ESP8266 so thought I would add some info here.  I used the Adafruit Huzzah ESP8266 variant.  They have a great step by step setup guide here:
https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide

It's been a while since I set mine up, but basically the Arduino IDE does it for you.  You have to add URL in settings for the board info and then it will load arduino "firmware" to the ESP8266.  Then you can load your sketch just like a regular Uno.  Only thing missing is ADC, there is one but it is limited voltage and caused mine to reset when I read a LDR/photoresistor.

December 16, 2015, 05:00:48 PM
Reply #8

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Do you (or anyone else) know the difference between the different models of ESP8266?  I see that Adafruit, Sparkfun, etc all have their own variant that aren't all that expensive but there's some on ebay from China that are as low as $2.00 w/ free shipping.  Is there something that I should be looking for to make sure these cheapo variants are actually usable?  My guess is that someone bought one from the other shops and cloned it.

EDIT: I did a little more looking and realized that the modules I found were just the ESP8266 module and not the ones with the Arduino hardware as well.  There are some similar looking modules on ebay but they don't save all that much (aside from shipping) and take much longer to get.  Also, compatibility is certainly not guaranteed since English isn't going to be the first language of the seller.
« Last Edit: December 16, 2015, 06:01:56 PM by bkenobi »

December 16, 2015, 07:00:31 PM
Reply #9

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
The $2 ones only have one GPIO pin I think and limited power supply methods, oh and they have an unfriendly pinouts if you want to breadboard it.  The Adafruit/SparkFun variants basically have a  ESP8266 module with more GPIO stuck on a board with more flexible power supply options, and breadboard friendly pinouts.

The arduino environment/firmware will run on the bare ESP8266 modules as well, adafruit & sparkfun don't really do anything to enable this feature (as far as I remember).

December 16, 2015, 11:01:27 PM
Reply #10

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
When you originally posted this thread, I thought it was a cool option that wouldn't work for me as I didn't want to build a web interface and have HG pull the data.  But now that I think about it having already installed MQTT for some other sensors, I realize that I don't have to use a web interface.  I can simply add the MQTT library and send pertinent info to the MQTT broker and let HG pull whatever data is needed that way.  Other than the fact that I'd have to come up with a proto board of some kind, this looks like a good solution for both my sensor hub as well as a possible replacement for the brains of my attic fan controller.

EDIT:
It appears that the Arduino support for these is based on the following github page:
https://github.com/esp8266/Arduino

The documentation indicates that there are a number of boards that are supported including the Sparkfun and Adafruit variants:
https://github.com/esp8266/Arduino/blob/master/doc/boards.md

The one on the MySensors link to this project is the NodesMCU dev board which is a little cheaper than either Huzzah or Thing but appears to be functionally identical.
« Last Edit: December 16, 2015, 11:51:51 PM by bkenobi »

February 03, 2016, 01:30:01 PM
Reply #11

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Update:
-Updated the ESP8266 Arduino "firmware" to 2.x couple weeks ago and have less resets now, but still happens every few days
-Added a photoresistor for luminance sensing via the one ADC input on ESP8266.  I have/had a limited selection of resistors to choose from so I couldn't use the best values in the divider. 


Other ideas I've been kicking around...
-move it closer to our interior garage/house door and add a small keypad to disarm HG security alarm
-still need to call HG webapi instead of polling the ESP8266

March 05, 2016, 06:15:00 AM
Reply #12

atideath

  • *
  • Information
  • Newbie
  • Posts: 2
Hello.

Can you share your HG program code and widget code? Lot of thanks!

January 13, 2017, 10:08:56 PM
Reply #13

djatie

  • **
  • Information
  • Jr. Member
  • Posts: 34