From 657af220be8f292fbd44fe72407e85502e332acd Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Wed, 24 Jun 2020 19:25:18 +0200 Subject: [PATCH] =?UTF-8?q?Configur=C3=A9=20les=20bons=20secrets=20pour=20?= =?UTF-8?q?ce=20projet,=20mais=20la=20mesure=20de=20distance=20ne=20foncti?= =?UTF-8?q?onne=20pas=20encore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/level/level_ruru_1/0_cron.lua | 14 ++++++-- Mesures/level/level_ruru_1/0_ultra_son.lua | 38 +++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Mesures/level/level_ruru_1/0_cron.lua b/Mesures/level/level_ruru_1/0_cron.lua index a01b696..7c384c7 100644 --- a/Mesures/level/level_ruru_1/0_cron.lua +++ b/Mesures/level/level_ruru_1/0_cron.lua @@ -1,5 +1,5 @@ -- Petit script pour faire office de crontab pour les mesures -print("\n 0_cron.lua zf200621.1936 \n") +print("\n 0_cron.lua zf200621.1922 \n") cron1=tmr.create() cron1:alarm(10*1000, tmr.ALARM_AUTO, function() @@ -7,7 +7,7 @@ cron1:alarm(10*1000, tmr.ALARM_AUTO, function() -- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end - rt_launch() + -- rt_launch() -- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1") @@ -15,7 +15,15 @@ cron1:alarm(10*1000, tmr.ALARM_AUTO, function() -- http_post(influxdb_url,"energy,memory=cron1_"..yellow_id.." ram="..node.heap()) -- if yellow_id == 60 then http_post(influxdb_url,"energy,compteur=3 puissance="..zpower/1000) end - if yellow_id == 64 then http_post(influxdb_url,"energy,compteur=4 puissance="..zpower/1000) end + -- 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 + + + + + -- http_post(influxdb_url,"energy,value=test2_"..yellow_id.." val=2") -- http_post(influxdb_url,"energy,value=test3_"..yellow_id.." val=3") diff --git a/Mesures/level/level_ruru_1/0_ultra_son.lua b/Mesures/level/level_ruru_1/0_ultra_son.lua index dcb91f7..ef51338 100644 --- a/Mesures/level/level_ruru_1/0_ultra_son.lua +++ b/Mesures/level/level_ruru_1/0_ultra_son.lua @@ -1,7 +1,7 @@ -- Mesure la distance avec le module ultra-son -print("\n ultra_son.lua zf181026.1355 \n") +print("\n 0_ultra_son.lua zf200624.1910 \n") ---Parametres pour le module ultra son +--Paramètres pour le module ultra son local ztrig=5 gpio.mode(ztrig, gpio.OUTPUT) local fast_write = gpio.write @@ -18,37 +18,37 @@ local ultra_son_stop=0 --Function pour envoyer la pulse function zmesure_pulse() ---t1=tmr.now() --- fast_write(ztrig, 1) --- fast_write(ztrig, 0) - ---gpio.serout(ztrig,gpio.LOW,{1,10}) -gpio.serout(ztrig,gpio.HIGH,{10,1}) - ---t2=tmr.now() ---print("durée: "..t2-t1-314) + --t1=tmr.now() + -- fast_write(ztrig, 1) + -- fast_write(ztrig, 0) + + --gpio.serout(ztrig,gpio.LOW,{1,10}) + gpio.serout(ztrig,gpio.HIGH,{10,1}) + + --t2=tmr.now() + --print("durée: "..t2-t1-314) end --Fonction pour mesurer la pulse function zmesure() ---print("pin: "..gpio.read(zecho)) + --print("pin: "..gpio.read(zecho)) if fast_read(zecho)==1 then ultra_son_start=tmr.now() else ultra_son_stop=tmr.now() -print("Delta: "..ultra_son_stop-ultra_son_start) --- zlength=math.floor(480*(ultra_son_stop-ultra_son_start)/2/10000)/100 + print("Delta: "..ultra_son_stop-ultra_son_start) + -- zlength=math.floor(480*(ultra_son_stop-ultra_son_start)/2/10000)/100 zlength=480*(ultra_son_stop-ultra_son_start)/2/10000 --- if zlength>6 then zlength=0 end + -- if zlength>6 then zlength=0 end disp_mesure() end end gpio.trig(zecho,"both",zmesure) - - -- à commenter après les tests de perf -function disp_mesure() print(zlength) end -tmr.alarm(detectortimer1, 1000, tmr.ALARM_AUTO, zmesure_pulse) +function disp_mesure() print("La distance est de "..zlength.."cm") end + +tmr_mesure=tmr.create() +tmr_mesure:alarm(1*1000, tmr.ALARM_AUTO, zmesure_pulse)