From 8515670cc87e5ba20da8118e18f69000fe74f95e Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 24 May 2020 17:28:33 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=C3=A9=20un=20time=20stamp=20aux=20routine?= =?UTF-8?q?s=20principales=20pour=20le=20profiling,=20ne=20marche=20pas=20?= =?UTF-8?q?encore=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 | 11 ++++++++++- Mesures/humidity/solar-grafana/0_http_post.lua | 4 +++- Mesures/humidity/solar-grafana/boot.lua | 6 ++++-- .../humidity/solar-grafana/{goodies => }/set_time.lua | 6 +++++- 6 files changed, 26 insertions(+), 7 deletions(-) rename Mesures/humidity/solar-grafana/{goodies => }/set_time.lua (87%) diff --git a/Mesures/humidity/solar-grafana/0_1_htu21d.lua b/Mesures/humidity/solar-grafana/0_1_htu21d.lua index 826c563..60120ed 100644 --- a/Mesures/humidity/solar-grafana/0_1_htu21d.lua +++ b/Mesures/humidity/solar-grafana/0_1_htu21d.lua @@ -2,7 +2,8 @@ -- 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 zf200523.1816 \n") end + if verbose then print("\n 0_1_htu21d.lua zf200524.1656 \n") end + if verbose then print("1readHTU21D: "..ztime_format(rtctime.get())) end id = 0 sda = 5 scl = 6 addr = 0x40 HUMIDITY = 0xE5 TEMPERATURE = 0xE3 diff --git a/Mesures/humidity/solar-grafana/0_2_htu21d.lua b/Mesures/humidity/solar-grafana/0_2_htu21d.lua index 79664bb..5430191 100644 --- a/Mesures/humidity/solar-grafana/0_2_htu21d.lua +++ b/Mesures/humidity/solar-grafana/0_2_htu21d.lua @@ -2,7 +2,8 @@ -- 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 zf200523.1839 \n") end + if verbose then print("\n 0_2_htu21d.lua zf200524.1657 \n") end + if verbose then print("2readHTU21D: "..ztime_format(rtctime.get())) end id = 0 sda = 5 scl = 7 addr = 0x40 HUMIDITY = 0xE5 TEMPERATURE = 0xE3 diff --git a/Mesures/humidity/solar-grafana/0_cron.lua b/Mesures/humidity/solar-grafana/0_cron.lua index 04177f4..c578fda 100644 --- a/Mesures/humidity/solar-grafana/0_cron.lua +++ b/Mesures/humidity/solar-grafana/0_cron.lua @@ -1,5 +1,5 @@ -- Petit script pour faire office de crontab pour les mesures -print("\n 0_cron.lua zf200524.1416 \n") +print("\n 0_cron.lua zf200524.1728 \n") function tprint(t) @@ -14,6 +14,7 @@ ztemp1=20 zhum1=40 ztemp2=20 zhum2=40 cron1=tmr.create() cron1:alarm(10*1000, tmr.ALARM_AUTO, function() if verbose then print("cron1........................") end + if verbose then print("cron1: "..ztime_format(rtctime.get())) end if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end http_post(influxdb_url,"energy,memory=cron1 ram="..node.heap()) @@ -38,4 +39,12 @@ end) --[[ cron1:stop() cron1:start() + +sec, usec = rtctime.get() +print(sec,usec) + +print(ztime_format(rtctime.get())) + + + ]] diff --git a/Mesures/humidity/solar-grafana/0_http_post.lua b/Mesures/humidity/solar-grafana/0_http_post.lua index 23719ba..6c20744 100644 --- a/Mesures/humidity/solar-grafana/0_http_post.lua +++ b/Mesures/humidity/solar-grafana/0_http_post.lua @@ -1,12 +1,13 @@ -- 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.1336 \n") end +if verbose then print("\n 0_http_post.lua zf200524.1656 \n") end t_zurl={} t_zarg={} f_zpost=false function zpost() f_zpost=true zurl=t_zurl[1] zarg=t_zarg[1] + if verbose then print("zpost: "..ztime_format(rtctime.get())) end if verbose then print("zurl: "..zurl) end if verbose then print("zarg: "..zarg) end http.post(zurl, 'Content-Type: application/x-www-form-urlencoded\r\n', zarg, function(code, data) @@ -32,6 +33,7 @@ end function http_post(zurl,zarg) + if verbose then print("http_post: "..ztime_format(rtctime.get())) end table.insert(t_zurl, zurl) table.insert(t_zarg, zarg) print("t_zurl:") tprint(t_zurl) print("t_zarg:") tprint(t_zarg) if f_zpost==false then zpost() end diff --git a/Mesures/humidity/solar-grafana/boot.lua b/Mesures/humidity/solar-grafana/boot.lua index b255e7b..0b63eff 100644 --- a/Mesures/humidity/solar-grafana/boot.lua +++ b/Mesures/humidity/solar-grafana/boot.lua @@ -1,17 +1,19 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot.lua zf200524.1357 \n") +print("\n boot.lua zf200524.1712 \n") function boot() verbose = true print("On lance le boot...") print(node.heap()) collectgarbage() print(node.heap()) + f = "set_time.lua" if file.exists(f) then dofile(f) end + f = "0_http_post.lua" if file.exists(f) then dofile(f) end --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 - f="0_cron.lua" if file.exists(f) then dofile(f) end + --f="0_cron.lua" if file.exists(f) then dofile(f) end --f = "web_ide2.lua" if file.exists(f) then dofile(f) end diff --git a/Mesures/humidity/solar-grafana/goodies/set_time.lua b/Mesures/humidity/solar-grafana/set_time.lua similarity index 87% rename from Mesures/humidity/solar-grafana/goodies/set_time.lua rename to Mesures/humidity/solar-grafana/set_time.lua index 8b12174..4883c25 100644 --- a/Mesures/humidity/solar-grafana/goodies/set_time.lua +++ b/Mesures/humidity/solar-grafana/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 zf191030.2026 \n") +print("\n set_time.lua zf200524.1711 \n") --source: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html @@ -31,6 +31,10 @@ tmr.create():alarm(2*1000, tmr.ALARM_SINGLE, function() end) +--[[ +sec, usec = rtctime.get() print(ztime_format(sec).."."..usec) +]] +