Complètement refactorisé mon projet de mesures de température à la maison. Cela ne marche pas car je n'ai pas encore trouvé la bonne solution au niveau lecture du web service
This commit is contained in:
35
Temp_DS18B20/temp_zf/0_send_web_temp.lua
Normal file
35
Temp_DS18B20/temp_zf/0_send_web_temp.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
-- Petit script pour envoyer les valeurs de température sur un serveur WEB via un HTTP GET
|
||||
print("\n send_web_temp.lua zf190726.1931 \n")
|
||||
|
||||
function send_temp(zserver)
|
||||
print("send_web_temp: ")
|
||||
|
||||
ztemp1=11 ztemp2=12 ztemp3=13
|
||||
|
||||
zurl=zserver.."field1="..tostring(ztemp1).."&field2="..tostring(ztemp2).."&field3="..tostring(ztemp3)
|
||||
print(zurl)
|
||||
|
||||
--[[
|
||||
http.get(zurl, nil, function(code, data)
|
||||
print("toto")
|
||||
if (code < 0) then
|
||||
print("tutu")
|
||||
print("HTTP request failed")
|
||||
print("zuzu", code, data)
|
||||
else
|
||||
print("titi")
|
||||
print(code, data)
|
||||
end
|
||||
end)
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
--disp_send()
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
send_temp(concentrator_url)
|
||||
|
||||
]]
|
||||
@@ -36,4 +36,4 @@ node ow pcm rtctime sntp spi tmr uart wifi ws2812
|
||||
https://thingspeak.com/channels/817940
|
||||
|
||||
|
||||
zf190709.2135
|
||||
zf190726.1917
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
|
||||
function a3()
|
||||
print("\n a3.lua zf190617.1135 \n")
|
||||
|
||||
end
|
||||
|
||||
a3()
|
||||
|
||||
|
||||
|
||||
|
||||
-- Petit script pour envoyer quelque chose sur un serveur WEB
|
||||
print("\n web_cli.lua zf190616.1519 \n")
|
||||
|
||||
function disp_send()
|
||||
print("web_cli: ")
|
||||
-- ztemp1=11 ztemp2=12 ztemp3=13
|
||||
|
||||
zurl=thingspeak_url_update.."field1="..tostring(ztemp1).."&field2="..tostring(ztemp2).."&field3="..tostring(ztemp3)
|
||||
print(zurl)
|
||||
http.get(zurl, nil, function(code, data)
|
||||
print("toto")
|
||||
if (code < 0) then
|
||||
print("tutu")
|
||||
print("HTTP request failed")
|
||||
print("zuzu", code, data)
|
||||
else
|
||||
print("titi")
|
||||
print(code, data)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
--disp_send()
|
||||
|
||||
|
||||
--[[
|
||||
disp_send()
|
||||
|
||||
|
||||
|
||||
]]
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf190709.2150 \n")
|
||||
print("\n boot.lua zf190726.1913 \n")
|
||||
|
||||
function heartbeat()
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -13,6 +13,11 @@ function heartbeat()
|
||||
end)
|
||||
end
|
||||
|
||||
--ses propres secrets
|
||||
f= "secrets_temp_zf_int_1er.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_temp_zf_out_nord.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_temp_zf_out_sud.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--f= "led_rgb.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "wifi_ap_start.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
-- le script repair.lua pendant xx secondes avant de continuer
|
||||
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
|
||||
|
||||
print("\n init.lua zf190601.1612 \n")
|
||||
print("\n init.lua zf190621.1612 \n")
|
||||
|
||||
zswitch=3 --switch flash
|
||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
|
||||
function wifi_cli_conf()
|
||||
print("\n wifi_cli_conf.lua zf190709.2147 \n")
|
||||
|
||||
--secrets par défaut
|
||||
--cli_ssid="3g-s7"
|
||||
cli_ssid="3G-zf"
|
||||
cli_pwd="12234567"
|
||||
|
||||
--ses propres secrets
|
||||
f= "secrets_temp_zf_int_1er.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_temp_zf_out_nord.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_temp_zf_out_sud.lua" if file.exists(f) then dofile(f) end
|
||||
print("\n wifi_cli_conf.lua zf190726.1912 \n")
|
||||
|
||||
-- les secrets sont maintenant initialisés par boot.lua !
|
||||
wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, save=true}
|
||||
end
|
||||
|
||||
wifi_cli_conf()
|
||||
wifi_cli_conf=nil
|
||||
cli_ssid=nil
|
||||
cli_pwd=nil
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 home page 190709.2214</h1>
|
||||
<h1>ESP8266 home page 190726.1953</h1>
|
||||
<h2>Différentes pages HTML:</h2>
|
||||
<h3>
|
||||
<a href="z_page1.html">Page 1, affichage de la température dynamique en code Lua inline.</a><br>
|
||||
<a href="z_page2.html">Page 2, tableau dynamique écrit en Lua inline.</a><br>
|
||||
<a href="z_page3.html">Page 3, affichage du capteur non linéaire corrigé.</a><br>
|
||||
<a href="z_page4.html?toto=123&tutu=234&titi=345">Page 4, web service concentrateur de mesures de température.</a><br>
|
||||
<a href="z_page4.html?field1=11&field2=12&field3=12">Page 4, web service concentrateur de mesures de température.</a><br>
|
||||
<a href="page_qui_existe_pag.html">Page qui n'existe pas !</a><br>
|
||||
</h3>
|
||||
</body>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 4 190709.2221</h1>
|
||||
<h1>ESP8266 page 4 190726.1955</h1>
|
||||
<br>
|
||||
Web service concentrateur de mesures de température !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
@@ -24,17 +24,26 @@
|
||||
Les arguments du web service (GET) sont:<br><br>
|
||||
<%
|
||||
if (vars ~= nil) then
|
||||
zout("<br>vars: "..vars.."<br>")
|
||||
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||
_GET[k] = v
|
||||
zout(k..": "..v.."<br>")
|
||||
if k == "field1" then
|
||||
ztemp1_conc = v
|
||||
elseif k == "field2" then
|
||||
ztemp2_conc = v
|
||||
elseif k == "field3" then
|
||||
ztemp3_conc = v
|
||||
end
|
||||
end
|
||||
end
|
||||
zout("<br>Les températures récupérées sont: "..ztemp1_conc..", "..ztemp2_conc..", "..ztemp3_conc)
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
||||
<br>Yeah... cela fonctionne vachement bien !<br><br>
|
||||
<br><br>Yeah... cela fonctionne vachement bien !<br><br>
|
||||
|
||||
<%
|
||||
zout("Il reste: "..node.heap().." de RAM !<br><br>\n")
|
||||
|
||||
Reference in New Issue
Block a user