First commit de mon nouveau projet solar_pv_energy, mesure de la production électrique de mon installation solaire PV
@@ -1,4 +1,4 @@
|
||||
# temp_zf
|
||||
# energy
|
||||
|
||||
Petit projet pour mesurer la consommation électrique en temps réel chez moi avec un NodeMCU en LUA, et l'afficher sur Grafana avec une DB InfluxDB.
|
||||
|
||||
@@ -127,7 +127,7 @@ Seulement la corrélation entre les trois température
|
||||
https://thingspeak.com/apps/plugins/300559
|
||||
|
||||
|
||||
zf190807.2100
|
||||
zf190908.2147
|
||||
|
||||
|
||||
pense bête:
|
||||
|
||||
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 583 KiB |
|
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 644 KiB |
|
Before Width: | Height: | Size: 2.8 MiB After Width: | Height: | Size: 679 KiB |
19
Mesures/solar_pv_energy/0_cron.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Petit script pour faire office de crontab pour les mesures de température
|
||||
print("\n 0_cron_temp.lua zf190728.1054 \n")
|
||||
|
||||
cron1=tmr.create()
|
||||
cron1:alarm(10*1000, tmr.ALARM_AUTO, function()
|
||||
get_temp()
|
||||
end)
|
||||
|
||||
if zfield == 2 then
|
||||
cron2=tmr.create()
|
||||
cron2:alarm(20*1000, tmr.ALARM_AUTO, function()
|
||||
print("cron2........................")
|
||||
zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(ztemp2).."&field3="..tostring(ztemp3)
|
||||
send_temp()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
||||
41
Mesures/solar_pv_energy/0_get_energy.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
-- Lit le capteur LDR pour mesurer la consommation électrique du compteur de la maison
|
||||
print("\n 0_get_energy.lua zf190807.0923 \n")
|
||||
|
||||
-- lecture: https://thingspeak.com/channels/802784/private_show
|
||||
|
||||
local ldr_pin = 2 -- pin de la LDR
|
||||
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
|
||||
if zt_energy >= 0.3 and zt_energy <= 100 then
|
||||
print("Durée ".. zt_energy)
|
||||
zpuissance = math.floor(3600/zt_energy)/1000
|
||||
print("Puissance ".. zpuissance.."kW")
|
||||
send_temp()
|
||||
end
|
||||
end
|
||||
print("btn_led: "..zled_state)
|
||||
end
|
||||
|
||||
gpio.trig(ldr_pin, "both", get_energy)
|
||||
|
||||
--[[
|
||||
|
||||
get_energy()
|
||||
|
||||
]]
|
||||
|
||||
32
Mesures/solar_pv_energy/0_send_data.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
-- Petit script pour envoyer les valeurs de température sur un serveur WEB via un http GET
|
||||
print("\n 0_send_temp.lua zf190806.1541 \n")
|
||||
|
||||
function send_temp()
|
||||
print("send_web_temp: ")
|
||||
|
||||
zurl="http://www.xxx.ml:8086/write?db=xxx&u=admin&p=xxx"
|
||||
print("zurl: "..zurl)
|
||||
|
||||
zarg="energy,compteur=1 puissance="..zpuissance
|
||||
print("zarg: "..zarg)
|
||||
|
||||
|
||||
|
||||
http.post(zurl, '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
|
||||
print(code, data)
|
||||
end
|
||||
-- print("tutu")
|
||||
end)
|
||||
-- print("titi")
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
send_temp()
|
||||
|
||||
]]
|
||||
@@ -0,0 +1 @@
|
||||
{"url": "https://docs.google.com/open?id=1FtUf-Q_QLBBVBtHr425DvN2uAinou2QF8BK8UVaSdH4", "doc_id": "1FtUf-Q_QLBBVBtHr425DvN2uAinou2QF8BK8UVaSdH4", "email": "christian.zufferey@gmail.com"}
|
||||
148
Mesures/solar_pv_energy/README.md
Normal file
@@ -0,0 +1,148 @@
|
||||
# solar_pv_energy
|
||||
|
||||
Petit projet pour mesurer la production électrique d'une installation solaire photovoltaïque monophasé avec un NodeMCU en LUA, et l'afficher sur Grafana avec une DB InfluxDB.
|
||||
|
||||

|
||||
Vue globale de mon installation solaire prototype (2x panneaux de 280W) :-)
|
||||
|
||||

|
||||
Vue des deux onduleurs (un par panneau) qui injectent le courant produit dans le réseau électrique 220V de la maison.
|
||||
|
||||

|
||||
Petit transformateur de mesure du courant avec un rapport de 1/800 !
|
||||
|
||||

|
||||
C'est mon NodeMCU de banc tests, il y a un pont diviseur pour faire une masse fictive à +0.5V qui permet de mesurer les alternances négatives du courant et la résistance *convertisseur* de courant de la mesure en tension (U=R*I).
|
||||
|
||||

|
||||
n voit ici l'image du courant d'un foehn (450W) en petite vitesse. On voit bien que la partie négative de l'alternance est effacée, c'est à cause de la mise ne série d'une diode avec le corps de chauffe, c'est un moyen très simple de diminuer le puissance dans un foehn
|
||||
|
||||

