Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New windmeter sensor #8283

Merged
merged 12 commits into from
May 7, 2020
Merged

New windmeter sensor #8283

merged 12 commits into from
May 7, 2020

Conversation

malbinola
Copy link
Contributor

@malbinola malbinola commented Apr 26, 2020

This sensor add support to simple cup anemometers based on reed switch (like https://www.amazon.it/08880905D-ANEMOMETRO-SENSORE-CRISTAL-ALMOT/dp/B07CJ83XF5).
It provides like Tx20 sensor (from which this is inspired) info about instant, min, max and average wind speed.

The configuration command allow to customize parameters (radius, pulses per rotation, reed bounce time and correction factor) related to the specific anemometer in use.

Lastly, how to deal with support_features.ino changes?
Can i take the next free one like below?

Related issue (if applicable): #5391, #2132

Checklist:

  • The pull request is done against the latest dev branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR.
  • The code change is tested and works on core Tasmota_core
  • The code change is tested and works on core ESP32
  • The code change pass travis tests. Your PR cannot be merged unless tests pass
  • I accept the CLA.

@malbinola malbinola marked this pull request as ready for review April 26, 2020 18:25
@ascillato
Copy link
Contributor

In tasmota/support_features.ino your added lines shouldn't be commented out.

@malbinola
Copy link
Contributor Author

In tasmota/support_features.ino your added lines shouldn't be commented out.

Yes, ok.. done! I was trying to figure out if that kind of modification could be done myself.

malbinola and others added 5 commits May 2, 2020 15:10
# Conflicts:
#	tasmota/language/bg-BG.h
#	tasmota/language/cs-CZ.h
#	tasmota/language/de-DE.h
#	tasmota/language/el-GR.h
#	tasmota/language/en-GB.h
#	tasmota/language/es-ES.h
#	tasmota/language/fr-FR.h
#	tasmota/language/he-HE.h
#	tasmota/language/hu-HU.h
#	tasmota/language/it-IT.h
#	tasmota/language/ko-KO.h
#	tasmota/language/nl-NL.h
#	tasmota/language/pl-PL.h
#	tasmota/language/pt-BR.h
#	tasmota/language/pt-PT.h
#	tasmota/language/ro-RO.h
#	tasmota/language/ru-RU.h
#	tasmota/language/sk-SK.h
#	tasmota/language/sv-SE.h
#	tasmota/language/tr-TR.h
#	tasmota/language/uk-UA.h
#	tasmota/language/zh-CN.h
#	tasmota/language/zh-TW.h
# Conflicts:
#	tasmota/language/bg_BG.h
#	tasmota/language/cs_CZ.h
#	tasmota/language/de_DE.h
#	tasmota/language/el_GR.h
#	tasmota/language/en_GB.h
#	tasmota/language/es_ES.h
#	tasmota/language/fr_FR.h
#	tasmota/language/he_HE.h
#	tasmota/language/hu_HU.h
#	tasmota/language/it_IT.h
#	tasmota/language/ko_KO.h
#	tasmota/language/nl_NL.h
#	tasmota/language/pl_PL.h
#	tasmota/language/pt_BR.h
#	tasmota/language/pt_PT.h
#	tasmota/language/ro_RO.h
#	tasmota/language/ru_RU.h
#	tasmota/language/sk_SK.h
#	tasmota/language/sv_SE.h
#	tasmota/language/tr_TR.h
#	tasmota/language/uk_UA.h
#	tasmota/language/zh_CN.h
#	tasmota/language/zh_TW.h
@arendst arendst merged commit 40d71e7 into arendst:development May 7, 2020
@malbinola
Copy link
Contributor Author

malbinola commented May 17, 2020 via email

@lacrimosa2k2
Copy link

can i report a bug to the windmeter here? when using 3 pulses per rotation, it shows only 2,14 or 4,27 as windspeed

@malbinola
Copy link
Contributor Author

can i report a bug to the windmeter here? when using 3 pulses per rotation, it shows only 2,14 or 4,27 as windspeed

Hi @lacrimosa2k2 , calculations rely on a numeric counter that counts pulses on the selected GPIO pin; maybe count are not reported correctly due to specific setup conditions.
If you set weblog level to 3 or 4 web, the console begins showing this log message reporting the actual count. Then you will be able to check if counts really reflect complete turns (3 counts for each turn). If anything mismatch maybe you have to tweak debounce time a little bit. I hope this helps.

@lacrimosa2k2
Copy link

lacrimosa2k2 commented May 29, 2020

can i report a bug to the windmeter here? when using 3 pulses per rotation, it shows only 2,14 or 4,27 as windspeed

Hi @lacrimosa2k2 , calculations rely on a numeric counter that counts pulses on the selected GPIO pin; maybe count are not reported correctly due to specific setup conditions.
If you set weblog level to 3 or 4 web, the console begins showing this log message reporting the actual count. Then you will be able to check if counts really reflect complete turns (3 counts for each turn). If anything mismatch maybe you have to tweak debounce time a little bit. I hope this helps.

thanks that was a logik problem by my wire,

i have figured out another problem that is crazy.

i have a pulse signal (windmeter) on gpio4 or gpio5 (i testet it on all avaible pins) and and the windmeter turns and comes pulse in, and then i restart the esp, it could not boot complete, it reboots so often that its looses the config.
when i dissconect the pulse cable from the esp and reboot and after boot complete add it, it runns fine.
the pulse ar not the error, when i disable (select none from the gpio) the esp reboots without problems and pulses are connected

@sergios100
Copy link

Hi I can confirm lacrimosa2k2 Issue, because I have the exact same behaviour.
I tried gpio4 gpio5 and gipo12 as well. As soon as there are Impulses sent to these Pins, ESP does not boot properly, crashes immediately an reboots so often it corrupts even the config!

`
15:00:22 APP: Restarting

ets Jan 8 2013,rst cause:2, boot mode:(3,0)

load 0x4010f000, len 3456, room 16
tail 0
chksum 0x84
csum 0x84
va5432625
~ld
00:00:00 CFG: Loaded from flash at F9, Count 51
00:00:00 Project tasmota Tasmota2 Version 8.3.1(tasmota)-2_7_1
00:00:00 WIF: Connecti 31o AP1 ***** Channel 11 BSSId ::::: in mode 11N as Tasmota2...
00:00:03 WIF: Connected
00:00:03 HTP: Web server active on Tasmota2 with IP address 192.168.1.37
15:00:28 RSL: INFO1 = {"Module":"Generic","Version":"8.3.1(tasmota)","FallbackTopic":"cmnd/DVES_BC58D4_fb/","GroupTopic":"tasmotas/cmnd/"}
15:00:28 RSL: INFO2 = {"WebServerMode":"Admin","Hostname":"Tasmota2","IPAddress":"192.168.1.37"}
15:00:28 RSL: INFO3 = {"RestartReason":"Software/System restart"}

Exception (0):
epc1=0x4021abec epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

'>>>stack>>>
`
Seems to me being some Issue with Interrupt handling? Getting a new interrupt pulse while doing something else seems to lead to a unhandled exception.
Could somebody try to reproduce this, and fix it?
Do I need to report this to some sort of "bug-report" on git-hub (sorry, I am a newbie).

Regards!
sergios100

@malbinola
Copy link
Contributor Author

@sergios100 @lacrimosa2k2 What device are you using? ESP8266?
I've tested it on Sonoff 4CH PRO R2 (on GPIO3) and Sonoff Dual R2 (on both button GPIOs) without any exceptions. I had only some bad experience with 4CH and GPIO2 (sda) where due to esp builtin logic if pulled low on boot causes boot failure.

Are you sure that your GPIOs are free for external uses?

@lacrimosa2k2
Copy link

lacrimosa2k2 commented Jun 1, 2020

@malbinola i have exact the same ecxeption

i tested it on a sonoff t1 2ch and a sonoff basic r2 (ESP8285). both on pins GPIO1/4/5/14 all same error. i think @sergios100 and me dont uses hardware buttons, i have soldered on the pins.
but the counter function runs fine on all GPIO with the wind sensor impulses
i will test it on a wemos d1 (EPS8286) too.
i think the best is when it runs on tx for sonoff devices, there pins a routet out to solder points (yes serial log are disabled)

my config is a hall sensor with digital out that goes high on signal, a npn transistor to invert the signal so that the high pin from the esp goes to ground when a magnet comes in range .

sorry for bad english, greets from germany

@sergios100
Copy link

I use a ESP8266 NodeMCU V3 on a Base Board ProtoShield with Voltageregulator:
https://www.bastelgarage.ch/esp8266-nodemcu-v3-kompatibles-development-board

As far as I know, the Pins I tested (gpio4, gpio5 and gipo12) should be directly routed to the solder PIN on the ProtoShield and free of any other functionality.
https://tasmota.github.io/docs/Peripherals/#restrictions

I use an Eltako WindMeter https://www.eltako.com/fileadmin/downloads/de/datenblatt/Datenblatt_WS.pdf

(I guess inside is a Reed-Switch in series with a 120Ohm Resistor which gets orbited by two magnets per revolution. So I measure infinite Ohm and two times 120Ohms per Revolution on the to Cables that leave the Sensor).
One "pin" of the Eltako is connected to GND on the ProtoBoard, the other "pin" to gpio4, 5 or 12). No Pullup, nothing.
I never had any Buttons attached to the Board. As soon as I had issues and started troubleshooting I disconected a previoulsy attached i2c Luminosity Sensor, just to be sure the issues are related to the WindMeter only.

