Interesting ESP8266 WiFi Module Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Interesting WiFi Module

Post by ThinkPad »

Anyone did something interesting in the meantime? I am still waiting for the power meter i ordered on eBay to arrive.

I want to build this: http://gizmosnack.blogspot.nl/2014/11/p ... eless.html but then with an ESP8266 that directly updates the value of a virtual Domoticz sensor.

Best would be to create some kind of sketch that mimicks a Youless device, as that one is already supported in Domoticz. Does anyone know how Domoticz reads the data from the Youless? As there is a webinterface for the Youless, but also some JSON output possible.
http://wiki.td-er.nl/index.php?title=YouLess

Edit: Awesome! I managed to get a DS18B20 connected to an Arduino to put its value into a virtual temperature sensor of Domoticz, wireless over my WiFi connection 8-) :mrgreen: In theory it can be done without the Arduino, but i am not that skilled enough.
I based it on: http://www.instructables.com/id/ESP8266 ... /?ALLSTEPS (i used the first code part (with debugging).

You can find my working code for Domoticz here: http://pastebin.com/CJcbALjN
Be sure to create a virtual temperature sensore (see wiki: http://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s )

Now the wireless electricity meter can't be that hard :lol: but unfortunately it is still somewhere between China and The Netherlands :(
I am not active on this forum anymore.
User avatar
Keptenkurk
Posts: 103
Joined: Wednesday 21 August 2013 17:24
Target OS: -
Domoticz version:
Location: Waalre, The Netherlands
Contact:

Re: Interesting WiFi Module

Post by Keptenkurk »

I made some progress on my ESP-03.
Found a very usefull quickstart, and was able to flash NodeMCU firmware into the unit (tuanpmt's version with MQTT support)
Next step is trying to program a Lua script which senses an ESP-03 GPIO input and posts the result by a json string to Domoticz. But that requires some more time and Lua skills.
The tiny board can see AP's two doors away, amazing! The supply is taken from the FT232RL USB interface buffered by a capacitor (470uF) to provide more current at peaks. Not really advised but works for the time being...

To be continued... (progress also blogged at keptenkurk)
/paul
SweetPants

Re: Interesting WiFi Module

Post by SweetPants »

Paul,
I'm experimenting with NodeMCU also, and so far it works great. Take a look at http://www.esp8266.com/viewtopic.php?f=22&t=747 The LuaUploader makes development a lot easier, you can easly upload you LUA scripts and test them. I currently run NodeMCU/SDK 0.9.5 on my ESP-1 and it works great.
/harry
User avatar
Keptenkurk
Posts: 103
Joined: Wednesday 21 August 2013 17:24
Target OS: -
Domoticz version:
Location: Waalre, The Netherlands
Contact:

Re: Interesting WiFi Module

Post by Keptenkurk »

@Harry
Tried the Lua Uploader which indeed makes programming the ESP real easy! A must have and i really love it. Thanks for sharing the link.
Now let's see how to push a value or status to Domoticz. Please post useful Lua scripts for the ESP here!
/paul
SweetPants

Re: Interesting WiFi Module

Post by SweetPants »

Keptenkurk wrote:Please post useful Lua scripts for the ESP here!/paul
init.lua
-- One time ESP Setup --
wifi.setmode(wifi.STATION)
wifi.sta.config ( "<your ssid>" , "<your password>" )
-- Get IP Address (DHCP)
print(wifi.sta.getip())

At this time you need to know your IP addres from your DHCP server because we run in STA (client) mode. I fixed that by using IP based on MAC address.

Then create a virtual device (ie a energy sensor), write down the index and execute the next LUA script

conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, pl) print(pl) end)
conn:connect(8080,"<your ip address>")
conn:send("GET /json.htm?type=command&param=udevice&idx=279&nvalue=0&svalue=450;2.0 HTTP/1.1\r\nHost: <your ip address>:8080\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")

and the values show up in the domoticz energy sensor
fridge.png
regards, Harry
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Interesting WiFi Module

Post by ThinkPad »

Did you really make something to monitor your fridge? Or is it just to have an example :P
I want to build this: http://gizmosnack.blogspot.nl/2014/10/p ... -hack.html but then with an ESP8266 to put the consumption data directly into Domoticz.

I have ordered that power meter he is talking about. The power meter should have arrived previous week, but unfortunately i didn't spot the mail man. Maybe next week...

Oh and i found this: https://github.com/beckdac/ESP8266-transparent-bridge
This is really basic firmware for the ESP that creates a totally transparent TCP socket to ESP UART0 bridge. Characters come in on one interface and go out the other.

