Calcul maintenant le pourcentage de remplissage du bidon. Mais le calcul n'est pas encore juste :-(
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
-- Petit script pour faire office de crontab pour les mesures
|
||||
print("\n 0_cron.lua zf200627.1824 \n")
|
||||
print("\n 0_cron.lua zf200628.1312 \n")
|
||||
|
||||
cron1=tmr.create()
|
||||
cron1:alarm(20*1000, tmr.ALARM_AUTO, function()
|
||||
cron1:alarm(3*1000, tmr.ALARM_AUTO, function()
|
||||
-- if verbose then print("cron1........................") end
|
||||
-- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
|
||||
|
||||
@@ -18,7 +18,11 @@ cron1:alarm(20*1000, tmr.ALARM_AUTO, function()
|
||||
-- if yellow_id == 64 then http_post(influxdb_url,"energy,compteur=4 puissance="..zpower/1000) end
|
||||
|
||||
|
||||
if yellow_id == 69 then http_post(influxdb_url,"bolo_ruru,capteur="..node_id.." hauteur="..zlength) end
|
||||
if yellow_id == 69 then
|
||||
local zmes="bolo_ruru,capteur="..node_id.." level="..zlevel
|
||||
zmes=zmes.."\n".."bolo_ruru,capteur="..node_id.." hauteur="..zlength_brut
|
||||
http_post(influxdb_url,zmes)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
-- 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 zf200627.1846 \n")
|
||||
print("\n 0_ultra_son.lua zf200628.1344 \n")
|
||||
|
||||
speed_air = 382
|
||||
zlength_min = 0.15
|
||||
zlength_max = 0.62
|
||||
speed_air = 382 -- en m/s
|
||||
zlength_min = 20 -- en cm
|
||||
zlength_max = 61 -- en cm
|
||||
|
||||
zlength_brut = 0
|
||||
zlength = (zlength_min+zlength_max)/2
|
||||
zlength_1, zlength_2, zlength_3 = zlength,zlength,zlength
|
||||
|
||||
zlevel = 50 -- en %
|
||||
|
||||
--Paramètres pour le module ultra son
|
||||
local ztrig=5
|
||||
gpio.mode(ztrig, gpio.OUTPUT)
|
||||
@@ -24,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,{10,1})
|
||||
gpio.serout(ztrig,gpio.HIGH,{2,1})
|
||||
end
|
||||
|
||||
--Fonction pour mesurer la pulse
|
||||
@@ -34,23 +37,23 @@ function zmesure()
|
||||
else
|
||||
ultra_son_stop=tmr.now()
|
||||
-- print("Delta: "..ultra_son_stop-ultra_son_start)
|
||||
zlength=math.floor(speed_air*(ultra_son_stop-ultra_son_start)/2/10000)/100
|
||||
--zlength=speed_air*(ultra_son_stop-ultra_son_start)/2/10000
|
||||
if zlength>zlength_max then zlength=zlength_max end
|
||||
if zlength<zlength_min then zlength=zlength_min end
|
||||
zlength_brut = math.floor(speed_air*(ultra_son_stop-ultra_son_start)/2/10000)
|
||||
zlength = zlength_brut
|
||||
|
||||
zlength_3= zlength_2 zlength_2= zlength_1 zlength_1= zlength
|
||||
zlength = (zlength_1+zlength_2+zlength_3)/3
|
||||
if zlength>zlength_max then zlength = zlength_max end
|
||||
if zlength<zlength_min then zlength = zlength_min end
|
||||
|
||||
disp_mesure()
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
gpio.trig(zecho,"both",zmesure)
|
||||
|
||||
-- à commenter après les tests de calibration
|
||||
function disp_mesure() print("La distance est de "..zlength.."m") end
|
||||
|
||||
tmr_mesure=tmr.create()
|
||||
tmr_mesure:alarm(1*1000, tmr.ALARM_AUTO, zmesure_pulse)
|
||||
tmr_mesure:alarm(2*1000, tmr.ALARM_AUTO, zmesure_pulse)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
|
||||
# zf200625.1133
|
||||
# zf200628.1329
|
||||
|
||||
|
||||
Todo à faire pour ce projet !
|
||||
@@ -15,14 +15,13 @@ Todo à faire pour ce projet !
|
||||
# ALT+CMD+F bascule entre le terminal et l'éditeur
|
||||
|
||||
# définitions à faire AVANT !
|
||||
export luatool_tty="/dev/cu.wchusbserial1410"
|
||||
#export luatool_tty="/dev/cu.wchusbserial1410"
|
||||
|
||||
export zIP="192.168.0.182"
|
||||
export zport="23"
|
||||
#export zIP="192.168.0.182"
|
||||
#export zport="23"
|
||||
|
||||
export zIP="localhost"
|
||||
export zport="23000"
|
||||
ATTENTION: voir les tunnels tout à la fin !
|
||||
|
||||
|
||||
# ouvrir et fermer (ALT+N+.) une session telnet sur le NodeMCU avec l'adresse zIP)
|
||||
@@ -58,10 +57,12 @@ ssh -N -L 23000:localhost:23000 ubuntu@www.zuzu-test.ml &
|
||||
|
||||
telnet -rN $zIP $zport
|
||||
|
||||
verbose=false
|
||||
=node.heap()
|
||||
~.
|
||||
|
||||
verbose=false
|
||||
verbose=true
|
||||
node.restart()
|
||||
|
||||
= node.bootreason()
|
||||
# https://nodemcu.readthedocs.io/en/master/modules/node/#nodebootreason
|
||||
@@ -74,8 +75,8 @@ verbose=true
|
||||
./luatool.py --ip $zIP:$zport -f 0_get_power.lua
|
||||
./luatool.py --ip $zIP:$zport -f 0_cron.lua
|
||||
./luatool.py --ip $zIP:$zport -f 0_http_post.lua
|
||||
./luatool.py --ip $zIP:$zport -f 0_htu21d.lua
|
||||
./luatool.py --ip $zIP:$zport -f 0_tst4_socat.lua
|
||||
./luatool.py --ip $zIP:$zport -f 0_ultra_son.lua
|
||||
|
||||
./luatool.py --ip $zIP:$zport --zrestart
|
||||
|
||||
|
||||
Reference in New Issue
Block a user