Voilà, ça commence à envoyer les mesures à la db :-)

This commit is contained in:
Christian Zufferey
2019-09-16 23:27:57 +02:00
parent 6d34e6325b
commit 97145e2a3f
3 changed files with 11 additions and 22 deletions

View File

@@ -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

View File

@@ -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()
]]

View File

@@ -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