Ajouté une fonction btn verbose afin de pouvoir éteindre le clignotement de la LED depuis le bouton
This commit is contained in:
26
Mesures/humidity/bolo-thingspeak/0_btn_flipflop.lua
Normal file
26
Mesures/humidity/bolo-thingspeak/0_btn_flipflop.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
-- Petit scripts pour faire un flip flop avec le bouton et la led du nodemcu
|
||||||
|
-- Très intéressant la techno utilisée ici pour enlever les rebonds du micro switch
|
||||||
|
-- dans la variable b se trouve l'heure à laquelle l'interruption est arrivée, il suffit juste alors de lui mettre un petit délai de 300mS
|
||||||
|
|
||||||
|
print("\n 0_btn_flipflop.lua zf200119.1527 \n")
|
||||||
|
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
gpio.mode(zLED,gpio.OUTPUT)
|
||||||
|
gpio.mode(zBTN,gpio.INT)
|
||||||
|
|
||||||
|
d=tmr.now()
|
||||||
|
|
||||||
|
function zled (a,b,c)
|
||||||
|
if verbose then print("a: "..a..",b: "..b..",c: "..c) end
|
||||||
|
if b-d > 300*1000 then
|
||||||
|
if verbose then
|
||||||
|
gpio.write(zLED,1) verbose=false
|
||||||
|
else
|
||||||
|
gpio.write(zLED,0) verbose=true
|
||||||
|
end
|
||||||
|
if verbose then print(gpio.read(zLED)) end
|
||||||
|
d=b
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.trig(zBTN, "down", zled)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
-- Lit le capteur I2C HTU21D de mesure d'humidité et de température
|
-- Lit le capteur I2C HTU21D de mesure d'humidité et de température
|
||||||
print("\n 0_htu21d.lua zf200119.1426 \n")
|
|
||||||
|
|
||||||
-- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt
|
-- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt
|
||||||
|
|
||||||
function readHTU21D()
|
function readHTU21D()
|
||||||
|
if verbose then print("\n 0_htu21d.lua zf200119.1517 \n") end
|
||||||
|
|
||||||
id = 0 sda = 5 scl = 6 addr = 0x40
|
id = 0 sda = 5 scl = 6 addr = 0x40
|
||||||
HUMIDITY = 0xE5 TEMPERATURE = 0xE3
|
HUMIDITY = 0xE5 TEMPERATURE = 0xE3
|
||||||
i2c.setup(id, sda, scl, i2c.SLOW) sda = nil scl = nil
|
i2c.setup(id, sda, scl, i2c.SLOW) sda = nil scl = nil
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
-- Petit script pour envoyer les valeurs de température sur un serveur WEB via un HTTP GET
|
-- Petit script pour envoyer les valeurs de température sur un serveur WEB via un HTTP GET
|
||||||
print("\n 0_send_data.lua zf200119.1433 \n")
|
|
||||||
|
|
||||||
function send_data()
|
function send_data()
|
||||||
|
if verbose then print("\n 0_send_data.lua zf200119.1518 \n") end
|
||||||
|
|
||||||
if verbose then print("send_data_web: ") end
|
if verbose then print("send_data_web: ") end
|
||||||
if verbose then print(zurl) end
|
if verbose then print(zurl) end
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ function boot()
|
|||||||
zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1)
|
zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1)
|
||||||
f="0_send_data.lua" if file.exists(f) then dofile(f) end
|
f="0_send_data.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="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end
|
||||||
|
|
||||||
--f = "web_ide2.lua" if file.exists(f) then dofile(f) end
|
--f = "web_ide2.lua" if file.exists(f) then dofile(f) end
|
||||||
|
|
||||||
f=nil boot=nil
|
f=nil boot=nil
|
||||||
|
|||||||
Reference in New Issue
Block a user