From 099e257876ed94edaef2a6e79fac3b6681b6dd3d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Mon, 25 May 2020 12:39:27 +0200 Subject: [PATCH] =?UTF-8?q?La=20routine=20set=5Ftime=20consomme=20trop=20d?= =?UTF-8?q?e=20ram,=20j'utilise=20donc=20maintenant=20tmr.now()=20comme=20?= =?UTF-8?q?time=5Fstamp.=20Socat=20est=20aussi=20d=C3=A9marr=C3=A9=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/humidity/solar-grafana/0_1_htu21d.lua | 3 ++- Mesures/humidity/solar-grafana/0_2_htu21d.lua | 3 ++- Mesures/humidity/solar-grafana/0_cron.lua | 3 ++- Mesures/humidity/solar-grafana/0_http_post.lua | 4 +++- Mesures/humidity/solar-grafana/0_zdyndns.lua | 4 +++- Mesures/humidity/solar-grafana/boot.lua | 14 +++++++++++--- .../solar-grafana/{ => goodies}/set_time.lua | 17 ++++------------- .../solar-grafana/{ => goodies}/telnet_srv2.lua | 0 8 files changed, 27 insertions(+), 21 deletions(-) rename Mesures/humidity/solar-grafana/{ => goodies}/set_time.lua (75%) rename Mesures/humidity/solar-grafana/{ => goodies}/telnet_srv2.lua (100%) diff --git a/Mesures/humidity/solar-grafana/0_1_htu21d.lua b/Mesures/humidity/solar-grafana/0_1_htu21d.lua index 72526fb..1e93afe 100644 --- a/Mesures/humidity/solar-grafana/0_1_htu21d.lua +++ b/Mesures/humidity/solar-grafana/0_1_htu21d.lua @@ -2,7 +2,7 @@ -- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt function readHTU21D() - if verbose then print("\n 0_1_htu21d.lua zf200524.1915 \n") end + if verbose then print("\n 0_1_htu21d.lua zf200525.1153 \n") end if verbose then print("1readHTU21D: "..ztime_stamp()) end id = 0 sda = 5 scl = 6 addr = 0x40 @@ -37,6 +37,7 @@ function readHTU21D() id=nil addr=nil HUMIDITY=nil TEMPERATURE=nil r=nil read_HTU21D=nil readTemp=nil readHumi=nil readHTU21D=nil if verbose then print("End 1_htu21d:\n"..node.heap()) end + if verbose then print("1readHTU21D: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end end diff --git a/Mesures/humidity/solar-grafana/0_2_htu21d.lua b/Mesures/humidity/solar-grafana/0_2_htu21d.lua index 24ea5bd..f886a90 100644 --- a/Mesures/humidity/solar-grafana/0_2_htu21d.lua +++ b/Mesures/humidity/solar-grafana/0_2_htu21d.lua @@ -2,7 +2,7 @@ -- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt function readHTU21D() - if verbose then print("\n 0_2_htu21d.lua zf200524.1915 \n") end + if verbose then print("\n 0_2_htu21d.lua zf200525.1154 \n") end if verbose then print("2readHTU21D: "..ztime_stamp()) end id = 0 sda = 5 scl = 7 addr = 0x40 @@ -37,6 +37,7 @@ function readHTU21D() id=nil addr=nil HUMIDITY=nil TEMPERATURE=nil r=nil read_HTU21D=nil readTemp=nil readHumi=nil readHTU21D=nil if verbose then print("End 2_htu21d:\n"..node.heap()) end + if verbose then print("2readHTU21D: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end end diff --git a/Mesures/humidity/solar-grafana/0_cron.lua b/Mesures/humidity/solar-grafana/0_cron.lua index 8fbcac4..33dce85 100644 --- a/Mesures/humidity/solar-grafana/0_cron.lua +++ b/Mesures/humidity/solar-grafana/0_cron.lua @@ -29,9 +29,10 @@ cron1:alarm(10*1000, tmr.ALARM_AUTO, function() ztemp1=nil zhum1=nil ztemp2=nil zhum2=nil - --f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end + f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end if verbose then print("End cron:\n"..node.heap()) end + if verbose then print("cron1: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end end) diff --git a/Mesures/humidity/solar-grafana/0_http_post.lua b/Mesures/humidity/solar-grafana/0_http_post.lua index 2410d20..9042312 100644 --- a/Mesures/humidity/solar-grafana/0_http_post.lua +++ b/Mesures/humidity/solar-grafana/0_http_post.lua @@ -1,7 +1,7 @@ -- Petit script pour envoyer en // es valeurs sur un serveur WEB (InfluxDB) -- via un http POST à travers un FIFO -if verbose then print("\n 0_http_post.lua zf200524.1915 \n") end +if verbose then print("\n 0_http_post.lua zf200525.1153 \n") end t_zurl={} t_zarg={} f_zpost=false @@ -25,6 +25,7 @@ function zpost() zpost() end if verbose then print("End zpost:\n"..node.heap()) end + if verbose then print("zpost: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end @@ -38,6 +39,7 @@ function http_post(zurl,zarg) print("t_zurl:") tprint(t_zurl) print("t_zarg:") tprint(t_zarg) if f_zpost==false then zpost() end if verbose then print("End http_post:\n"..node.heap()) end + if verbose then print("http_post: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end end diff --git a/Mesures/humidity/solar-grafana/0_zdyndns.lua b/Mesures/humidity/solar-grafana/0_zdyndns.lua index 6cb5e48..f662113 100644 --- a/Mesures/humidity/solar-grafana/0_zdyndns.lua +++ b/Mesures/humidity/solar-grafana/0_zdyndns.lua @@ -1,7 +1,8 @@ -- Petit script pour s'inregistrer sur zdyndns function send_zdyndns() - if verbose then print("\n 0_zdyndns.lua zf200229.1816 \n") end + if verbose then print("\n 0_zdyndns.lua zf200525.1237 \n") end + if verbose then print("send_zdyndns: "..ztime_stamp()) end zip = wifi.sta.getip() zdyndns_str = "s "..node_id..","..console_host..":"..tostring(console_port).." "..zip.."\n" @@ -21,6 +22,7 @@ function send_zdyndns() if verbose then print("close...") end zdyndns_str=nil zip=nil srv_zdyndns=nil send_zdyndns=nil if verbose then print("End zdyndns:\n"..node.heap()) end + if verbose then print("send_zdyndns: "..ztime_stamp()) end collectgarbage() if verbose then print(node.heap()) end end) diff --git a/Mesures/humidity/solar-grafana/boot.lua b/Mesures/humidity/solar-grafana/boot.lua index e5c559c..ca815a4 100644 --- a/Mesures/humidity/solar-grafana/boot.lua +++ b/Mesures/humidity/solar-grafana/boot.lua @@ -1,24 +1,32 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot.lua zf200524.1922 \n") +print("\n boot.lua zf200525.1229 \n") + +function ztime_stamp() return tmr.now()/1000000 end function boot() verbose = true print("On lance le boot...") + print("boot: "..ztime_stamp()) print(node.heap()) collectgarbage() print(node.heap()) - f = "set_time.lua" if file.exists(f) then dofile(f) end + f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end + print(node.heap()) collectgarbage() print(node.heap()) f = "0_http_post.lua" if file.exists(f) then dofile(f) end + print(node.heap()) collectgarbage() print(node.heap()) - --f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end f="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end + print(node.heap()) collectgarbage() print(node.heap()) + f="0_cron.lua" if file.exists(f) then dofile(f) end + print(node.heap()) collectgarbage() print(node.heap()) --f = "web_ide2.lua" if file.exists(f) then dofile(f) end print("verbose:",verbose) print("boot lancé...") + print("boot: "..ztime_stamp()) print(node.heap()) collectgarbage() print(node.heap()) f=nil boot=nil end diff --git a/Mesures/humidity/solar-grafana/set_time.lua b/Mesures/humidity/solar-grafana/goodies/set_time.lua similarity index 75% rename from Mesures/humidity/solar-grafana/set_time.lua rename to Mesures/humidity/solar-grafana/goodies/set_time.lua index a3f027c..cdacb47 100644 --- a/Mesures/humidity/solar-grafana/set_time.lua +++ b/Mesures/humidity/solar-grafana/goodies/set_time.lua @@ -1,7 +1,7 @@ -- Scripts pour régler l'horloge quand on est connecté en WIFI -- Permet aussi de 'compresser' le unix time afin de prendre moins de place dans les strings -print("\n set_time.lua zf200524.1914 \n") +print("\n set_time.lua zf200525.1147 \n") --source: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html @@ -26,21 +26,12 @@ end function ztime_stamp() sec, usec = rtctime.get() - return (ztime_format(sec).."."..usec) + return (ztime_format(sec)..string.format(".%06d", usec)) end set_time() -tmr.create():alarm(2*1000, tmr.ALARM_SINGLE, function() - print(ztime_format(rtctime.get())) +tmr.create():alarm(3*1000, tmr.ALARM_SINGLE, function() + print("ztime_stamp: "..ztime_stamp()) end) - - ---[[ -sec, usec = rtctime.get() print(ztime_format(sec).."."..usec) - - -]] - - diff --git a/Mesures/humidity/solar-grafana/telnet_srv2.lua b/Mesures/humidity/solar-grafana/goodies/telnet_srv2.lua similarity index 100% rename from Mesures/humidity/solar-grafana/telnet_srv2.lua rename to Mesures/humidity/solar-grafana/goodies/telnet_srv2.lua