Voilà, mon niveau d'eau en pourcentage est enfin correct, ouf !

This commit is contained in:
Christian Zufferey
2020-06-28 14:56:36 +02:00
parent e9ea5a978d
commit d41b389e1b
2 changed files with 23 additions and 19 deletions

View File

@@ -1,17 +1,17 @@
-- Mesure la distance avec le module ultra-son de 15cm à 2m
-- Attention le module à ultra-son doit être alimenté en 5V !
print("\n 0_ultra_son.lua zf200628.1344 \n")
print("\n 0_ultra_son.lua zf200628.1448 \n")
speed_air = 382 -- en m/s
zlength_min = 20 -- en cm
zlength_max = 61 -- en cm
zlength_min = 12 -- en cm
zlength_max = 56 -- en cm
zlength_brut = 0
zlength = (zlength_min+zlength_max)/2
zlength = 9
zlength_1, zlength_2, zlength_3 = zlength,zlength,zlength
zlevel = 50 -- en %
zlevel = 0
--Paramètres pour le module ultra son
local ztrig=5
@@ -27,7 +27,7 @@ local ultra_son_start, ultra_son_stop = 0,0
--Function pour envoyer la pulse
function zmesure_pulse()
gpio.serout(ztrig,gpio.HIGH,{2,1})
gpio.serout(ztrig,gpio.HIGH,{3,1})
end
--Fonction pour mesurer la pulse
@@ -38,17 +38,17 @@ function zmesure()
ultra_son_stop=tmr.now()
-- print("Delta: "..ultra_son_stop-ultra_son_start)
zlength_brut = math.floor(speed_air*(ultra_son_stop-ultra_son_start)/2/10000)
if zlength_brut>zlength_max then zlength_brut = zlength end
if zlength_brut<zlength_min then zlength_brut = zlength end
zlength = zlength_brut
if zlength>zlength_max then zlength = zlength_max end
if zlength<zlength_min then zlength = zlength_min end
zlength_3 = zlength_2 zlength_2 = zlength_1 zlength_1 = zlength
zlength = math.floor((zlength_1+zlength_2+zlength_3)/3)
zlevel = 100-math.floor((zlength-zlength_min)/(zlength_max-zlength_min)*100)
if verbose then print("La distance est de "..zlength.."cm, "..zlevel.."%") end
if verbose then print("Hauteur brute: "..zlength_brut.."cm, net: "..zlength.."cm , "..zlevel.."%") end
end
end

View File

@@ -58,19 +58,12 @@ ssh -N -L 23000:localhost:23000 ubuntu@www.zuzu-test.ml &
telnet -rN $zIP $zport
verbose=false
=node.heap()
~.
=node.heap()
verbose=true
node.restart()
= node.bootreason()
# https://nodemcu.readthedocs.io/en/master/modules/node/#nodebootreason
for k,v in pairs(_G) do print(k,v) end
verbose=true
#zdyn
./luatool.py --ip $zIP:$zport -f boot.lua
./luatool.py --ip $zIP:$zport -f 0_get_power.lua
./luatool.py --ip $zIP:$zport -f 0_cron.lua
@@ -80,6 +73,17 @@ verbose=true
./luatool.py --ip $zIP:$zport --zrestart
= node.bootreason()
# https://nodemcu.readthedocs.io/en/master/modules/node/#nodebootreason
for k,v in pairs(_G) do print(k,v) end
verbose=true
#zdyn
./luatool.py --ip $zIP:$zport -f api_sonoff.html
http://192.168.0.182