Page 1 of 1

Get analog value for anemometer (ESPEASY)

Posted: Sunday 01 November 2020 18:59
by bricololo
Hello,
I am using an analog anemometer on the analog input of an ESP8266.
I store the maximum wind value (gust) in a variable (var2).
But my code doesn't work because the variable doesn't seem persistent.
Here is my code :

Code: Select all

On System#Boot do
 let,1,0     //  [var#1]= speed ms
 let,2,0     //  [var#2]= max speed ms
 timerSet,1,10      // send every 10s
 endon

On Vent_analog#analog do
 // store speed value ms in var#1
 let,1,[Vent_analog#analog]*30/1024
  if [var#1]>[var#2]  // store max speed in var#2
   let,2,[var#1]
 endif
endon

On Rules#Timer=1 do  // 10s
 // send max speed
 SendToHTTP 192.168.1.30,8080,/json.htm?type=command&param=udevice&idx=59&nvalue=0&svalue=[var#2]
  timerSet,1,10
endon
I don't see my mistake.
Thanks for your help.

Re: Get analog value for anemometer (ESPEASY)

Posted: Sunday 01 November 2020 20:34
by marcojpolet
Hi!
Not sure what exactly is going wrong, but it might be that var2 never gets above zero. If var1 is the value from the picture, e.g. 10 or 15, the *30/1024 would be rounded down to zero I think. To debug you could consider pushing var1 to domoticz to see what that value is.

Regards,
Marco

Re: Get analog value for anemometer (ESPEASY)

Posted: Tuesday 03 November 2020 9:30
by bricololo
Hello,
I opened a syslog connection with the esp.
And I discovered abnormal messages every time I lose the value of my variables.

Code: Select all

Tue Nov 03 02:42:32 2020;192.168.1.49; <5>ESP_Weather EspEasy: WIFI : DHCP IP: 192.168.1.49 (ESP-Weather-2) GW: 192.168.1.1 SN: 255.255.255.0   duration: 49 ms
Tue Nov 03 02:42:32 2020;192.168.1.49; <5>ESP_Weather EspEasy: EVENT: WiFi#Connected
Tue Nov 03 02:42:32 2020;192.168.1.49; <5>ESP_Weather EspEasy: Webserver: start
Tue Nov 03 02:42:32 2020;192.168.1.49; <5>ESP_Weather EspEasy: firstLoopConnectionsEstablished
It looks like a loss of wifi which generates a reboot.
Any idea for what can create this problem?

I also have this message which does not generate a problem

Code: Select all

Tue Nov 03 02:42:33 2020;192.168.1.49; <5>ESP_Weather EspEasy: WD   : Uptime 0 ConnectFailures 0 FreeMem 21704 WiFiStatus 3