Commencé à calculer la puissance électrique. Je ne l'envoie pas encore à Thingspeak :-(

This commit is contained in:
Christian Zufferey
2019-08-05 13:35:09 +02:00
parent 881e50b25a
commit be72a29187
49 changed files with 15 additions and 4 deletions

View File

@@ -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()
]]

View File

@@ -1 +1,3 @@
-- programme pour faire un test depuis de le webide
node.restart()

View File

@@ -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

View File

Before

Width:  |  Height:  |  Size: 940 KiB

After

Width:  |  Height:  |  Size: 940 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB