Cela va mieux, mais ça n'envoie pas automatiquement vie le crontab :-(
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
-- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt
|
||||
|
||||
function readHTU21D()
|
||||
if verbose then print("\n 0_1_htu21d.lua zf200523.1408 \n") end
|
||||
if verbose then print("\n 0_1_htu21d.lua zf200523.1642 \n") end
|
||||
|
||||
id = 0 sda = 5 scl = 6 addr = 0x40
|
||||
HUMIDITY = 0xE5 TEMPERATURE = 0xE3
|
||||
@@ -40,4 +40,4 @@ function readHTU21D()
|
||||
if verbose then print(node.heap()) end
|
||||
end
|
||||
|
||||
readHTU21D()
|
||||
--readHTU21D()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- https://github.com/zuzu59/NodeMCU_Lua/tree/master/Mesures/humidity/bolo-thingspeak/docu/HTU21D.txt
|
||||
|
||||
function readHTU21D()
|
||||
if verbose then print("\n 0_2_htu21d.lua zf200523.1408 \n") end
|
||||
if verbose then print("\n 0_2_htu21d.lua zf200523.1643 \n") end
|
||||
|
||||
id = 0 sda = 5 scl = 4 addr = 0x40
|
||||
HUMIDITY = 0xE5 TEMPERATURE = 0xE3
|
||||
@@ -40,4 +40,4 @@ function readHTU21D()
|
||||
if verbose then print(node.heap()) end
|
||||
end
|
||||
|
||||
readHTU21D()
|
||||
--readHTU21D()
|
||||
|
||||
@@ -1,22 +1,37 @@
|
||||
-- Petit script pour faire office de crontab pour les mesures
|
||||
print("\n 0_cron.lua zf200229.1557 \n")
|
||||
print("\n 0_cron.lua zf200523.1644 \n")
|
||||
|
||||
cron1=tmr.create()
|
||||
cron1:alarm(60*1000, tmr.ALARM_AUTO, function()
|
||||
cron1:alarm(5*1000, tmr.ALARM_AUTO, function()
|
||||
if verbose then print("cron1........................") end
|
||||
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
|
||||
|
||||
f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--[[
|
||||
f = "0_htu21d.lua" if file.exists(f) then dofile(f) end
|
||||
print("toto0")
|
||||
th_id=1
|
||||
print("toto1")
|
||||
f = "0_1_htu21d.lua" if file.exists(f) then dofile(f) end
|
||||
print("toto2")
|
||||
readHTU21D()
|
||||
print("toto3")
|
||||
f = "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
print("toto4")
|
||||
send_data()
|
||||
|
||||
zurl = thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1)
|
||||
print("toto5")
|
||||
th_id=2
|
||||
print("toto6")
|
||||
f = "0_2_htu21d.lua" if file.exists(f) then dofile(f) end
|
||||
print("toto7")
|
||||
readHTU21D()
|
||||
print("toto8")
|
||||
f = "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
print("toto9")
|
||||
send_data()
|
||||
print("toto10")
|
||||
|
||||
f = "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
ztemp1=nil zhum1=nil
|
||||
]]
|
||||
th_id=nil ztemp1=nil zhum1=nil
|
||||
|
||||
if verbose then print(node.heap()) end
|
||||
collectgarbage()
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
-- Petit script pour envoyer les valeurs de température sur un serveur WEB via un HTTP GET
|
||||
-- Petit script pour envoyer les valeurs sur un serveur WEB (InfluxDB)
|
||||
-- via un http GET
|
||||
|
||||
function send_data()
|
||||
if verbose then print("\n 0_send_data.lua zf200119.1518 \n") end
|
||||
if verbose then print("\n 0_send_data.lua zf200523.1643 \n") end
|
||||
|
||||
if verbose then print("send_data_web: ") end
|
||||
if verbose then print(zurl) end
|
||||
|
||||
http.get(zurl, nil, function(code, data)
|
||||
if (code < 0) then
|
||||
if verbose then print("HTTP request failed") end
|
||||
if verbose then print("zuzu", code, data) end
|
||||
else
|
||||
if verbose then print(code, data) end
|
||||
end
|
||||
zurl=nil
|
||||
function zpost(zarg)
|
||||
if verbose then print("influxdb_url: "..influxdb_url) end
|
||||
if verbose then print("zarg: "..zarg) end
|
||||
http.post(influxdb_url, 'Content-Type: application/x-www-form-urlencoded\r\n', zarg, function(code, data)
|
||||
-- print("toto")
|
||||
if (code < 0) then
|
||||
print("HTTP request failed")
|
||||
print("zuzu", code, data)
|
||||
else
|
||||
if verbose then print(code, data) end
|
||||
end
|
||||
-- print("tutu")
|
||||
end)
|
||||
zurl=nil send_data=nil
|
||||
if verbose then print(node.heap()) end
|
||||
collectgarbage()
|
||||
if verbose then print(node.heap()) end
|
||||
end
|
||||
|
||||
zpost("energy,capteur=th"..th_id.." humidity="..zhum1)
|
||||
zpost("energy,capteur=th"..th_id.." temperature="..ztemp1)
|
||||
|
||||
zarg=nil code=nil data=nil zpost=nil send_data=nil
|
||||
-- print("titi")
|
||||
end
|
||||
|
||||
--send_data()
|
||||
|
||||
--[[
|
||||
verbose=true
|
||||
send_data()
|
||||
]]
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
print("\n boot.lua zf200521.1339 \n")
|
||||
print("\n boot.lua zf200523.1611 \n")
|
||||
|
||||
function boot()
|
||||
verbose = true
|
||||
print("On lance le boot...")
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
|
||||
--f="0_htu21d.lua" if file.exists(f) then dofile(f) end
|
||||
--zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1)
|
||||
--f="0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
--f="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end
|
||||
--f="0_cron.lua" if file.exists(f) then dofile(f) end
|
||||
--f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end
|
||||
--f="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end
|
||||
--f="0_cron.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--f = "web_ide2.lua" if file.exists(f) then dofile(f) end
|
||||
print("verbose:",verbose)
|
||||
|
||||
Reference in New Issue
Block a user