Do you already have a serial project to which you just want to add WiFi? This is your ticket. No more dealing with the AT command set.
I think when i connect the ESP8266 to my smartmeter' P1-port, i can install something like ser2net and have a wireless smart meter :o 8-) ?
Something to try soon :P
I am not active on this forum anymore.
Emerson
Posts: 6
Joined: Monday 27 October 2014 12:19
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: South East England
Contact:

Re: Interesting WiFi Module

Post by Emerson »

ESP8266 with LDR photo resistance module
I have one of these modules, and with the trimpot you can configure the light intensity level where it should trigger. If it is light it returns a high signal (5V or 3V3, depending on supply voltage), when under set level it is low (0V).
Combined with an ESP8266 and a small phone charger, this could be a cheap way to create a dusk/dawn sensor
ThinkPad can i ask where you purchased the ESP8266 and the LDR module from and how are they connected or does the ESP8266 come with an LDR as an option?
Raspberry Pi + Domoticz + RFXtrx, LightwaveRF (dimmers, sockets, PIR's) Owl CM113, Oregon Scientific Temp / Humidity Sensors, Huacam CCTV Cameras, MySensors Lux and CO, ESP8266 NodeMCU temperature sensors
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Interesting WiFi Module

Post by ThinkPad »

Emerson wrote:
ESP8266 with LDR photo resistance module
I have one of these modules, and with the trimpot you can configure the light intensity level where it should trigger. If it is light it returns a high signal (5V or 3V3, depending on supply voltage), when under set level it is low (0V).
Combined with an ESP8266 and a small phone charger, this could be a cheap way to create a dusk/dawn sensor
ThinkPad can i ask where you purchased the ESP8266 and the LDR module from and how are they connected or does the ESP8266 come with an LDR as an option?
I am sorry, the description about it is not something i already made, it is just something that popped up in my mind.

I buy most of my hardware from eBay in China.

LDR module: http://www.ebay.com/itm/Photosensitive- ... 51c9c71646
ESP8266: http://www.ebay.com/itm/ESP8266-Serial- ... 259c25e960
I am not active on this forum anymore.
User avatar
Keptenkurk
Posts: 103
Joined: Wednesday 21 August 2013 17:24
Target OS: -
Domoticz version:
Location: Waalre, The Netherlands
Contact:

Re: Interesting WiFi Module

Post by Keptenkurk »

Then create a virtual device (ie a energy sensor), write down the index and execute the next LUA script
Yes! That works... :D sort of :? .
Tried this script to set/reset a dummy switch:

Code: Select all

print('jsonpost.lua started')
conn = nil
conn=net.createConnection(net.TCP, 0) 
conn:on("receive", function(conn, payload) print(payload) end )
conn:connect(8080,"192.168.xxx.xxx")
conn:send("GET /json.htm?type=command&param=switchlight&idx=120&switchcmd=On&level=0 HTTP/1.1\r\nHost: 192.168.xxx.xxx:8080\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
The odd thing is that if i try to set the switch off in a consecutive command i thought another conn:send(...) would be enough but for the second command to work i need to run the whole thing from conn=net.create(..) etc to get an answer from Domoticz. Not a big deal but gives me the awkward feeling i don't really understand what i'm doing (which of course is true).
/paul
SweetPants

Re: Interesting WiFi Module

Post by SweetPants »

HTTP is connection oriented, so after every send, the connection is closed (i presume). Maybe that's the reason why you have to create a new session to the Domoticz web server. I will try to make a packet trace to verify this behaviour and let you know. Regards, HArry
SweetPants

Re: Interesting WiFi Module

Post by SweetPants »

SweetPants wrote: I will try to make a packet trace to verify this behaviour and let you know. Regards, HArry
Just verfied that after receiving the HTTP/1.0 200 OK, the webserver closes the connection. This looks like normal behaviour.
So every time you want to send something you need to setup a connection first. That is maybe why ther is no 'close'?
SweetPants

Re: Interesting WiFi Module

Post by SweetPants »

@Paul Take a look at https://github.com/Manawyrm/ESP8266-HTTP for some nice HTTP functions
mvdbro
Posts: 24
Joined: Saturday 31 January 2015 19:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Interesting WiFi Module

Post by mvdbro »

This little device is really easy to implement. Using the LUA firmware with this script:

Code: Select all

if(t==nil) then
t=0
end
tmr.alarm(0,30000, 1, function()
conn=net.createConnection(net.TCP, 0)
    conn:on("receive", function(conn, payload) print(payload) end )
    conn:connect(8080,"192.168.0.8")
        conn:send("GET /json.htm?type=command&param=udevice&idx=9&nvalue=0&svalue=" .. t .. " HTTP/1.1\r\nHost: www.local.home\r\n"
        .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
and an Arduino Mini Pro to set t="xx.yy" through serial is all i needed to get a custom sensor shown in Domoticz.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Interesting WiFi Module

Post by ThinkPad »

Found this: http://vaasa.hacklab.fi/2015/01/12/esp8 ... k-nodemcu/

Lua scripting to connect DS18B20 directly to ESP8266 and upload data via GET-request. Replace ThingSpeak URL with a JSON one from Domoticz and presto :D
I am not active on this forum anymore.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Interesting ESP8266 WiFi Module

Post by dannybloe »

I wonder if these two batteries last long. I've read that the ESP takes about 200+mA to operate.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
niwreg
Posts: 25
Joined: Thursday 19 February 2015 11:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Interesting ESP8266 WiFi Module

Post by niwreg »

I found another example already with domoticz example:

http://blog.quindorian.org/2014/12/esp8 ... -x_30.html

wich create 2 dimable ledsstrip with wifi :)
antwan
Posts: 116
Joined: Saturday 13 July 2013 13:28
Target OS: Linux
Domoticz version: Latest
Location: Hilversum, The Netherlands
Contact:

Re: Interesting ESP8266 WiFi Module

Post by antwan »

dannybloe wrote:I wonder if these two batteries last long. I've read that the ESP takes about 200+mA to operate.
half a day max.
Rasp Pi 2B: 3x DS18S20 (1-wire), BME280 (i2c)
Cubietruck 1: Aeotec Z-Wave+, RFXtrx433XL+P1, RFXtrx868, TE923 display, SolarEdge API
Cubietruck 2: Aeotec Z-Wave, Voltcraft CO-20
SweetPants

Re: Interesting ESP8266 WiFi Module

Post by SweetPants »

antwan wrote:
dannybloe wrote:I wonder if these two batteries last long. I've read that the ESP takes about 200+mA to operate.
half a day max.
That is when it is transmitting, you can set it to 'deep sleep' mode http://hackaday.com/2015/02/08/hack-all ... eep-sleep/
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Interesting ESP8266 WiFi Module

Post by dannybloe »

I'm intending to make a multi-sensor with temp,hum,motion,lux and smoke detection (with alarm) all in one. I guess that for smoke and motion detection you don't want deep-sleep. I just got 5 ESPs from China. See if that will do or that I will go for mysensors with an Arduino instead. We'll see :))
Looking forward to some experimentation work.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Zycker
Posts: 24
Joined: Monday 29 December 2014 8:04
Target OS: Linux
Domoticz version:
Contact:

Re: Interesting WiFi Module

Post by Zycker »

SweetPants wrote:
Keptenkurk wrote:Please post useful Lua scripts for the ESP here!/paul
init.lua
-- One time ESP Setup --
wifi.setmode(wifi.STATION)
wifi.sta.config ( "<your ssid>" , "<your password>" )
-- Get IP Address (DHCP)
print(wifi.sta.getip())

At this time you need to know your IP addres from your DHCP server because we run in STA (client) mode. I fixed that by using IP based on MAC address.

Then create a virtual device (ie a energy sensor), write down the index and execute the next LUA script

conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, pl) print(pl) end)
conn:connect(8080,"<your ip address>")
conn:send("GET /json.htm?type=command&param=udevice&idx=279&nvalue=0&svalue=450;2.0 HTTP/1.1\r\nHost: <your ip address>:8080\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")

and the values show up in the domoticz energy sensor
fridge.png
regards, Harry
Hi,
First thank you for your message, with it I'm finally able to send information from my esp-12 to domoticz after hours of search.
I might haven't understand entirely the concept behind counter with domoticz, here is my setup :
Raspberry with domoticz 2.2283
Nodemcu devkit (esp-12) wired to an Velleman EMDIN01 (kWh counter with lcd display and pulse output with 1 pulse = 1 Wh)

I've read the wiki about json and electric counter but I'm not sure which one to choose between Electric and Counter.
What I want is my overall and daily consumption, with graph as domoticz generate itself but I'm not sure what value send to domoticz :
- each impulsion (easy but not optimized)
- x min consumption
and should I send it as nvalue , svalue COUNTER or ENERGY, I don't understand the difference in the wiki.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest