HomeGenie Forum

General Category => General Discussion => Topic started by: [email protected] on February 03, 2016, 09:18:04 AM

Title: Esp8266
Post by: [email protected] on February 03, 2016, 09:18:04 AM
Anybody using these?  I'm planning on  ds18b20 and a relay or two via mqtt back to homegenie. Got it on the bench talking via at commands now need to look at nodemcu
Title: Re: Esp8266
Post by: kevin1 on February 03, 2016, 12:51:36 PM
I have been using the ESP8266 as a garage door / multisensor for over 6 months.  Works great if you enjoy tinkering with arduino/electronics and a bit of code, but don't want your device in a pretty white box ;-)  More info in this thread...
http://www.homegenie.it/forum/index.php?topic=927.msg5664#msg5664
Title: Re: Esp8266
Post by: [email protected] on February 03, 2016, 03:37:05 PM
Thanks, thought I had seen stuff floating about, but couldn't find it with the search!

Dont mind playing with electronics.. My view is to use a fair few of these esp modules with some custom pcb's to try and enable some existing stuff where I cant get wires and don't want big 'smart' devices with limited functionality.

What language / firmware have you been using.. I have the ESP-12 modules here.
Title: Re: Esp8266
Post by: kevin1 on February 03, 2016, 04:10:26 PM
Arduino IDE, C code ... https://github.com/esp8266/Arduino
Title: Re: Esp8266
Post by: bkenobi on February 03, 2016, 04:53:47 PM
I'm attempting to convert my 433MHz sensor receiver to MQTT gateway from Arduino UNO over to a NodeMCU + RFM69.

I'm slowly making progress, but I find that the documentation on using these things with Arduino IDE is TERRIBLE.  I spent quite a while over the last couple days trying to figure out why using things like BUILTIN_LED doesn't work.  Turns out that the IDE doesn't pick the right GPIO for my board.  This seems common with my Wemos D1 as well.  But, if you reference the GPIO number directly, it will work.  The issue is, the board is labeled with an Arduino type pin number (D0, D1, D2, ...) and not the GPIO (0, 1, 2, ...) and since they don't align (D0 <> GPIO 0) it is tricky.

The other thing I've run into is that the libraries for Arduino hardware are not always compatible with ESP8266 modules.  So, the RFM69 library that everybody uses:
https://github.com/LowPowerLab/RFM69
Does not work for ESP8266.  I've read a couple blog posts that suggest a port has been completed, but it appears none have been released.  I assume this won't be an issue for your ds18b20 as it's quite common hardware.
Title: Re: Esp8266
Post by: [email protected] on February 04, 2016, 12:17:54 AM
I've just got a esp-12 and noticed that gpio names  ref a gpio index number.  I've flashed a node mcu firmware on,  but the more I read the more confusion about what to run on it.. People say not to use arduino but got to be better than Lua?
Title: Re: Esp8266
Post by: kevin1 on February 04, 2016, 02:56:47 AM
I vote for arduino unless you happen to know Lua scripting.
Title: Re: Esp8266
Post by: [email protected] on February 04, 2016, 01:59:23 PM
I'm sticking with arduino.

Just writing some code up now using notepad with a view to flashing the code when at home :)

Plan is to communicate via mqtt and be able to control the frequency of updates by sending commands, IE tell it to send temp more or less frequently without code changes.. and then also send back ack messages for when you tell it to do something.. so I actually know I have turned a module on.. and also support local switching that gets sent back to home genie to update the module state.

Title: Re: Esp8266
Post by: [email protected] on February 06, 2016, 12:53:21 AM
Got the thing sending messages via mqtt now.. Just using mosquitto for testing initially :)

Image attached
Title: Re: Esp8266
Post by: bkenobi on February 06, 2016, 04:59:02 AM
I've been having a heck of a time trying to get a simple test going with my NodeMCU or Wemos D1 boards.  I can run all the basic stuff, but when I hook up a RF receiver module, I get resets every 5 seconds. 
Title: Re: Esp8266
Post by: [email protected] on February 06, 2016, 01:56:37 PM
What you using for power? (I know every one says this for every pi problem too!!!)

I did have interesting behavior last night, when I tried to get the signal strength it crashed the thing.. so skipped that for the moment.

What sort of RF Receiver you using too? just a 433mhz am?? if so I have a load here I can test with if thats any use.. EDIT- Just seen RFM69..

Depending on what board you are using some have the gpio's marked incorrectly.

Anyway got a little further with mine now as it can detect multiple sensors and post these via MQTT.. just need to work out how I am going to store the previous values for multiple sensors..

Reading this http://blog.hekkers.net/2012/09/18/mqtt-about-dumb-sensors-topics-and-clean-code/ (http://blog.hekkers.net/2012/09/18/mqtt-about-dumb-sensors-topics-and-clean-code/) was very interesting, so going to use the MAC address to pull data required, which I currently post to a topic during setup()

but going to need to do some dev on the homegenie side to store / retrieve this data, probably in a db initially.

David
Title: Re: Esp8266
Post by: bkenobi on February 07, 2016, 07:33:30 AM
I have a couple hardware configurations I've been playing with.

