From 97145e2a3fb62442b5f71edf40a047280d36dac4 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Mon, 16 Sep 2019 23:27:57 +0200 Subject: [PATCH] =?UTF-8?q?Voil=C3=A0,=20=C3=A7a=20commence=20=C3=A0=20env?= =?UTF-8?q?oyer=20les=20mesures=20=C3=A0=20la=20db=20:-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/solar_pv_energy/0_cron.lua | 18 +++--------------- Mesures/solar_pv_energy/0_send_data.lua | 9 +++++---- Mesures/solar_pv_energy/boot.lua | 6 +++--- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Mesures/solar_pv_energy/0_cron.lua b/Mesures/solar_pv_energy/0_cron.lua index f729ae4..e60c0a1 100644 --- a/Mesures/solar_pv_energy/0_cron.lua +++ b/Mesures/solar_pv_energy/0_cron.lua @@ -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 - - - diff --git a/Mesures/solar_pv_energy/0_send_data.lua b/Mesures/solar_pv_energy/0_send_data.lua index 79b6af8..9a74ea5 100644 --- a/Mesures/solar_pv_energy/0_send_data.lua +++ b/Mesures/solar_pv_energy/0_send_data.lua @@ -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() ]] diff --git a/Mesures/solar_pv_energy/boot.lua b/Mesures/solar_pv_energy/boot.lua index 8ebd274..931ba86 100644 --- a/Mesures/solar_pv_energy/boot.lua +++ b/Mesures/solar_pv_energy/boot.lua @@ -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