nodeMCU dimmer/switch/temp.sensor without arduino

6 years 7 months ago - 6 years 7 months ago #810 by cdj
Dennis now i've :
> print(dofile("bmp085.lua").read(4, 3))
18.893415127304 764.84547162023

Vladimir told me that we need :
--local t = .read(...); print(t) for temperature
--local _, p = .read(...); print(p) for pression

tried in bmp085.lua to put at the end instead of return t, p :

if pression then
return p
else
return t --, p
end

according to modified dht22.lua when you write if hum....

but don't understand how to make the function when i read "pression" ....because in dht there's

local read = function(pin, dht22, hum)
sob

Please it miss very little !

Dario

Please Log in or Create an account to join the conversation.

6 years 7 months ago #812 by Dennis

cdj wrote: Dennis now i've :
> print(dofile("bmp085.lua").read(4, 3))
18.893415127304 764.84547162023

Vladimir told me that we need :
--local t = .read(...); print(t) for temperature
--local _, p = .read(...); print(p) for pression

tried in bmp085.lua to put at the end instead of return t, p :

if pression then
return p
else
return t --, p
end

according to modified dht22.lua when you write if hum....

but don't understand how to make the function when i read "pression" ....because in dht there's

local read = function(pin, dht22, hum)
sob

Please it miss very little !

Dario


OK, so you got a reading now from your sensor, good.
To alter the "read" function of the bmp085.lua, to accept one additional boolean argument "pression", you need to replace
local read = function(sda, scl, oss)

with
local read = function(sda, scl, oss, pression)

and then you need to query it from init.lua as follows,

temperature:
dofile("bmp085.lua").read(4, 3,false,false)

pressure:
dofile("bmp085.lua").read(4, 3,false,true)


I'm sure there is also a way to return multiple values and reference them in a table object (similar to array in c), but I don't know how to.

I updated github repo with new init.lua improved for dht11 read stability, btw.

regards
The following user(s) said Thank You: cdj

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #813 by Dennis

VasilijHCN wrote: Look at this
homes-smart.ru/index.php/oborudovanie/be...-servisa-narodmon-ru
Here is alternative firmware with many sensor type support, in free version maybe we can get temperature info from it.
Sensors read command is http://ESP_IP/sensors
Data are output through a point from a comma. (:)
I get this dsw1:17.9;dsw2:17.9;
dsw -ds18b20 sensor(dsw1 dsw2 sensor numbers)
In IOT automation we need request temperature from http://192.168.1.113/sensors
and extract temperature data from dsw1:17.9;dsw2:17.9;
My programming skill is to low for this.


Just tried that FW, and it looks very interesting.
But it is commercial, no open-source and you need to pay for it to enable all features. And we need to remove whole HTTP protocol, just to get a float value (and also put together http GET request instead of sending a simple string command). I like the lua FW much more, since it offers almost same flexibility as the arduino platform.

I think, the better solution is turning this code from esp8266 forums into a "library" (omit the webserver part, and expose the readTemp function and give the needed values as arguments): www.esp8266.com/viewtopic.php?f=19&t=752

Can someone with ds18b20 sensor in reach confirm this is working code with nodeMCU 0.9.4?

Edit: found a simpler code, I think adopting this will be easier: www.esp8266.com/viewtopic.php?f=19&t=757

edit2 - or simply one of the nodeMCU firmware examples, again from Vladimir Dronnikov so chances are good it will work well :)
github.com/nodemcu/nodemcu-firmware/blob...-another-ds18b20.lua


regards

Please Log in or Create an account to join the conversation.

6 years 7 months ago #814 by Dennis
Just read again, this bit is the key! :woohoo:

Vladimir told me that we need :
--local t = .read(...); print(t) for temperature
--local _, p = .read(...); print(p) for pression


So, if <I understand correctly we do not need to modify the dht22 or bmp085 library, we just need to select which returned value to accept!
myval = (dofile("dht22.lua").read(4))
_,myval = (dofile("dht22.lua").read(4))

I'll try this with the original un-modified dht22.lua, and if this works we can omit altering the libs. B)

regards

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #816 by cdj
ARGH, wait a min...
i've just ended to modify everything and sometimes read temp or pressure but all the rest give me a "not enough memory" error....

and if we can it's better to trim value in XX,XX format with only two decimal...

But now... i try to put again lua and dht22 and try with bmp and your command...


No, with your last init.lua and dht22 loaded if i send manually :

> dofile("dht22.lua").read(4)

i have no answer....

tried also
dofile("dht22.lua").read(4, false, false)

EDIT: with modified init.lua ver. 0.6 and bmp085.lua i've obtained :

> print("BMP Press", dofile("bmp085.lua").read(4,3,false,true))
BMP Press 765.16358666021
> print("BMP Temp", dofile("bmp085.lua").read(4,3,false,false))
BMP Temp 20.833698907656

EDIT : this happen with 0.9.5... but instable... if i put 0.9.4 when i make request node reboot :-(

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #817 by cdj
See the next post, sorry

Please Log in or Create an account to join the conversation.

Time to create page: 0.245 seconds