I actually just got them working to some degree this afternoon.  I can now receive noise (no signals yet).  I plan to use the RFM69 in the end, but the ESP library for RFM69 is not published so far as I've found.  I think I can use the chip without the library, but it will be missing most of the benefits.
Title: Re: Esp8266
Post by: [email protected] on February 13, 2016, 01:22:46 PM
Think I have almost finished the code on the 8266 now..

Basic functionality:

Scan for the number of sensors attached (DS18B20) (currently only using two.. as coding for one seems silly :) )

Posts signal strength and temp when changed via MQTT to dynamically determined topics using the devices macaddress.

Receives commands to control a relay via MQTT to do the following:

ON
OFF
STATUS
FLASH_ON (will revert to previous state)
FLASH_OFF

All commands can send an ack msg back when received too.

Going to also add a local switch that could be used in the room to turn the light on, which would then tell homegenie the state, this should allow things to work whilst homegenie reboots or is offline for any reason :)

Title: Re: Esp8266
Post by: bkenobi on February 15, 2016, 06:13:14 PM
So can I assume you are using the ESP as the sensor nodes and they send the data to your MQTT broker for collection?  Have you looked at power usage yet?  I read that ESP was a power hog compared to an Arduino + RFM69 or Arduino + nRF24L01+.  My setup won't have remote sensors as I'm simply collecting commercial 433MHz signals and processing them in my gateway and then sending the processed data on to my MQTT broker via 2.4GHz.

Oh, and I've found a number of resources that appear to all point to the MySensors RFM69 library which now has ESP support within the Arduino IDE.  I haven't gotten a chance to play with it yet, but hopefully it will work out.
Title: Re: Esp8266
Post by: kevin1 on February 17, 2016, 01:57:24 PM
From here ... http://blog.hekkers.net/2015/04/06/esp8266-good-enough-for-a-battery-powered-sensor/ (http://blog.hekkers.net/2015/04/06/esp8266-good-enough-for-a-battery-powered-sensor/)

Quote
A report interval of 4 samples per hour will lead to a battery life of roughly 1 year. Increasing the report interval to 60 times an hour (once per minute) will lead to a much shorter battery life: less than 3 weeks.
Title: Re: Esp8266
Post by: [email protected] on February 18, 2016, 03:10:21 PM
I don't care about power usage, I cared about size :) It will be running from the mains..

I could drop it into deep sleep and wake it when interested.. It looks typically like it draws around 80ma from memory of my desktop psu display.
Title: Re: Esp8266
Post by: bkenobi on February 18, 2016, 05:47:05 PM
Yup, if running from mains it makes no difference.  That's my plan as well.
Title: Re: Esp8266
Post by: [email protected] on March 01, 2016, 12:42:07 AM
Added 433 Mhz support tonight :)

Originally I had added 433 support to homegenie using a cheap ebay transmitter connected to an arduino and plug in sockets.

Problem is these are only one way and dont send any thing back..

So, I've got an ESP8266 with two temperature sensors (ds18b20) which post data back to homegenie if the value changes, but can add minimum poll values etc, and make it dynamically configurable from homegenie. (I added two, so that the code supported more than 1!)

You can send commands such as on, off, toggle, flash, status - which erm do as they sound.

And you can now use the original remote to turn them on and off, meaning the other half knows no difference, yet homegenie knows whats going on :)

Code needs a bit of refactoring now and then got to squeeze the hardware down and fit it inside some more cheapo sockets I got off ebay with no remote as I couldn't find a case in this style (http://ecx.images-amazon.com/images/I/41iWOF8E-HL._SY300_.jpg)

Got some small 5v PSU's coming, and then will add a 3.3v reg for the esp8266, mount a ds18b20 outside the case, and hope :)

Title: Re: Esp8266
Post by: bkenobi on March 01, 2016, 04:12:21 PM
I was all excited when you said 433MHz thinking you might have opted for the HopeRF RFM69.  I know there's a way to incorporate it since MySensors has an Arduino library that supposedly works, but I have yet to wrap my head around how to make it work.
Title: Re: Esp8266
Post by: [email protected] on March 01, 2016, 08:04:08 PM
No, Sorry to get your hopes up, nothing fancy, this isn't ideal either as it isn't secure and prone to triggering my doorbells, but this was only to maintain backwards compatibility for some lamps, whilst I perfect occupancy detection and remove the control :) I'm simply using the RC Switch Lib.
Title: Re: Esp8266
Post by: bkenobi on March 01, 2016, 09:16:15 PM
That library seems to be widely used but doesn't work when receiving sensor data in my experience.  Seems to be well suited for communicating between two devices that you are writing code for though (which is what you are doing).
Title: Re: Esp8266
Post by: [email protected] on March 01, 2016, 11:54:46 PM
I'm not so sure it is for much other than turning things on or off, might be mistaken..
Title: Re: Esp8266
Post by: bkenobi on March 02, 2016, 08:05:02 AM
When I looked into it a year+ ago, I believe I saw some examples of people doing more than turning a light on/off.  I was looking for a way to decode RF transmissions, so it didn't work for me and I moved on without doing any more research.  I'm sure you're right (just look at the code name!).