The principle works. Ik can get it to connect to my wifi network, and with a simple webserver I can read the temperature of the sensor in a webbrowser.
But I want the ESP to send it automatically to my Domoticz server. Using the examples given in this topic, and elsewere on the net I did succeeed up until a certain point. Everything seems to work, but there is no data in Domoticz. Maybe someone can help me take the last hurdle.
Some more info regarding to my setup:
The IP address of the Domoticz server is 192.168.8.12
The IP address of the ESP8266 is 192.168.8.99
I've created a dummy device so i got a temperature sensor in Domoticz. The ID of the device is 32
On the ESP, i use the following script to connect to my WiFi and give it a static IP address:
Code: Select all
--init.lua
print("Setting up WIFI...")
wifi.setmode(wifi.STATION)
wifi.sta.config("MySSID","MyWPA2key")
wifi.sta.connect()
wifi.sta.setip({ip="192.168.8.99",netmask="255.255.255.0",gateway="192.168.8.11"})
print("ESP8266 mode is: " .. wifi.getmode())
print("The module MAC address is: " .. wifi.ap.getmac())
print("Config done, IP is "..wifi.sta.getip())
dofile ("domoticz.lua")
This works like a charm. I get correct temperatures at the serial console.
Last, I trie to send the temperature to Domoticz, and I think that there is the problem somewhere, but I do not see it.
The code I use is:
Code: Select all
require('ds18b20')
-- ESP-01 GPIO Mapping
gpio0 =3
gpio2 =4
-- ds18b20.setup(gpio0)
ds18b20.setup(gpio2)
t1=ds18b20.read()
print("Temp:" .. ds18b20.read() .. " C\n")
conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, pl) print(pl) end)
conn:connect(8080,"192.168.8.12")
conn:send("GET /json.htm?type=command¶m=udevice&idx=32&nvalue=0&svalue=" .. t1 .. " HTTP/1.1\r\nHost: 192.168.8.12:8080\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
Thanx for looking.
Ed.