Page 2 of 6

Re: Interesting WiFi Module

Posted: Friday 23 January 2015 20:16
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 :(

Re: Interesting WiFi Module

Posted: Saturday 24 January 2015 17:34
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

Re: Interesting WiFi Module

Posted: Sunday 25 January 2015 12:10
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

Re: Interesting WiFi Module

Posted: Sunday 25 January 2015 20:11
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

Re: Interesting WiFi Module

Posted: Sunday 25 January 2015 21:14
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

Re: Interesting WiFi Module

Posted: Sunday 25 January 2015 22:21
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

Re: Interesting WiFi Module

Posted: Monday 26 January 2015 12:36
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?

Re: Interesting WiFi Module

Posted: Monday 26 January 2015 12:48
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

Re: Interesting WiFi Module

Posted: Monday 26 January 2015 21:30
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

Re: Interesting WiFi Module

Posted: Tuesday 27 January 2015 8:04
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

Re: Interesting WiFi Module

Posted: Tuesday 27 January 2015 21:05
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'?

Re: Interesting WiFi Module

Posted: Tuesday 27 January 2015 21:48
by SweetPants
@Paul Take a look at https://github.com/Manawyrm/ESP8266-HTTP for some nice HTTP functions

Re: Interesting WiFi Module

Posted: Saturday 31 January 2015 19:36
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.

Re: Interesting WiFi Module

Posted: Thursday 12 February 2015 19:25
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

Re: Interesting ESP8266 WiFi Module

Posted: Thursday 19 February 2015 13:30
by dannybloe
I wonder if these two batteries last long. I've read that the ESP takes about 200+mA to operate.

Re: Interesting ESP8266 WiFi Module

Posted: Thursday 19 February 2015 14:12
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 :)

Re: Interesting ESP8266 WiFi Module

Posted: Thursday 19 February 2015 23:49
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.

Re: Interesting ESP8266 WiFi Module

Posted: Friday 20 February 2015 7:50
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/

Re: Interesting ESP8266 WiFi Module

Posted: Friday 20 February 2015 9:01
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.

Re: Interesting WiFi Module

Posted: Saturday 21 February 2015 17:52
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.