Voilà, ça commence à envoyer les mesures à la db :-)
This commit is contained in:
@@ -1,20 +1,8 @@
|
||||
-- Petit script pour faire office de crontab pour les
|
||||
--mesures
|
||||
print("\n 0_cron.lua zf190916.1506 \n")
|
||||
print("\n 0_cron.lua zf190916.2318 \n")
|
||||
|
||||
cron1=tmr.create()
|
||||
cron1:alarm(10*1000, tmr.ALARM_AUTO, function()
|
||||
get_temp()
|
||||
cron1:alarm(5*1000, tmr.ALARM_AUTO, function()
|
||||
send_data()
|
||||
end)
|
||||
|
||||
if zfield == 2 then
|
||||
cron2=tmr.create()
|
||||
cron2:alarm(20*1000, tmr.ALARM_AUTO, function()
|
||||
print("cron2........................")
|
||||
zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(ztemp2).."&field3="..tostring(ztemp3)
|
||||
send_temp()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
-- Petit script pour envoyer les valeurs sur un serveur WEB (InfluxDB)
|
||||
-- via un http GET
|
||||
print("\n 0_send_data.lua zf190916.1504 \n")
|
||||
print("\n 0_send_data.lua zf190916.2254 \n")
|
||||
|
||||
function send_data()
|
||||
print("send_data: ")
|
||||
|
||||
zarg="energy,compteur=2 puissance="..zpuissance
|
||||
zarg="energy,compteur=2 puissance="..zpower/1000
|
||||
print("zarg: "..zarg)
|
||||
|
||||
http.post(zurl, 'Content-Type: application/x-www-form-urlencoded\r\n', zarg, function(code, data)
|
||||
http.post(influxdb_url, 'Content-Type: application/x-www-form-urlencoded\r\n', zarg, function(code, data)
|
||||
-- print("toto")
|
||||
if (code < 0) then
|
||||
print("HTTP request failed")
|
||||
@@ -22,5 +22,6 @@ function send_data()
|
||||
end
|
||||
|
||||
--[[
|
||||
function send_data()()
|
||||
zpower=450
|
||||
send_data()
|
||||
]]
|
||||
|
||||
@@ -24,9 +24,9 @@ f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
f= "web_ide2.lua" if file.exists(f) then dofile(f) end
|
||||
f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--f= "0_get_data.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "0_cron.lua" if file.exists(f) then dofile(f) end
|
||||
f= "0_get_data.lua" if file.exists(f) then dofile(f) end
|
||||
f= "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
f= "0_cron.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f=nil
|
||||
--heartbeat=nil
|
||||
|
||||
Reference in New Issue
Block a user