I have to mention, that this setup was running fine using tasmotas counter function and some rules, there were no crashes. But I had to do the speed calculations in NodeRed and I did not have the nice Sensor-Data (avg. Speed, min, max, actual) on the Web-Interface.

Greetings from Switzerland!

@lacrimosa2k2
Copy link

@malbinola so i tested it with a wemos d1 mini with the same result, it hangs on bootloop until the config is resetet. with the counter function it runs fine

@lacrimosa2k2 lacrimosa2k2 mentioned this pull request Jun 3, 2020
6 tasks
@malbinola
Copy link
Contributor Author

@lacrimosa2k2, @sergios100
Any news on the issue after commenting out debug sentence in ISR?
I've submitted another pull that should improve the interrupt management. It's merged already, so free to try it. ;)

@lacrimosa2k2
Copy link

lacrimosa2k2 commented Jun 8, 2020

@malbinola i try it without the ISR, and no crashes :)
but i think the code is a little bit slow, my 3 pulses are registred when i turn it by hand, but when it runs fast the wind speed displays max 12,xx
what changes for the interupt managment?

btw another question, i cant find anything for a powermeter that gives 1000 pulses per KWh, i use a counter for and give him the aktual powermeter numbers.

can you make a copy of your windmeter script to like a a powermeter?

