@okadesde ok, now i have some other problems…
First a notice about time.lua ( it can not compile… )
Second on the main.lua you have an ip of a pimatic server. I can not change the ip from the web page if i leave it (error preferred ip is … )
Third the ip of pimatic server after reset of esp is lost…
-
[UPDATED] ESP8266 WiFi Sensor - temperature and humidity
-
@Panos Sry, time.lua is a temporary fix and used as a DB. Therfore you don’t need to compile it. Will edit my post. That all settings are lost on restart is a known problem and listed under bugs. Without this bug it wouldn’t be possible to change the DATA interval. Posted this earlier and I am already working on a fix.
Changing the IP Address via the website is working for me. Please post the complete error message so that I can look into it.
-
@okadesde ok. Thank you for your help. Everything is ok now. I did not notice the bugs… keep up your excellent work…!!!
-
@georg90 please, could you publish a wiring diagram ? (about https://github.com/georg90/esp8266-pimatic)
I can’t see pictures details about DS18B20 and resistor (4K7 ??) conections.
I try some posibilitties but the program says:
Total DS18B20 sensors: 1 Temperature: 85°C
Thanks in advance!
-
@tomansi I’m waiting for my DHT22 to arrive, so I can change it for the DS18B20…
The 85° error is common with the DS18B20…let it run for a while, maybe it Needs some time to "settle"
That’s why I use this: https://github.com/georg90/esp8266-pimatic/blob/master/main.lua#L71-L73
Once I open the case again I can make some wiring Diagramm…but it should be like this: (I used a 4.7k resistor) -
@okadesde I really like the GUI etc. Nice job.
I had a little time to play around - added a custom Port feature because I’m not using a Standard Port.https://github.com/georg90/esp8266-pimatic-1
So Todos would be
- to have the settings survive a restart (other method that put them in files?)
- Add custom variable support, since if you’re running multiple devices this can be an issue^^
-
@georg90 said:
“but it should be like this (picture)”
Works with the GPIO2 the other one (the picture shows connect to the GPIO0).
Thanks!
-
mine is also working - edited the sketch a bit further to support persistent config values & custom variable names
https://github.com/georg90/esp8266-pimatic-1
Also check out this one: http://frightanic.com/nodemcu-custom-build
-
@georg90 Nice work on your side. Will try to add some features tomorrow (client index, dump all settings to a db.lua file etc). But still no luck with the tmr.alarm() loop.
Nodemcu custom builds seems really nice. Now it just needs the feature to add lua files and flashing would be far easier ^^.
-
I tried one db with cjson, too. But I always ran into memory issues… Hope you have better luck.
Custom builds will be an good option to easier put everything together. Must be able to put some user functions in there somehow…
-
@okadesde hi guys!
i use ds18b20 sensor with esp8266 with this scripts
i can’t show recieved data from esp8266 in pimatic. It’s show me:
error [pimatic]: No variable with the name “esp01-temp1” found.
My devices section:"devices": [ { "id": "esp01-outside-wifi-temp-device", "name": "Outside", "class": "VariablesDevice", "variables": [ { "name": "outsideTemp", "expression": "$temp1", "type": "number", "unit": "°C" } ] } ],
in main.lua i used variable like in the pimatic: $temp1
variableName = “temp1” -
Hi @mocart2
That’s a bit misleading, sorry.
The variable have to be named$esp01-temp1
You can also change the following line: https://github.com/georg90/esp8266-pimatic/blob/master/main.lua#L49
to something like this:conn:send("PATCH /api/variables/"..name.." HTTP/1.1\r\n")
This way you can name the variable$temp1
Edit: Done that in: CommitAlso stay tuned since @okadesde is developing a better version. Also I tried: https://github.com/georg90/esp8266-pimatic-1 (it’s not very stable for now, but this can also be an issue with my power supply…)
-
@georg90 said:
Also stay tuned since @okadesde is developing a better version. Also I tried: https://github.com/georg90/esp8266-pimatic-1 (it’s not very stable for now, but this can also be an issue with my power supply…)
Hi, i changed line in main.lua, but it still not working, pimatic show me:
15:52:51.163 [pimatic] error: No variable with the name “temp1” found.
this is cat of my devices section:"devices": [ { "id": "esp01-outside-wifi-temp-device", "name": "Outside", "class": "VariablesDevice", "variables": [ { "name": "temp1", "expression": "$temp1", "type": "number", "unit": "°C" } ] } ]
and in pimatic Variables page i see 1 var:
$esp091-outside-wifi-temp-device.temp1 (attribute) nullmaybe it not works, because variable $temp1 is has device prefix? $esp091-outside-wifi-temp-device.
-
@mocart2 Please add/edit these to your config.json:
variables:
{ "name": "esp01-hum", "value": 0 }, { "name": "esp01-tem", "value": 0 }
devices:
{ "id": "esp01", "name": "Sensor", "class": "VariablesDevice", "variables": [ { "name": "Temperatur", "expression": "$esp01-tem", "type": "number", "unit": "°C" }, { "name": "Luftfeuchtigkeit", "expression": "$esp01-hum", "type": "number", "unit": "%" } ] }
Should work this way. You can only change the “name” in devices to your prefered ones. In “variables” it should stay like this, otherwise it won’t accept an incomming request.
-
@mocart2
You’re only editing the Variables Device. This is only to display the variable inside pimatic.
You’ll need a variable in pimatic named after what you put invariableName
inside your main.lua! (see @okadesde reply)This clearly shows your error:
15:52:51.163 [pimatic] error: No variable with the name “temp1” found.If you take this example, you should:
- enter a variable named
esp01-tem
in pimatic (give it a value: 0) - name your variable (in main.lua)
variableName = "esp01-tem"
- put
$esp01-tem
inside the expression tag of your VariablesDevice
- enter a variable named
-
Hi. used the code by @georg90 as a starting point for my first first esp8266 testing.
The only thing the code should be doing now is changing a variable scene in pimatic to the value test.
But (unfortunately it doesn’t )The console log from the EPS (ESPlorer) shows:
Setting up WIFI…
IP unavailable, Waiting…
Config done, IP is 192.168.2.133
Test
Sending data…
Closing connection.
Got disconnected
Test
Sending data…
Closing connection.
Got disconnected
etc. etc.But… the value in pimatic doesn’t change.
I used the correct ip address for my pimatic server
I used base64login that is <user>:<password> encoded by motobit.comHow can I debug this, is there a way in pimatic to view what is sent tho the API?
-
@AvdH post your source code here (or better paste it!) since my github changed alot^^
I now try to edit a device, which is not working…anybody tried that in lua before?
Edit: Got it working…
-
Hi @georg90 Thanks for the response.
My code (main.lua) is :
contentLength = 0 -- user:password (pimatic) in BASE64; ex. "dXNlcjpwYXNzd29yZA==" -- This online tool can encode/decode base 64 for you http://www.motobit.com/util/base64-decoder-encoder.asp -- admin:A2kwadraat = YWRtaW46QTJrd2FkcmFhdA== base64login = "YWRtaW46QTJrd2FkcmFhdA==" -- UTF8 -- pimatic server IP -- according to docs can also be domain --pimaticServer = "192.168.178.64" pimaticServer = "pimatic" -- pimaticPort = "80" pimaticPort = 80 -- Pimatic variable which should be updated variableName = "scene" -- send data every X seconds interval = 60 -- Show Script version function showVersion() print("") print("esp8266-pimatic Scene switch") print("v 0.01.11") print("") end --- calc content-length function calcLength(type) print(type) contentLength = string.len(type) + 40 print("Content-Length: "..contentLength) end --- send data function sendData(type, name) calcLength(type) print("Sending data ...") -- conn=net.createConnection(net.TCP, 0) -- conn:on("receive", function(conn, payload) print(payload) end) -- conn:connect(pimaticPort,pimaticServer) -- conn:connect(80,"192.168.2.187") -- conn:send("PATCH /api/variables/"..name.." HTTP/1.1\r\n") -- conn:send("Authorization: Basic "..base64login.."\r\n") -- conn:send("Host: "..pimaticServer.."\r\n") -- conn:send("Content-Type:application/json\r\n") -- conn:send("Content-Length: "..contentLength.."\r\n\r\n") -- conn:send("\{\"type\"\: \"value\"\, \"valueOrExpression\"\: "..type.."\}") --- conn=net.createConnection(net.TCP, 0) conn:on("receive", function(conn, payload) print(payload) end) conn:connect(pimaticPort,pimaticServer) conn:send("PATCH /api/variables/"..name.." HTTP/1.1\r\n") conn:send("Authorization: Basic "..base64login.."\r\n") conn:send("Host: "..pimaticServer.."\r\n") conn:send("Content-Type:application/json\r\n") conn:send("Content-Length: "..contentLength.."\r\n\r\n") conn:send("\{\"type\"\: \"value\"\, \"valueOrExpression\"\: "..type.."\}") --- conn:on("sent",function(conn) print("Closing connection") conn:close() end) conn:on("disconnection", function(conn) print("Got disconnection...") end) --- end --- main loop print("main.lua started") showVersion() print("IP address is "..wifi.sta.getip()) tmr.alarm(0, (interval*1000), 1, function() sendData("Test", variableName) end )
Edit: Added code tags
-
please post this in code tags or use pasebin etc.
I can’t read it like this…