diff --git a/Mesures/energy/0_get_energy.lua b/Mesures/energy/0_get_energy.lua index 2fcea1a..fba1b5f 100644 --- a/Mesures/energy/0_get_energy.lua +++ b/Mesures/energy/0_get_energy.lua @@ -1,34 +1,30 @@ --- Lit le capteur de température solaire en fonction de son field qui se trouve dans les secrets ! -print("\n 0_get_temp.lua zf190728.1014 \n") +-- Lit le capteur LDR pour mesurer la consommation électrique du compteur de la maison +print("\n 0_get_energy.lua zf190803.2138 \n") -- lecture: https://thingspeak.com/channels/802784/private_show --- source: https://nodemcu.readthedocs.io/en/master/modules/ds18b20/ -local ow_pin = 3 -ds18b20.setup(ow_pin) +local ldr_pin = 2 -- pin de la LDR +local zledbleue=0 --led bleue -function get_temp() - ds18b20.read( - function(ind,rom,res,temp,tdec,par) - print(ind, temp, zfield) - if zfield == 1 then - ztemp1 = temp - zurl=hub_url.."field1="..tostring(ztemp1) - send_temp() - elseif zfield == 2 then - ztemp2 = temp - elseif zfield == 3 then - ztemp3 = temp - zurl=hub_url.."field3="..tostring(ztemp3) - send_temp() - end - print(ztemp1, ztemp2, ztemp3) - end,{}) +gpio.mode(ldr_pin, gpio.INT, gpio.FLOAT) + +function get_energy() + if gpio.read(ldr_pin)==0 then + zled_state="OFF" + gpio.write(zledbleue, gpio.HIGH) + else + zled_state="ON" + gpio.write(zledbleue, gpio.LOW) + end + print("btn_led: "..zled_state) +-- disp_send() end +gpio.trig(ldr_pin, "both", get_energy) + --[[ -get_temp() +get_energy() ]] diff --git a/Mesures/energy/boot.lua b/Mesures/energy/boot.lua index d432a99..e1ae4ed 100644 --- a/Mesures/energy/boot.lua +++ b/Mesures/energy/boot.lua @@ -1,6 +1,6 @@ -- Scripts à charger après le boot pour démarrer son appli -print("\n boot.lua zf190803.1908 \n") +print("\n boot.lua zf190803.2137 \n") function heartbeat() f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end @@ -24,13 +24,13 @@ f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end f= "web_ide2.lua" if file.exists(f) then dofile(f) end f= "web_srv2.lua" if file.exists(f) then dofile(f) end ---f= "0_get_temp.lua" if file.exists(f) then dofile(f) end +f= "0_get_energy.lua" if file.exists(f) then dofile(f) end --f= "0_send_temp.lua" if file.exists(f) then dofile(f) end --f= "0_cron_temp.lua" if file.exists(f) then dofile(f) end f=nil ---heartbeat=nil -heartbeat() +heartbeat=nil +--heartbeat()