|
||||
On voit ici l'image du courant d'un foehn (450W) en grande vitesse. L'alternance est bien complète ici. On voit aussi qu'elle se trouve dans la plage des 1V du convertisseur ADC du NodeMCU.
|
||||
|
||||
|
||||
On peut voir, avec ce projet assez complet, toutes les possibilités offertes de la programmation des NodeMCU en LUA, en mode événementiel. <br>
|
||||
Choses qui ne seraient pas possible si on l'avait fait en C++ (mode Arduino), comme par exemple:
|
||||
|
||||
* serveur WEB Active Server Pages ZYX, permet de faire des pages HTML dynamique avec du code LUA in line
|
||||
* serveur WEB service pour le HUB (API GET)
|
||||
* serveur WEB pour l'affichage de la consommation électrique
|
||||
* serveur WEB pour l'IDE, modification du code source en remote directement depuis une page WEB, pas besoin d'IDE
|
||||
* crontab, horloge pour les mesures de la consommation
|
||||
* serveur TELNET, utilisation de la console en remote pour le debug
|
||||
|
||||
Toutes les fonctions sont bien séparées dans des scripts, ce qui facilite la portabilité entre les projets mais aussi sa mise au point.
|
||||
|
||||
|
||||
|
||||
## Astuces de mesures
|
||||
|
||||
Dans ce projet il y a 1x NodeMCU qui mesure la production électrique de mon installation solaire PV. En en mesurant le courant (avec le petit transformateur de courant 1/800 connecté sur un fil) injecté dans le réseau électrique de ma maison des deux minis onduleurs qui convertissent la basse tension (36V) des panneaux PV en 220V du réseau électrique.
|
||||
Le calcul de conversion tension/courant mesurée est très simpliste, un simple P=U*I*cos(phy). On ne tient pas du tout compte ici du cosinus phy qui pourrait varier en fonction des charges inductives dans la maison !
|
||||
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Il faut *flasher* le NodeMCU avec ce firmware:
|
||||
|
||||
https://github.com/zuzu59/NodeMCU_Lua/blob/master/Firmware/nodemcu-master-20-modules-2019-07-01-06-35-13-float.bin
|
||||
|
||||
|
||||
Avec ces modules:
|
||||
|
||||
```
|
||||
adc ds18b20 file gpio http i2c mdns mqtt net
|
||||
node ow pcm rtctime sntp spi tmr uart wifi ws2812
|
||||
```
|
||||
|
||||
|
||||
## Utilisation
|
||||
|
||||
### Distribution des rôles de NodeMCU
|
||||
|
||||
Comme la mesure de consommation est faite avec 1x NodeMCU, il y a donc 1x fichiers de *secrets*. C'est dans ce fichier de *secrets* qu'il y a l'information de l'adresse IP de la base de donnée InfluxDB !<br>
|
||||
|
||||
```
|
||||
secrets_energy.lua
|
||||
```
|
||||
|
||||
C'est aussi là qu'il y a le *numéro du field* (zfield), c'est à dire le rôle joué par le NodeMCU_Lua:
|
||||
|
||||
* **1**, production électrique des PV
|
||||
|
||||
|
||||
|
||||
|
||||
**ATTENTION, readme pas encore terminé, il faut encore modifier le readme depuis ici ! zf190908.2222**
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
### Affichage des températures en local sur le NodeMCU
|
||||
|
||||
On peut lire la température directement sur le NodeMCU au moyen de cet url (il faut modifier l'adresse IP du NodeMCU en question):
|
||||
|
||||
nodemcu 28 int, http://192.168.0.171/disp_temp.html
|
||||
|
||||
nodemcu 29 sud, http://192.168.0.180/disp_temp.html
|
||||
|
||||
nodemcu 30 nord, http://192.168.0.105/disp_temp.html
|
||||
|
||||
|
||||
### Affichage du petit serveur web du NodeMCU_Lua
|
||||
|
||||
Chaque NodeMCU a son propre serveur WEB, on peut l'accéder simplement depuis son adresse IP:
|
||||
|
||||
nodemcu 28 int, http://192.168.0.171
|
||||
|
||||
nodemcu 29 sud, http://192.168.0.180
|
||||
|
||||
nodemcu 30 nord, http://192.168.0.105
|
||||
|
||||
|
||||
### Modification du code source du NodeMCU en remote
|
||||
|
||||
Très pratique pour le debug, on peut directement modifier le code source Lua du NodeMCU en remote avec cet url:
|
||||
|
||||
nodemcu 28 int, http://192.168.0.171:88
|
||||
|
||||
nodemcu 29 sud, http://192.168.0.180:88
|
||||
|
||||
nodemcu 30 sord, http://192.168.0.105:88
|
||||
|
||||
|
||||
### Utilisation de la console du NodeMCU en remote
|
||||
|
||||
Très pratique pour le debug, on peut accéder à la console du NodeMCU en remote avec telnet:
|
||||
|
||||
nodemcu 28 int, **telnet -rN 192.168.0.171**
|
||||
|
||||
nodemcu 29 sud, **telnet -rN 192.168.0.180**
|
||||
|
||||
nodemcu 30 nord, **telnet -rN 192.168.0.105**
|
||||
|
||||
|
||||
## Visualisation sur ThingSpeak
|
||||
La totale en détail
|
||||
https://thingspeak.com/channels/817940
|
||||
|
||||
Seulement la corrélation entre les trois température
|
||||
https://thingspeak.com/apps/plugins/300559
|
||||
|
||||
|
||||
zf190908.2223
|
||||
|
||||
|
||||
pense bête:
|
||||
|
||||
```
|
||||
file.open("hello.lua","w+")
|
||||
file.writeline([[print("hello nodemcu")]])
|
||||
file.writeline([[print(node.heap())]])
|
||||
file.close()
|
||||
```
|
||||
17
Mesures/solar_pv_energy/_secrets_energy.lua_
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Petit script pour configurer les choses secrètes que l'on n'aimerait
|
||||
-- pas être exportées sur Internet (github)
|
||||
-- faut donc le mettre ailleurs que dans le dépôt !
|
||||
|
||||
function secrets()
|
||||
print("\n secrets_temp_zf_out_sud.lua zf190727.1006 \n")
|
||||
|
||||
cli_ssid="xxx"
|
||||
cli_pwd="xxx"
|
||||
|
||||
thingspeak_url="http://api.thingspeak.com/update?api_key=xxx&"
|
||||
hub_url="http://192.168.0.180/api_hub_temp.html?"
|
||||
zfield=1 ou 2 ou 3 !
|
||||
|
||||
end
|
||||
secrets()
|
||||
secrets=nil
|
||||
23
Mesures/solar_pv_energy/a1.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
|
||||
-- source: https://nodemcu.readthedocs.io/en/master/modules/ds18b20/
|
||||
|
||||
function a1()
|
||||
print("\n a1.lua zf190601.1627 \n")
|
||||
end
|
||||
|
||||
a1()
|
||||
|
||||
local ow_pin = 3
|
||||
ds18b20.setup(ow_pin)
|
||||
|
||||
print("toto182538")
|
||||
|
||||
-- read all sensors and print all measurement results
|
||||
ds18b20.read(
|
||||
function(ind,rom,res,temp,tdec,par)
|
||||
print(ind,string.format("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",string.match(rom,"(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%d+)")),res,temp,tdec,par)
|
||||
end,{})
|
||||
|
||||
print("tutu152603")
|
||||
|
||||
1
Mesures/solar_pv_energy/a2.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
3
Mesures/solar_pv_energy/a3.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
node.restart()
|
||||
|
||||
36
Mesures/solar_pv_energy/boot.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf190805.1042 \n")
|
||||
|
||||
function heartbeat()
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
flash_led_xfois()
|
||||
boottimer1=tmr.create()
|
||||
boottimer1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
xfois =2
|
||||
blink_LED ()
|
||||
end)
|
||||
end
|
||||
|
||||
-- charge ses propres secrets
|
||||
f= "secrets_energy.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
|
||||
f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
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_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()
|
||||
|
||||
|
||||
|
||||
30
Mesures/solar_pv_energy/disp_data.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>Affichage des températures</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Affichage des températures 190727.1349</h1>
|
||||
<br>
|
||||
Les températures mesurées sont:<br>
|
||||
|
||||
|
||||
<%
|
||||
if (ztemp1 ~= nil) then
|
||||
zout("<br>Température intérieure chambre à coucher "..ztemp1.."°C")
|
||||
end
|
||||
if (ztemp2 ~= nil) then
|
||||
zout("<br>Température extérieure sud (nodemcu 29) "..ztemp2.."°C")
|
||||
end
|
||||
if (ztemp3 ~= nil) then
|
||||
zout("<br>Température extérieure nord (nodemcu 30) "..ztemp3.."°C")
|
||||
end
|
||||
|
||||
zout("<br><br>RAM: "..node.heap().."<br>")
|
||||
%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
39
Mesures/solar_pv_energy/flash_led_xfois.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
-- programme pour faire clignoter x fois une LED avec un rapport on/off
|
||||
|
||||
function flash_led_xfois()
|
||||
print("\n flash_led_xfois.lua zf190601.1618 \n")
|
||||
|
||||
--zLED=0 --NodeMCU
|
||||
zLED=4 --EPS-M3
|
||||
zTm_On_LED = 50 --> en ms
|
||||
zTm_Off_LED = 100 --> en ms
|
||||
nbfois = 0
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
gpio.mode(zLED, gpio.OUTPUT)
|
||||
ztmr_Flash_LED = tmr.create()
|
||||
|
||||
function blink_LED ()
|
||||
if nbfois >= xfois then
|
||||
-- print(nbfois)
|
||||
nbfois = 0
|
||||
else
|
||||
if gpio.read(zLED)==gpio.HIGH then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
-- tmr.alarm(ztmr_Flash_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED)
|
||||
ztmr_Flash_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED)
|
||||
else
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
nbfois = nbfois+1
|
||||
-- tmr.alarm(ztmr_Flash_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED)
|
||||
ztmr_Flash_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- xfois =2
|
||||
-- blink_LED ()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
1
Mesures/solar_pv_energy/goodies/a6.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
1
Mesures/solar_pv_energy/goodies/a7.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
1
Mesures/solar_pv_energy/goodies/a8.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
1
Mesures/solar_pv_energy/goodies/a9.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- programme pour faire un test depuis de le webide
|
||||
6
Mesures/solar_pv_energy/goodies/a_tst_variables.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Scripts pour afficher toutes les variables et fonctions en cours dans le système
|
||||
|
||||
print("\n a_tst_variable.lua zf190310.1525 \n")
|
||||
|
||||
for n in pairs (_G) do print(n) end
|
||||
|
||||
37
Mesures/solar_pv_energy/goodies/led_rgb.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
-- Scripts juste pour allumer ou éteindre une LED sur un ruban RGB
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n led_rgb.lua zf190303.1436 \n")
|
||||
|
||||
nbleds=3
|
||||
ws2812.init()
|
||||
myLedStrip = ws2812.newBuffer(nbleds, 3)
|
||||
|
||||
function RGB_clear()
|
||||
myLedStrip:fill(0, 0, 0) ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
function RGB_reform(R1, G1, B1) --conversion de RGB à BRG
|
||||
rR1=B1 rG1=R1 rB1=G1
|
||||
end
|
||||
|
||||
function zled_rgb(num_led, R1, G1, B1, zpower)
|
||||
RGB_reform(R1, G1, B1)
|
||||
myLedStrip:set(num_led, rR1*zpower, rG1*zpower, rB1*zpower)
|
||||
ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
function zled_write()
|
||||
ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
|
||||
RGB_clear()
|
||||
|
||||
--[[
|
||||
zled_rgb(1,255,0,0,1)
|
||||
zled_rgb(2,0,255,0,1)
|
||||
zled_rgb(2,0,255,0,0.05)
|
||||
zled_rgb(3,0,0,255,1)
|
||||
]]
|
||||
12
Mesures/solar_pv_energy/goodies/rm_files.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- pour effacer TOUS les fichiers qui se trouve dans la flash du NodeMCU
|
||||
|
||||
print("\n rm_files.lua zf180907.1511 \n")
|
||||
|
||||
|
||||
l=file.list() i=0
|
||||
for k,v in pairs(l) do
|
||||
i=i+v
|
||||
file.remove(k)
|
||||
end
|
||||
print("-------------------------------")
|
||||
print("\nC'est tout effaced :-) \n")
|
||||
27
Mesures/solar_pv_energy/goodies/t1.csv
Normal file
@@ -0,0 +1,27 @@
|
||||
ohm,%
|
||||
33,100
|
||||
36,96.77419355
|
||||
41,92.74193548
|
||||
45,88.70967742
|
||||
52,84.67741935
|
||||
56,80.64516129
|
||||
61,76.61290323
|
||||
67,72.58064516
|
||||
72,68.5483871
|
||||
79,64.51612903
|
||||
83,60.48387097
|
||||
91,56.4516129
|
||||
97,52.41935484
|
||||
104,48.38709677
|
||||
112,44.35483871
|
||||
117,40.32258065
|
||||
121,36.29032258
|
||||
128,32.25806452
|
||||
132,28.22580645
|
||||
139,24.19354839
|
||||
150,20.16129032
|
||||
166,16.12903226
|
||||
191,12.09677419
|
||||
207,8.064516129
|
||||
224,4.032258065
|
||||
240,0
|
||||
|
19
Mesures/solar_pv_energy/goodies/wifi_ap_start.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
|
||||
function wifi_ap_start()
|
||||
print("\n wifi_ap_start.lua zf190310.1511 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI mode AP only")
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
elseif zmodewifi == wifi.STATION then
|
||||
print("WIFI mode AP+CLI")
|
||||
wifi.setmode(wifi.STATIONAP)
|
||||
end
|
||||
wifi.ap.config({ ssid = "NodeMCU "..wifi.ap.getmac(), pwd = "12345678" })
|
||||
--f= "wifi_info.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
|
||||
wifi_ap_start()
|
||||
wifi_ap_start=nil
|
||||
12
Mesures/solar_pv_energy/goodies/wifi_get_ip.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi
|
||||
print("\n wifi_get_ip.lua zf181119.2318 \n")
|
||||
|
||||
wifitimer1=tmr.create()
|
||||
tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function()
|
||||
if wifi.sta.getip() == nil then
|
||||
print("Connecting to AP...")
|
||||
else
|
||||
tmr.stop(wifitimer1)
|
||||
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
end)
|
||||
9
Mesures/solar_pv_energy/goodies/wifi_off.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Déconnecte le WIFI
|
||||
print("\n wifi_off.lua zf180822.0959 \n")
|
||||
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
|
||||
--[[
|
||||
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
|
||||
print(wifi.getmode())
|
||||
]]
|
||||
BIN
Mesures/solar_pv_energy/img/20190907_170403.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
Mesures/solar_pv_energy/img/20190907_170414.jpg
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
Mesures/solar_pv_energy/img/20190908_134444.jpg
Normal file
|
After Width: | Height: | Size: 768 KiB |
BIN
Mesures/solar_pv_energy/img/20190908_213900.jpg
Normal file
|
After Width: | Height: | Size: 801 KiB |
BIN
Mesures/solar_pv_energy/img/20190908_213927.jpg
Normal file
|
After Width: | Height: | Size: 792 KiB |
BIN
Mesures/solar_pv_energy/img/20190908_221514.jpg
Normal file
|
After Width: | Height: | Size: 834 KiB |
53
Mesures/solar_pv_energy/initz.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
--Script de bootstrap, test au moment du boot qui a été la cause de boot.
|
||||
-- Si la cause est un power on ou une connexion depuis l'IDE, alors
|
||||
-- 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 zf190621.1612 \n")
|
||||
|
||||
zswitch=3 --switch flash
|
||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||
|
||||
function hvbouton()
|
||||
-- gpio.trig(zswitch, "none")
|
||||
initalarme:unregister()
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
|
||||
gpio.trig(zswitch, "both", hvbouton)
|
||||
|
||||
function second_chance()
|
||||
print("seconde chance...")
|
||||
f= "repair.lua" if file.exists(f) then dofile(f) end
|
||||
initalarme=tmr.create()
|
||||
-- tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function()
|
||||
initalarme:alarm(4*1000, tmr.ALARM_SINGLE, function()
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end)
|
||||
end
|
||||
|
||||
_, reset_reason = node.bootreason()
|
||||
print("reset_reason:",reset_reason)
|
||||
if reset_reason == 0 then
|
||||
print("power on")
|
||||
second_chance()
|
||||
elseif reset_reason == 4 then
|
||||
print("node.restart")
|
||||
gpio.trig(zswitch)
|
||||
hvbouton=nil
|
||||
second_chance=nil
|
||||
zswitch=nil
|
||||
reset_reason=nil
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
elseif reset_reason == 5 then
|
||||
print("dsleep wake up")
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
elseif reset_reason == 6 then
|
||||
print("external reset")
|
||||
second_chance()
|
||||
-- f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
else
|
||||
print("autre raison")
|
||||
second_chance()
|
||||
end
|
||||
|
||||
52
Mesures/solar_pv_energy/oldies/ds18b20-example.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
t = require("ds18b20")
|
||||
pin = 3 -- gpio0 = 3, gpio2 = 4
|
||||
|
||||
local function readout(temp)
|
||||
if t.sens then
|
||||
print("Total number of DS18B20 sensors: ".. #t.sens)
|
||||
for i, s in ipairs(t.sens) do
|
||||
print(string.format(" sensor #%d address: %s%s", i, ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(s:byte(1,8)), s:byte(9) == 1 and " (parasite)" or ""))
|
||||
end
|
||||
end
|
||||
for addr, temp in pairs(temp) do
|
||||
print(string.format("Sensor %s: %s °C", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(addr:byte(1,8)), temp))
|
||||
end
|
||||
|
||||
-- Module can be released when it is no longer needed
|
||||
--t = nil
|
||||
--package.loaded["ds18b20"]=nil
|
||||
end
|
||||
|
||||
t:enable_debug()
|
||||
file.remove("ds18b20_save.lc") -- remove saved addresses
|
||||
print("=============================================", node.heap())
|
||||
print("first call, no addresses in flash, search is performed")
|
||||
t:read_temp(readout, pin, t.C)
|
||||
|
||||
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
|
||||
print("=============================================", node.heap())
|
||||
print("second readout, no new search, found addresses are used")
|
||||
t:read_temp(readout, pin)
|
||||
|
||||
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
|
||||
print("=============================================", node.heap())
|
||||
print("force search again")
|
||||
t:read_temp(readout, pin, nil, true)
|
||||
|
||||
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
|
||||
print("=============================================", node.heap())
|
||||
print("save search results")
|
||||
t:read_temp(readout, pin, nil, false, true)
|
||||
|
||||
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
|
||||
print("=============================================", node.heap())
|
||||
print("use saved addresses")
|
||||
t.sens={}
|
||||
t:read_temp(readout, pin)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
35
Mesures/solar_pv_energy/oldies/ds18b20-web.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
t = require('ds18b20')
|
||||
|
||||
port = 80
|
||||
pin = 3 -- gpio0 = 3, gpio2 = 4
|
||||
gconn = {} -- global variable for connection
|
||||
|
||||
function readout(temp)
|
||||
local resp = "HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
|
||||
"<!DOCTYPE HTML>" ..
|
||||
"<html><body>" ..
|
||||
"<b>ESP8266</b></br>"
|
||||
|
||||
for addr, temp in pairs(temp) do
|
||||
resp = resp .. string.format("Sensor %s: %s ℃</br>", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8)), temp)
|
||||
end
|
||||
|
||||
resp = resp ..
|
||||
"Node ChipID: " .. node.chipid() .. "<br>" ..
|
||||
"Node MAC: " .. wifi.sta.getmac() .. "<br>" ..
|
||||
"Node Heap: " .. node.heap() .. "<br>" ..
|
||||
"Timer Ticks: " .. tmr.now() .. "<br>" ..
|
||||
"</html></body>"
|
||||
|
||||
gconn:send(resp)
|
||||
gconn:on("sent",function(conn) conn:close() end)
|
||||
end
|
||||
|
||||
srv=net.createServer(net.TCP)
|
||||
srv:listen(port,
|
||||
function(conn)
|
||||
gconn = conn
|
||||
-- t:read_temp(readout) -- default pin value is 3
|
||||
t:read_temp(readout, pin)
|
||||
end
|
||||
)
|
||||
223
Mesures/solar_pv_energy/oldies/ds18b20.lua
Normal file
@@ -0,0 +1,223 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- DS18B20 one wire module for NODEMCU
|
||||
-- NODEMCU TEAM
|
||||
-- LICENCE: http://opensource.org/licenses/MIT
|
||||
-- @voborsky, @devsaurus, TerryE 26 Mar 2017
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
local modname = ...
|
||||
|
||||
-- Used modules and functions
|
||||
local table, string, ow, tmr, print, type, tostring, pcall, ipairs =
|
||||
table, string, ow, tmr, print, type, tostring, pcall, ipairs
|
||||
-- Local functions
|
||||
local ow_setup, ow_search, ow_select, ow_read, ow_read_bytes, ow_write, ow_crc8, ow_reset, ow_reset_search, ow_skip, ow_depower =
|
||||
ow.setup, ow.search, ow.select, ow.read, ow.read_bytes, ow.write, ow.crc8, ow.reset, ow.reset_search, ow.skip, ow.depower
|
||||
local node_task_post, node_task_LOW_PRIORITY = node.task.post, node.task.LOW_PRIORITY
|
||||
local string_char, string_dump = string.char, string.dump
|
||||
local now, tmr_create, tmr_ALARM_SINGLE = tmr.now, tmr.create, tmr.ALARM_SINGLE
|
||||
local table_sort, table_concat = table.sort, table.concat
|
||||
local math_floor = math.floor
|
||||
local file_open = file.open
|
||||
|
||||
table, string, tmr, ow = nil, nil, nil, nil
|
||||
|
||||
local DS18B20FAMILY = 0x28
|
||||
local DS1920FAMILY = 0x10 -- and DS18S20 series
|
||||
local CONVERT_T = 0x44
|
||||
local READ_SCRATCHPAD = 0xBE
|
||||
local READ_POWERSUPPLY= 0xB4
|
||||
local MODE = 1
|
||||
|
||||
local pin, cb, unit = 3
|
||||
local status = {}
|
||||
|
||||
local debugPrint = function() return end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Implementation
|
||||
--------------------------------------------------------------------------------
|
||||
local function enable_debug()
|
||||
debugPrint = function (...) print(now(),' ', ...) end
|
||||
end
|
||||
|
||||
local function to_string(addr, esc)
|
||||
if type(addr) == 'string' and #addr == 8 then
|
||||
return ( esc == true and
|
||||
'"\\%u\\%u\\%u\\%u\\%u\\%u\\%u\\%u"' or
|
||||
'%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8))
|
||||
else
|
||||
return tostring(addr)
|
||||
end
|
||||
end
|
||||
|
||||
local function readout(self)
|
||||
local next = false
|
||||
local sens = self.sens
|
||||
local temp = self.temp
|
||||
for i, s in ipairs(sens) do
|
||||
if status[i] == 1 then
|
||||
ow_reset(pin)
|
||||
local addr = s:sub(1,8)
|
||||
ow_select(pin, addr) -- select the sensor
|
||||
ow_write(pin, READ_SCRATCHPAD, MODE)
|
||||
data = ow_read_bytes(pin, 9)
|
||||
|
||||
local t=(data:byte(1)+data:byte(2)*256)
|
||||
-- t is actually signed so process the sign bit and adjust for fractional bits
|
||||
-- the DS18B20 family has 4 fractional bits and the DS18S20s, 1 fractional bit
|
||||
t = ((t <= 32767) and t or t - 65536) *
|
||||
((addr:byte(1) == DS18B20FAMILY) and 625 or 5000)
|
||||
|
||||
if 1/2 == 0 then
|
||||
-- integer version
|
||||
if unit == 'F' then
|
||||
t = (t * 18)/10 + 320000
|
||||
elseif unit == 'K' then
|
||||
t = t + 2731500
|
||||
end
|
||||
local sgn = t<0 and -1 or 1
|
||||
local tA = sgn*t
|
||||
local tH=tA/10000
|
||||
local tL=(tA%10000)/1000 + ((tA%1000)/100 >= 5 and 1 or 0)
|
||||
|
||||
if tH and (t~=850000) then
|
||||
temp[addr]=(sgn<0 and "-" or "")..tH.."."..tL
|
||||
debugPrint(to_string(addr),(sgn<0 and "-" or "")..tH.."."..tL)
|
||||
status[i] = 2
|
||||
end
|
||||
-- end integer version
|
||||
else
|
||||
-- float version
|
||||
if t and (math_floor(t/10000)~=85) then
|
||||
t = t / 10000
|
||||
if unit == 'F' then
|
||||
t = t * 18/10 + 32
|
||||
elseif unit == 'K' then
|
||||
t = t + 27315/100
|
||||
end
|
||||
self.temp[addr]=t
|
||||
debugPrint(to_string(addr), t)
|
||||
status[i] = 2
|
||||
end
|
||||
-- end float version
|
||||
end
|
||||
end
|
||||
next = next or status[i] == 0
|
||||
end
|
||||
if next then
|
||||
node_task_post(node_task_LOW_PRIORITY, function() return conversion(self) end)
|
||||
else
|
||||
--sens = {}
|
||||
if cb then
|
||||
node_task_post(node_task_LOW_PRIORITY, function() return cb(temp) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function conversion(self)
|
||||
local sens = self.sens
|
||||
local powered_only = true
|
||||
for _, s in ipairs(sens) do powered_only = powered_only and s:byte(9) ~= 1 end
|
||||
if powered_only then
|
||||
debugPrint("starting conversion: all sensors")
|
||||
ow_reset(pin)
|
||||
ow_skip(pin) -- select the sensor
|
||||
ow_write(pin, CONVERT_T, MODE) -- and start conversion
|
||||
for i, s in ipairs(sens) do status[i] = 1 end
|
||||
else
|
||||
for i, s in ipairs(sens) do
|
||||
if status[i] == 0 then
|
||||
local addr, parasite = s:sub(1,8), s:byte(9)
|
||||
debugPrint("starting conversion:", to_string(addr), parasite == 1 and "parasite" or " ")
|
||||
ow_reset(pin)
|
||||
ow_select(pin, addr) -- select the sensor
|
||||
ow_write(pin, CONVERT_T, MODE) -- and start conversion
|
||||
status[i] = 1
|
||||
if parasite == 1 then break end -- parasite sensor blocks bus during conversion
|
||||
end
|
||||
end
|
||||
end
|
||||
tmr_create():alarm(750, tmr_ALARM_SINGLE, function() return readout(self) end)
|
||||
end
|
||||
|
||||
local function _search(self, lcb, lpin, search, save)
|
||||
self.temp = {}
|
||||
if search then self.sens = {}; status = {} end
|
||||
local temp = self.temp
|
||||
local sens = self.sens
|
||||
pin = lpin or pin
|
||||
|
||||
local addr
|
||||
if not search and #sens == 0 then
|
||||
-- load addreses if available
|
||||
debugPrint ("geting addreses from flash")
|
||||
local s,check,a = pcall(dofile, "ds18b20_save.lc")
|
||||
if s and check == "ds18b20" then
|
||||
for i = 1, #a do sens[i] = a[i] end
|
||||
end
|
||||
debugPrint (#sens, "addreses found")
|
||||
end
|
||||
|
||||
ow_setup(pin)
|
||||
if search or #sens == 0 then
|
||||
ow_reset_search(pin)
|
||||
-- ow_target_search(pin,0x28)
|
||||
-- search the first device
|
||||
addr = ow_search(pin)
|
||||
else
|
||||
for i, s in ipairs(sens) do status[i] = 0 end
|
||||
end
|
||||
local function cycle()
|
||||
debugPrint("cycle")
|
||||
if addr then
|
||||
local crc=ow_crc8(addr:sub(1,7))
|
||||
if (crc==addr:byte(8)) and ((addr:byte(1)==DS1920FAMILY) or (addr:byte(1)==DS18B20FAMILY)) then
|
||||
ow_reset(pin)
|
||||
ow_select(pin, addr)
|
||||
ow_write(pin, READ_POWERSUPPLY, MODE)
|
||||
local parasite = (ow_read(pin)==0 and 1 or 0)
|
||||
sens[#sens+1]= addr..string_char(parasite) -- {addr=addr, parasite=parasite, status=0}
|
||||
debugPrint("contact: ", to_string(addr), parasite == 1 and "parasite" or " ")
|
||||
end
|
||||
addr = ow_search(pin)
|
||||
node_task_post(node_task_LOW_PRIORITY, cycle)
|
||||
else
|
||||
ow_depower(pin)
|
||||
-- place powered sensors first
|
||||
table_sort(sens, function(a, b) return a:byte(9)<b:byte(9) end) -- parasite
|
||||
-- save sensor addreses
|
||||
if save then
|
||||
debugPrint ("saving addreses to flash")
|
||||
|
||||
local addr_list = {}
|
||||
for i =1, #sens do
|
||||
local s = sens[i]
|
||||
addr_list[i] = to_string(s:sub(1,8), true)..('.."\\%u"'):format(s:byte(9))
|
||||
end
|
||||
local save_statement = 'return "ds18b20", {' .. table_concat(addr_list, ',') .. '}'
|
||||
debugPrint (save_statement)
|
||||
local save_file = file_open("ds18b20_save.lc","w")
|
||||
save_file:write(string_dump(loadstring(save_statement)))
|
||||
save_file:close()
|
||||
end
|
||||
-- end save sensor addreses
|
||||
if lcb then node_task_post(node_task_LOW_PRIORITY, lcb) end
|
||||
end
|
||||
end
|
||||
cycle()
|
||||
end
|
||||
|
||||
local function read_temp(self, lcb, lpin, lunit, force_search, save_search)
|
||||
cb, unit = lcb, lunit or unit
|
||||
_search(self, function() return conversion(self) end, lpin, force_search, save_search)
|
||||
end
|
||||
|
||||
-- Set module name as parameter of require and return module table
|
||||
local M = {
|
||||
sens = {},
|
||||
temp = {},
|
||||
C = 'C', F = 'F', K = 'K',
|
||||
read_temp = read_temp, enable_debug = enable_debug
|
||||
}
|
||||
_G[modname or 'ds18b20'] = M
|
||||
return M
|
||||
40
Mesures/solar_pv_energy/oldies/thingspeak.mat
Normal file
@@ -0,0 +1,40 @@
|
||||
% Template MATLAB code for visualizing correlated data using the
|
||||
% SCATTER function.
|
||||
|
||||
% zf190728.1213
|
||||
|
||||
% Prior to running this MATLAB code template, assign the channel variables.
|
||||
% Set 'readChannelID' to the channel ID of the channel to read from.
|
||||
% Also, assign the read field IDs to the variables 'fieldID1', and 'fieldID2'.
|
||||
|
||||
% Replace the [] with channel ID to read data from:
|
||||
readChannelID = []];
|
||||
fieldID1 = 1;
|
||||
fieldID2 = 2;
|
||||
fieldID3 = 3;
|
||||
|
||||
% Channel Read API Key
|
||||
% If your channel is private, then enter the read API
|
||||
% Key between the '' below:
|
||||
readAPIKey = '';
|
||||
|
||||
%% Read Data %%
|
||||
|
||||
nbMesures = 200
|
||||
|
||||
% Read 1 data variable
|
||||
[data1, time1] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);
|
||||
|
||||
% Read 2 data variable
|
||||
[data2, time2] = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);
|
||||
|
||||
% Read 3 data variable
|
||||
[data3, time3] = thingSpeakRead(readChannelID, 'Field', fieldID3, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);
|
||||
|
||||
%% Visualize Data %%
|
||||
plot(time1,data1, time2,data2, time3,data3);
|
||||
|
||||
legend({'Tint 1er','Text sud','Text nord'});
|
||||
xlabel('Time (GMT ! )');
|
||||
ylabel('Temperature °C');
|
||||
title('Mesures température 1023 Crissier');
|
||||
29
Mesures/solar_pv_energy/set_time.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Scripts pour régler l'horloge quand on est connecté en WIFI
|
||||
-- Permet aussi de 'compresser' le unix time afin de prendre moins de place dans les strings
|
||||
|
||||
print("\n set_time.lua zf190217.1426 \n")
|
||||
|
||||
--source: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html
|
||||
|
||||
ztime2019 = 1546300800 -- Unix time pour le 1.1.2019
|
||||
|
||||
function set_time()
|
||||
sntp.sync(nil, nil, nil, 1)
|
||||
end
|
||||
|
||||
function ztime_compress(ztime_long)
|
||||
return ztime_long - ztime2019
|
||||
end
|
||||
|
||||
function ztime_uncompress(ztime_short)
|
||||
return ztime_short + ztime2019
|
||||
end
|
||||
|
||||
function ztime_format(ztime)
|
||||
tm = rtctime.epoch2cal(ztime + 3600)
|
||||
return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
|
||||
end
|
||||
|
||||
set_time()
|
||||
print(ztime_format(rtctime.get()))
|
||||
|
||||
87
Mesures/solar_pv_energy/telnet_srv2.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
-- Serveur telnet pour connexion en remote WIFI, NOUVELLE VERSION !
|
||||
-- source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/telnet/telnet.lua
|
||||
|
||||
print("\n telnet_srv2.lua zf181215.1326 \n")
|
||||
|
||||
local node, table, tmr, wifi, uwrite, tostring =
|
||||
node, table, tmr, wifi, uart.write, tostring
|
||||
|
||||
local function telnet_listener(socket)
|
||||
local insert, remove, concat, heap, gc =
|
||||
table.insert, table.remove, table.concat, node.heap, collectgarbage
|
||||
local fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0
|
||||
local s -- s is a copy of the TCP socket if and only if sending is in progress
|
||||
local wdclr, cnt = tmr.wdclr, 0
|
||||
local function debug(fmt, ...)
|
||||
if (...) then fmt = fmt:format(...) end
|
||||
uwrite(0, "\r\nDBG: ",fmt,"\r\n" )
|
||||
cnt = cnt + 1
|
||||
if cnt % 10 then wdclr() end
|
||||
end
|
||||
|
||||
local function flushGarbage()
|
||||
if heap() < 13440 then gc() end
|
||||
end
|
||||
|
||||
local function sendLine()
|
||||
if not s then return end
|
||||
|
||||
if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s
|
||||
s = nil
|
||||
return
|
||||
end
|
||||
flushGarbage()
|
||||
if #fifo2 < 4 then -- Flush FIFO1 into FIFO2
|
||||
insert(fifo2,concat(fifo1))
|
||||
fifo2l, fifo1, fifo1l = fifo2l + fifo1l, {}, 0
|
||||
end
|
||||
local rec = remove(fifo2,1) .. (remove(fifo2,1) or '') ..
|
||||
(remove(fifo2,1) or '') .. (remove(fifo2,1) or '')
|
||||
fifo2l = fifo2l - #rec
|
||||
flushGarbage()
|
||||
s:send(rec)
|
||||
end
|
||||
|
||||
local F1_SIZE = 256
|
||||
|
||||
local function queueLine(str)
|
||||
while #str > 0 do -- this is because str might be longer than the packet size!
|
||||
local k, l = F1_SIZE - fifo1l, #str
|
||||
local chunk
|
||||
if #fifo1 >= 32 or (k < l and k < 16) then
|
||||
insert(fifo2, concat(fifo1))
|
||||
fifo2l, fifo1, fifo1l, k = fifo2l + fifo1l, {}, 0, F1_SIZE
|
||||
end
|
||||
if l > k+16 then -- also tolerate a size overrun of 16 bytes to avoid a split
|
||||
chunk, str = str:sub(1,k), str:sub(k+1)
|
||||
else
|
||||
chunk, str = str, ''
|
||||
end
|
||||
insert(fifo1, chunk)
|
||||
fifo1l = fifo1l + #chunk
|
||||
end
|
||||
if not s and socket then
|
||||
s = socket
|
||||
sendLine()
|
||||
else
|
||||
flushGarbage()
|
||||
end
|
||||
end
|
||||
|
||||
local function receiveLine(s, line)
|
||||
node.input(line)
|
||||
end
|
||||
|
||||
local function disconnect(s)
|
||||
fifo1, fifo1l, fifo2, fifo2l, s = {}, 0, {}, 0, nil
|
||||
node.output(nil)
|
||||
end
|
||||
|
||||
socket:on("receive", receiveLine)
|
||||
socket:on("disconnection", disconnect)
|
||||
socket:on("sent", sendLine)
|
||||
node.output(queueLine, 0)
|
||||
end
|
||||
|
||||
net.createServer(net.TCP, 180):listen(23, telnet_listener)
|
||||
print("Telnet server running...\nUsage: telnet -rN ip\n")
|
||||
159
Mesures/solar_pv_energy/web_ide2.lua
Normal file
@@ -0,0 +1,159 @@
|
||||
-- Petit WEB IDE tout simple autonome
|
||||
-- ATTENTION: tourne sur le port 88 !
|
||||
|
||||
print("\n web_ide2.lua zf190706.1430 \n")
|
||||
|
||||
--[[
|
||||
XChip's NodeMCU IDE
|
||||
|
||||
Create, Edit and run NodeMCU files using your webbrowser.
|
||||
Examples:
|
||||
http://<mcu_ip>/ will list all the files in the MCU
|
||||
http://<mcu_ip>/newfile.lua displays the file on your browser
|
||||
http://<mcu_ip>/newfile.lua?edit allows to creates or edits the specified script in your browser
|
||||
http://<mcu_ip>/newfile.lua?run it will run the specified script and will show the returned value
|
||||
]]--
|
||||
|
||||
srv=net.createServer(net.TCP)
|
||||
srv:listen(88,function(conn)
|
||||
|
||||
local rnrn=0
|
||||
local Status = 0
|
||||
local DataToGet = 0
|
||||
local method=""
|
||||
local url=""
|
||||
local vars=""
|
||||
|
||||
conn:on("receive",function(conn,payload)
|
||||
|
||||
if Status==0 then
|
||||
_, _, method, url, vars = string.find(payload, "([A-Z]+) /([^?]*)%??(.*) HTTP")
|
||||
print(method, url, vars)
|
||||
end
|
||||
|
||||
if method=="POST" then
|
||||
|
||||
if Status==0 then
|
||||
--print("status", Status)
|
||||
_,_,DataToGet, payload = string.find(payload, "Content%-Length: (%d+)(.+)")
|
||||
if DataToGet~=nil then
|
||||
DataToGet = tonumber(DataToGet)
|
||||
--print(DataToGet)
|
||||
rnrn=1
|
||||
Status = 1
|
||||
else
|
||||
print("bad length")
|
||||
end
|
||||
end
|
||||
|
||||
-- find /r/n/r/n
|
||||
if Status==1 then
|
||||
--print("status", Status)
|
||||
local payloadlen = string.len(payload)
|
||||
local mark = "\r\n\r\n"
|
||||
local i
|
||||
for i=1, payloadlen do
|
||||
if string.byte(mark, rnrn) == string.byte(payload, i) then
|
||||
rnrn=rnrn+1
|
||||
if rnrn==5 then
|
||||
payload = string.sub(payload, i+1,payloadlen)
|
||||
file.open(url, "w")
|
||||
file.close()
|
||||
Status=2
|
||||
break
|
||||
end
|
||||
else
|
||||
rnrn=1
|
||||
end
|
||||
end
|
||||
if Status==1 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if Status==2 then
|
||||
--print("status", Status)
|
||||
if payload~=nil then
|
||||
DataToGet=DataToGet-string.len(payload)
|
||||
--print("DataToGet:", DataToGet, "payload len:", string.len(payload))
|
||||
file.open(url, "a+")
|
||||
file.write(payload)
|
||||
file.close()
|
||||
else
|
||||
conn:send("HTTP/1.1 200 OK\r\n\r\nERROR")
|
||||
Status=0
|
||||
end
|
||||
|
||||
if DataToGet==0 then
|
||||
conn:send("HTTP/1.1 200 OK\r\n\r\nOK")
|
||||
Status=0
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
DataToGet = -1
|
||||
|
||||
if url == "favicon.ico" then
|
||||
conn:send("HTTP/1.1 404 file not found")
|
||||
return
|
||||
end
|
||||
|
||||
conn:send("HTTP/1.1 200 OK\r\n\r\n")
|
||||
|
||||
-- it wants a file in particular
|
||||
if url~="" and vars=="" then
|
||||
DataToGet = 0
|
||||
return
|
||||
end
|
||||
|
||||
conn:send("<html><body><h1>NodeMCU IDE</h1>")
|
||||
|
||||
if vars=="edit" then
|
||||
conn:send("<script>function tag(c){document.getElementsByTagName('w')[0].innerHTML=c};\n")
|
||||
conn:send("var x=new XMLHttpRequest()\nx.onreadystatechange=function(){if(x.readyState==4) document.getElementsByName('t')[0].value = x.responseText; };\nx.open('GET',location.pathname,true)\nx.send()</script>")
|
||||
conn:send("<h2><a href='/'>Back to file list</a>\n")
|
||||
conn:send("<br><br><button onclick=\"tag('Saving');x.open('POST',location.pathname,true);\nx.onreadystatechange=function(){if(x.readyState==4) tag(x.responseText);};\nx.send(new Blob([document.getElementsByName('t')[0].value],{type:'text/plain'}));\">Save</button><a href='?run'>run</a><w></w>")
|
||||
conn:send("</h2><br><textarea name=t cols=110 rows=50></textarea></br>")
|
||||
end
|
||||
|
||||
if vars=="run" then
|
||||
conn:send("<verbatim>")
|
||||
local st, result=pcall(dofile, url)
|
||||
conn:send(tostring(result))
|
||||
conn:send("</verbatim>")
|
||||
end
|
||||
|
||||
if url=="" then
|
||||
local l = file.list();
|
||||
for k,v in pairs(l) do
|
||||
conn:send("<a href='"..k.."?edit'>"..k.."</a>, size:"..v.."<br>")
|
||||
end
|
||||
end
|
||||
|
||||
conn:send("</body></html>")
|
||||
|
||||
end)
|
||||
conn:on("sent",function(conn)
|
||||
if DataToGet>=0 and method=="GET" then
|
||||
if file.open(url, "r") then
|
||||
file.seek("set", DataToGet)
|
||||
local line=file.read(512)
|
||||
file.close()
|
||||
if line then
|
||||
conn:send(line)
|
||||
DataToGet = DataToGet + 512
|
||||
|
||||
if (string.len(line)==512) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
conn:close()
|
||||
end)
|
||||
end)
|
||||
print("listening, free:", node.heap())
|
||||
|
||||
78
Mesures/solar_pv_energy/web_srv2.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
-- petit script de serveur WEB avec Active Server Page ZYX
|
||||
|
||||
print("\n web_srv2.lua zf190728.1021 \n")
|
||||
|
||||
ztemp=12
|
||||
|
||||
-- envoie sur le port ouvert mais depuis l'environnement global !
|
||||
function zout(zstring)
|
||||
zzclient:send(zstring) -- envoie le résultat du code lua inline
|
||||
end
|
||||
|
||||
-- envoie un fichier HTML sur le port. ATTENTION: longueur de la ligne maximale de 1'024 bytes !
|
||||
function send_file(zclient, zfilename)
|
||||
print("start send html...")
|
||||
zclient:send("HTTP/1.1 200 OK\n")
|
||||
zclient:send("Content-Type: text/html\n\n")
|
||||
zzclient = zclient -- export le port sur l'environnement global !
|
||||
if zfilename == "" then zfilename = "z_index.html" end
|
||||
file_web = file.open(zfilename, "r")
|
||||
if file_web then
|
||||
repeat
|
||||
local line = file_web:read('\n')
|
||||
if line then
|
||||
if string.find(line, "<%%") then
|
||||
-- print("start lua...")
|
||||
flag_lua_code = true -- bascule sur le code lua inline
|
||||
lua_code = ""
|
||||
elseif string.find(line, "%%>") then
|
||||
-- print("stop lua...")
|
||||
flag_lua_code = false -- revient sur le code HTML
|
||||
-- print("Et voici le code lua inline:\n"..lua_code)
|
||||
loadstring(lua_code)() --on exécute ici le code lua inline !
|
||||
elseif flag_lua_code then
|
||||
-- print(line)
|
||||
lua_code = lua_code..line -- récupère le code lua inline
|
||||
else
|
||||
zclient:send(line) -- envoie le code HTML
|
||||
end
|
||||
end
|
||||
until not line
|
||||
file_web:close() file_web = nil
|
||||
else
|
||||
zclient:send("<html><h1>"..zfilename.." not found - 404 error</h1><a href='/'>Home</a><br></html>")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
srv = net.createServer()
|
||||
srv:listen(80, function(conn)
|
||||
conn:on("receive", function(client, request)
|
||||
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||
|
||||
print("zrequest: \n---\n"..request.."---")
|
||||
|
||||
-- print("method: ", method) print("path: ", path) print("vars: ", vars)
|
||||
|
||||
if not string.find(request, "/favicon.ico") then
|
||||
print("coucou")
|
||||
if (method == nil) then
|
||||
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
|
||||
end
|
||||
print("method: ", method) print("path: ", path) print("vars: ", vars)
|
||||
_GET = {}
|
||||
if (vars ~= nil) then
|
||||
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||
_GET[k] = v
|
||||
print(k..": "..v)
|
||||
end
|
||||
end
|
||||
file_html=string.gsub(path, "/", "")
|
||||
-- print("file_html: ",file_html)
|
||||
send_file(client, file_html)
|
||||
end
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
|
||||
10
Mesures/solar_pv_energy/wifi_ap_stop.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_ap_stop.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.SOFTAP then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.STATION)
|
||||
end
|
||||
print("WIFI AP arrêté")
|
||||
11
Mesures/solar_pv_energy/wifi_cli_conf.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
|
||||
function wifi_cli_conf()
|
||||
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
|
||||
20
Mesures/solar_pv_energy/wifi_cli_start.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
|
||||
|
||||
function wifi_cli_start()
|
||||
print("\n wifi_cli_start.lua zf190310.1519 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI mode CLI only")
|
||||
wifi.setmode(wifi.STATION)
|
||||
elseif zmodewifi == wifi.SOFTAP then
|
||||
print("WIFI mode AP+CLI")
|
||||
wifi.setmode(wifi.STATIONAP)
|
||||
end
|
||||
wifi.sta.autoconnect(1)
|
||||
wifi.sta.connect()
|
||||
--f= "wifi_get_ip.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
|
||||
wifi_cli_start()
|
||||
wifi_cli_start=nil
|
||||
33
Mesures/solar_pv_energy/wifi_info.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Petit script pour afficher les infos actuel du WIFI
|
||||
print("\n wifi_info.lua zf190727.1220 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
|
||||
--wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP
|
||||
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI OFF")
|
||||
elseif zmodewifi == wifi.STATION then
|
||||
print("WIFI mode CLI")
|
||||
print("Connected IP:\n",wifi.sta.getip())
|
||||
local sta_config=wifi.sta.getconfig(true)
|
||||
print("Current client config:")
|
||||
print("\tssid:", sta_config.ssid)
|
||||
print("\tpassword:", sta_config.pwd)
|
||||
print("\tbssid:", sta_config.bssid)
|
||||
elseif zmodewifi == wifi.SOFTAP then
|
||||
print("WIFI mode AP")
|
||||
print("AP MAC:\n",wifi.ap.getmac())
|
||||
print("AP IP:\n",wifi.ap.getip())
|
||||
print("AP Connect:\n",wifi.ap.getconfig())
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
print("WIFI mode CLI+AP")
|
||||
print("Connected IP:\n",wifi.sta.getip())
|
||||
local sta_config=wifi.sta.getconfig(true)
|
||||
print("Current client config:")
|
||||
print("\tssid:", sta_config.ssid)
|
||||
print("\tpassword:", sta_config.pwd)
|
||||
print("\tbssid:", sta_config.bssid)
|
||||
print("AP MAC: ", wifi.ap.getmac())
|
||||
print("AP IP: ", wifi.ap.getip())
|
||||
end
|
||||
23
Mesures/solar_pv_energy/z_index.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 home page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 home page 190727.0941</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?field1=11&field2=12&field3=13">Page 4, test de récupération d'arguments pour un web service.</a><br>
|
||||
<a href="api_hub_temp.html?field1=11&field2=12&field3=13">API HUB Temp, test d'un web service hub de mesures de température.</a><br>
|
||||
<a href="disp_temp.html">Affichage des températures, affiche les températures mesurées.</a><br>
|
||||
<a href="page_qui_existe_pag.html">Page qui n'existe pas !</a><br>
|
||||
</h3>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
26
Mesures/solar_pv_energy/z_page1.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 1</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 1 190127.1445</h1>
|
||||
<br>
|
||||
Coucou c'est la page 1 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
La température est:
|
||||
|
||||
<%
|
||||
ztemp=ztemp+1
|
||||
zout(ztemp.."°C")
|
||||
%>
|
||||
|
||||
<br>Mais il fait encore trop froid !<br>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
51
Mesures/solar_pv_energy/z_page2.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 2 190127.1449</h1>
|
||||
<br>
|
||||
Coucou c'est la page 2 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
Voici un tableau dynamique écrit en Lua inline.<br><br>
|
||||
|
||||
Le code Lua pour créer ce tableau se trouve dans le code HTML de cette page et est exécuté sur le NodeMCU.<br>
|
||||
Les données du tableau viennent du NodeMCU !<br><br>
|
||||
|
||||
<%
|
||||
-- création du tableau sur le NodeMCUjuste juste pour la démo ici !
|
||||
zmac_adrs={}
|
||||
zmac_adrs["b8:d7:af:a6:bd:86"]={["zname"]="S7 zf", ["zrssi"]=45, ["ztime"]="12:03:36"}
|
||||
zmac_adrs["cc:c0:79:7d:f5:d5"]={["zname"]="S7 Mélanie", ["zrssi"]=50, ["ztime"]="14:23:46"}
|
||||
zmac_adrs["5c:f9:38:a1:f7:f0"]={["zname"]="MAC zf", ["zrssi"]=40, ["ztime"]="11:53:16"}
|
||||
zmac_adrs["d8:30:62:5a:d6:3a"]={["zname"]="IMAC Maman", ["zrssi"]=55, ["ztime"]="17:07:23"}
|
||||
%>
|
||||
|
||||
<table border='1'>
|
||||
<tr>
|
||||
<th>MAC</th><th>Name</th><th>RSSI</th><th>Time</th>
|
||||
</tr>
|
||||
<%
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
zout("<tr>\n")
|
||||
zout("\t<td>" .. k .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zname"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zrssi"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["ztime"]) .. "</td>\n")
|
||||
zout("</tr>\n")
|
||||
end
|
||||
%>
|
||||
</table>
|
||||
|
||||
<%
|
||||
-- libère la mémoire du tableau sur le NodeMCU qui avait été créé pour la démo ici !
|
||||
zmac_adrs=nil
|
||||
%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
50
Mesures/solar_pv_energy/z_page3.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 3</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 3 190505.1156</h1>
|
||||
<br>
|
||||
Coucou c'est la page 3 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
Voici le résultat du capteur non linéaire corrigé avec une table
|
||||
d'interpolation dans un fichier .csv sur la flash.<br><br>
|
||||
|
||||
Le code Lua pour afficher ce résultat se trouve dans le code HTML de cette page et est exécuté sur le NodeMCU.<br>
|
||||
Les données viennent du NodeMCU !<br><br>
|
||||
|
||||
<%
|
||||
zout("Il reste: "..node.heap().." de RAM !<br><br>\n")
|
||||
%>
|
||||
|
||||
<%
|
||||
zx0=83
|
||||
get_correction(zx0)
|
||||
zout("la valeur corrigée de "..zx0.." est "..zy0.."<br>")
|
||||
%>
|
||||
|
||||
<%
|
||||
zx0=91
|
||||
get_correction(zx0)
|
||||
zout("la valeur corrigée de "..zx0.." est "..zy0.."<br>")
|
||||
%>
|
||||
|
||||
<%
|
||||
zx0=100
|
||||
get_correction(zx0)
|
||||
zout("la valeur corrigée de "..zx0.." est "..zy0.."<br>")
|
||||
%>
|
||||
|
||||
<br>Yeah... cela fonctionne vachement bien !<br><br>
|
||||
|
||||
<%
|
||||
zout("Il reste: "..node.heap().." de RAM !<br><br>\n")
|
||||
%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
53
Mesures/solar_pv_energy/z_page4.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 3</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<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>
|
||||
|
||||
Test d'un web service qui fonctionne avec l'Active Server Page ZYX.<br><br>
|
||||
|
||||
Le code Lua pour afficher ce résultat se trouve dans le code HTML de cette page et est exécuté sur le NodeMCU.<br>
|
||||
Les données viennent du NodeMCU !<br><br>
|
||||
|
||||
<%
|
||||
zout("Il reste: "..node.heap().." de RAM !<br><br>\n")
|
||||
%>
|
||||
|
||||
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><br>Yeah... cela fonctionne vachement bien !<br><br>
|
||||
|
||||
<%
|
||||
zout("Il reste: "..node.heap().." de RAM !<br><br>\n")
|
||||
%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||