Import temperature sensor1 One-wire
Posted: Sunday 13 May 2018 13:07
Hello Everybody,
I am trying to read and write several One-wire sensors into dummy temp sensors.
One-wire sensors are conected to a WEBCAI board, values I can receive with HTTP request
when I use the request an output it gives me value 23.2 C (where C is for Celsius, but this is coming from the web board)
Found this script allready on this site , but needs some rewriting for me to get it working.
I am a complete nob when it comes to programming, so desperate for some help with this.
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -s http://x.x.x.x/gett2.cgi" , 'r'))
local s = assert(f:read('*a'))
local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
if status == "OK" then
-- you can see prints in Setup/Log
print("One-Wire : read and update 1 : "..s.."=>"..temp)
commandArray["UpdateDevice"] = IDX.."|0|"..temp
else
print("One-Wire : bad status : "..s)
end
end
return commandArray
I believe the error for my case is in the line : local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
but not sure. I am only getting 23.6 C as result also when I use a curl request directly.
Any help, much appriated
Jack
I am trying to read and write several One-wire sensors into dummy temp sensors.
One-wire sensors are conected to a WEBCAI board, values I can receive with HTTP request
when I use the request an output it gives me value 23.2 C (where C is for Celsius, but this is coming from the web board)
Found this script allready on this site , but needs some rewriting for me to get it working.
I am a complete nob when it comes to programming, so desperate for some help with this.
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -s http://x.x.x.x/gett2.cgi" , 'r'))
local s = assert(f:read('*a'))
local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
if status == "OK" then
-- you can see prints in Setup/Log
print("One-Wire : read and update 1 : "..s.."=>"..temp)
commandArray["UpdateDevice"] = IDX.."|0|"..temp
else
print("One-Wire : bad status : "..s)
end
end
return commandArray
I believe the error for my case is in the line : local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
but not sure. I am only getting 23.6 C as result also when I use a curl request directly.
Any help, much appriated
Jack