Commencé à calculer la puissance électrique. Je ne l'envoie pas encore à Thingspeak :-(
@@ -1,5 +1,5 @@
|
||||
-- Lit le capteur LDR pour mesurer la consommation électrique du compteur de la maison
|
||||
print("\n 0_get_energy.lua zf190803.2138 \n")
|
||||
print("\n 0_get_energy.lua zf190805.1038 \n")
|
||||
|
||||
-- lecture: https://thingspeak.com/channels/802784/private_show
|
||||
|
||||
@@ -8,13 +8,22 @@ local zledbleue=0 --led bleue
|
||||
|
||||
gpio.mode(ldr_pin, gpio.INT, gpio.FLOAT)
|
||||
|
||||
zt1_energy = tmr.now()
|
||||
zt2_energy = tmr.now()
|
||||
|
||||
function get_energy()
|
||||
if gpio.read(ldr_pin)==0 then
|
||||
zled_state="OFF"
|
||||
gpio.write(zledbleue, gpio.HIGH)
|
||||
zt1_energy = tmr.now()
|
||||
else
|
||||
zled_state="ON"
|
||||
gpio.write(zledbleue, gpio.LOW)
|
||||
zt2_energy = tmr.now()
|
||||
zt_energy = (zt2_energy-zt1_energy)/1000000
|
||||
print("Durée ".. zt_energy)
|
||||
zpuissance = math.floor(3600/zt_energy)/1000
|
||||
print("Puissance ".. zpuissance.."kW")
|
||||
end
|
||||
print("btn_led: "..zled_state)
|
||||
-- disp_send()
|
||||
@@ -28,3 +37,4 @@ get_energy()
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
node.restart()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf190803.2137 \n")
|
||||
print("\n boot.lua zf190805.1042 \n")
|
||||
|
||||
function heartbeat()
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -24,7 +24,7 @@ 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_energy.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
|
||||
|
||||
@@ -34,4 +34,3 @@ heartbeat=nil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 940 KiB After Width: | Height: | Size: 940 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 210 KiB |