@kugelkopf123
Copy link
Contributor

@lacrimosa2k2 have a look on the sml/scripter section in the docu.
You can define different options for a counter. Like for a water or gasmeter. https://tasmota.github.io/docs/Smart-Meter-Interface/

Sent with GitHawk

@lacrimosa2k2
Copy link

@lacrimosa2k2 have a look on the sml/scripter section in the docu.
You can define different options for a counter. Like for a water or gasmeter. https://tasmota.github.io/docs/Smart-Meter-Interface/

Sent with GitHawk

thanks, i have seen this, but can i use rules and script at the same? i use rules at the moment, the sml config is so verry big and confusing

@kugelkopf123
Copy link
Contributor

...

@lacrimosa2k2 no. Not at the same time.
But nearly everything that you can do with rules is possible within the scripter, too.

Sent with GitHawk

@malbinola
Copy link
Contributor Author

malbinola commented Jun 8, 2020 via email

@lacrimosa2k2
Copy link

lacrimosa2k2 commented Jun 8, 2020

@malbinola i have test the debounce 2-10ms

@kugelkopf123 i have one compuled file for all my devices with different sensors etc, i think i dont change all to script, i hope it give a simple way to calculate watts consumption

@malbinola
Copy link
Contributor Author

@lacrimosa2k2 yes, they are already low values
Can you test the last code? The recent PR make use of volatile marking of variables in ISR, i've never had experiences in this but docs says that it may avoid inaccurate storage of values.

If it doesn't work, next step could be to completely disable debounce check, keeping only the counter increment in ISR. But i think that you have do add a such sort of hw-debounce like this outside. In theory in this way we are sure that we have the right counter value without any time-dependent debounce logic.

It's strange because current code is acting like the counter sensor that you were using before. Isn't it? During my tests i had a similar issue (speed capped at fixed value) but i solved lowering the debounce time, but my anemometer has only 1 magnet.

@lacrimosa2k2
Copy link

@malbinola i will try it at the week with the new code

@lacrimosa2k2
Copy link

@malbinola tested it, without visibil change. the windmeter works, but the counts are to low.
when i set the signals to 1 it works better, it is possibil that is a simple little math fail?

@MassimoSporchia
Copy link

@malbinola Hey Matteo!
Can you share on the docs sample rules on how to interact with the sensor wind speed on intervals? (e.g. trigger relay1 when windspeed is > 10km/h for 10 secs)
Should I use telemessages and teleperiod from Sensor68? ( https://tasmota.github.io/docs/Commands/#sensors )

@malbinola
Copy link
Contributor Author

@lacrimosa2k2 i cannot exclude that aren't problems with different pulsesXrot, my situation (value 1) is the simplest case.
In any case, counts are the base for all calculations so we have to make sure that they are effectively right. Counts are resetted in the ISR, so you can try to comment-out line 131 and print counter value in a debug sentence (i hope you can bypass reset issue you had in past). In this way you can figure out if counts really reflect anemometer turns. Again with 1 turns in my case, this do not impact in any way. :)

Once you have a reliable value of counter you can concentrate on speed: looking at the formula the only key point that can differ from my situation is the part "(WindMeter.counter / Settings.windmeter_pulses_x_rot)", an explicit cast to float on counter value is maybe missing (like "(float)WindMeter.counter").

Hi @MassimoSporchia

Can you share on the docs sample rules on how to interact with the sensor wind speed on intervals?

Unfortunately i do not have any experience with tasmota's rules/triggers, i use windmeter sensor through HomeAssistant automations.

Should I use telemessages and teleperiod from Sensor68?

Speed and other data (like average) are included in tele messages so the are sent according the main tele period setting (if i remember well 300 is the default). If you want to be more reactive you can obviously lower that value (but you will have lot of tele messages overhead especially in absence of wind), otherwise you can set the minimum percentage change between current and last reported speed (5th option with Sensor68 command). So, if the current speed differs from the last reported by a percentage value greater than the set threshold, the sensor will trigger/send an optional tele message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants