Closed bassicrob closed 4 years ago
Testing on the bench: "Final" Wiring With Keystone panel:
I just need to finish the connections at the Wemos and put it all in an enclosure.
I combined the rain and wind RJ-11 into a single Cat5 run to the Wemos. Second Cat5 cable is for i2c communication (pair each for 3.3v-Gnd-SDL-SCA). Led is just single-pin out-wire to monitoring unit (ran out of wires!). Fritzing:
Nice work @bassicrob! Do you plan to do a post on Home Assistant forum? Would be nice. I plan to do the same thing but only with Wind (gauge/direction) and rain using a SEN-15901 kit. Using a RJ45 cable is clever! So the ESP is inside your home and sensors are outside? Do you think that it will work with a 15m RJ45 cable?
I think I may have just responded to your comment on the HA forum?
The sensors are outside on my garage. I replaced the guts of the transmitter and temperature with a PCB with an LED and i2c BME280. The LED is fed with its own wire, the i2c is run off about 15' of cat5e cable to the inside of my garage where the Wemos lives. The rain, wind, and anemometer are combined from a homemade patch panel where the wires enter into my garage, and then run back to the Wemos with a 25' CAT5 cable (I ran out of cable in the pull-box and had a pre-made one on hand). I used like-colored pairs for all connections. I found this was very important to prevent cross-talk. 15m run? maybe. try i on the bench and see if it works!
Hey guys. Thanks for using this. Will think about adding your wind direction part to the code, though I don’t have it my self. Regarding the rain pulse counter going to zero, we’ll that is how that component works. If you want another behavior I suggest using an integrator on top of that (like the total daily rain). @bassicrob why not make a fork of my code to show and share your own contributions :)
Excuse my ignorance. Can you tell me how to code calculate windspeed for a davis ? According to the Davis Anemometer technical document 1 mile per hour is equal to 1600 revolutions per hour.
Excuse my ignorance.
Can you tell me how to code calculate windspeed for a davis ?
According to the Davis Anemometer technical document 1 mile per hour is equal to 1600 revolutions per hour.
First of all you need to know Home many pulsen your sensor gives per revolution/rotation and per minute. From this I have calculated my sensors rotations per second because I want to measure wind speed in meters per second.
Then you must calculate the circumference of the anemomenter. The radius (r) of mine is 0.09m or 9cm. Circumference formula is r2pi
Multiplying circumference and rotations per second gives roughly the wind speed. But I have added a calibration factor of 1.18 to compensate for the fact that the anemometer will not rotate at full wind speed but rather a bit slower due to friction drag and more.
So basically your calculation must be adapted the size of you anemometer, pulses per revolution and losses.
Thanks for the reply. I get this from Arduino code site was trying to convert to Esphome yaml.
How to Measure the Wind Speed The wind cups have a reed switch mounted inside near the shaft. This switch is activated once per revolution of the cups. To calculate the wind speed we apply a formula that converts the number of time the switch activates per period of time to miles per hour.
According to the Davis Anemometer technical document 1 mile per hour is equal to 1600 revolutions per hour.
Using the formula V = P(2.25/T) we can calculate the speed in miles per hour. More here http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer-wind-speed
Thanks for the reply.
I get this from Arduino code site was trying to convert to Esphome yaml.
How to Measure the Wind Speed
The wind cups have a reed switch mounted inside near the shaft. This switch is activated once per revolution of the cups. To calculate the wind speed we apply a formula that converts the number of time the switch activates per period of time to miles per hour.
According to the Davis Anemometer technical document 1 mile per hour is equal to 1600 revolutions per hour.
Using the formula V = P(2.25/T) we can calculate the speed in miles per hour.
More here
http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer-wind-speed
To make it clearer I convert this to SI units. I suggest everyone to do all calculations in SI units and the convert to whatever you want to be displayed.
1600 rev/h = 1 miles/h = 1.609 km/h 1600 m/h This implies that 1600rev = 1609 m And 1 rev = 1609 / 1600 = 1.006 m So the circumference is 1m. Use 1m as circumference in my code and skip the calibration factor.
So if you use update_interval: 60s Your multiply filter is approximately 1/60 = 0.0167
Thank you, You rock.
Now reading both of your replies I mostly get how the formula and code works.
At first I did not understand the formula on speed calculations. I am a dumb ass and always need real world hands on example.
In any of the example I have found online it was NOT explained that
#circ_m=0.09*2*3.14 = 0.5652
Is the calculation of the size of the wind cups rotation converted to time.
Every different design is going to be different size and I'm sure most will miss this fact if they just use your code that is linked in esphome.
One question so I understand how it works
What is the 2 in this line?
I think I get the 60 is a time factor seconds ?
rotations_per_sec = pulses/2/60
Thank you very much for taking the time to help me and others learn.
thestovedoc.com.
Thank you, You rock.
Now reading both of your replies I mostly get how the formula and code works.
At first I did not understand the formula on speed calculations. I am a dumb ass and always need real world hands on example.
In any of the example I have found online it was NOT explained that
#circ_m=0.09*2*3.14 = 0.5652
Is the calculation of the size of the wind cups rotation converted to time.
Every different design is going to be different size and I'm sure most will miss this fact if they just use your code that is linked in esphome.
One question so I understand how it works
What is the 2 in this line?
I think I get the 60 is a time factor seconds ?
rotations_per_sec = pulses/2/60
Thank you very much for taking the time to help me and others learn.
thestovedoc.com.
When writing comments in code without review it tends not to be fully clarifying 😃 But hey, mistakes are part of being human and asking questions is a underestimated social activity 😉
By the way, my 2 is for 2 pulses per revolution...
Thank you, You rock. Now reading both of your replies I mostly get how the formula and code works. At first I did not understand the formula on speed calculations. I am a dumb ass and always need real world hands on example. In any of the example I have found online it was NOT explained that
#circ_m=0.09*2*3.14 = 0.5652
Is the calculation of the size of the wind cups rotation converted to time. Every different design is going to be different size and I'm sure most will miss this fact if they just use your code that is linked in esphome. One question so I understand how it works What is the 2 in this line? I think I get the 60 is a time factor seconds ?rotations_per_sec = pulses/2/60
Thank you very much for taking the time to help me and others learn. thestovedoc.com.When writing comments in code without review it tends not to be fully clarifying 😃 But hey, mistakes are part of being human and asking questions is a underestimated social activity 😉
By the way, my 2 is for 2 pulses per revolution...
Hi , how will be if i have 3 magnes ? and hall is connected to D7
''
filters:
If you have 3 pulsen per revolution (3 magnets)? Then the calculation would be ...
rotations_per_sec = pulses/3/60
... rather than...
rotations_per_sec = pulses/4/60
... which would correspond to 4 pulsen per revolution.
If you have 3 pulsen per revolution (3 magnets)? Then the calculation would be ...
rotations_per_sec = pulses/3/60
... rather than...
rotations_per_sec = pulses/4/60
... which would correspond to 4 pulsen per revolution.
THX will check
Hi, thx its working. But i have another problem when is connected to Esp8266 , is restarting every random minutes
Hi, thx its working. But i have another problem when is connected to Esp8266 , is restarting every random minutes
The restarts you have is not something I have experienced. Make sure you have configured your specific board correctly in esphome and seek general support in esphome forums and discord etc.
I have set platform: ESP8266 board: nodemcuv2
but i have ESP8266 nodemcuv3 th will try
Hi, If anyone have an idea about the wind speed calculation explained in this comment https://github.com/hugokernel/esphome-weather-station/issues/6#issuecomment-1173526588 Thx !
So i have another question what will be multiply if i have only that informations ? Resolution: 0.0875 m/s (that is, if 20 pulse detected in 1s, the wind speed is 1.75 m/s, and 3.5m/s if 40 pulse detected)
Thanks for all the sharing!
This is my version, running on NodeMCU v3:
esphome:
name: weather
friendly_name: Weather Station
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: <redacted>
ota:
- platform: esphome
password: <redacted>
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none # for keeping ESP8266 online
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Weather2 Fallback Hotspot"
password: <redacted>
# captive_portal:
i2c:
frequency: 100kHz #try for longer distance
sensor:
- platform: pulse_counter
pin:
# pin D5
number: GPIO14
mode: INPUT_PULLUP
unit_of_measurement: 'm/s' ##change to m/s if metric
name: 'Wind sensor'
icon: 'mdi:weather-windy'
id: my_wind
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
internal_filter: 50us
update_interval: 60s
#rotations_per_sec = pulses/2/60
#circ_m=0.09*2*3.14 = 0.5652
#mps = 1.18*circ_m*rotations_per_sec
#mps = 1.18*0.5652/2/60 =0,0055578
filters:
- multiply: 0.0055578 #use for m/s
# - multiply: 2.237 #m/s to mph
- sliding_window_moving_average:
window_size: 4
send_every: 1
- multiply: 0.04973 #1.492mph switch to close 1/sec per spec, pulse/sec (/60/2)*1.492
# - multiply: 0.0124327986 #m/s * mph conversion
- platform: template
id: wind_knots
unit_of_measurement: 'knots'
name: "Wind Speed Knots"
lambda: return id(my_wind).state * 0.0055578 * 1.94384449;
- platform: pulse_counter
pin:
# pin D6
number: GPIO12
mode: INPUT_PULLUP
unit_of_measurement: 'mm' ##change to mm if metric
name: 'Rain gauge'
icon: 'mdi:weather-rainy'
id: my_rain
internal: true
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
internal_filter: 50us
update_interval: 60s
#buckets = pulses
#mm_per_bucket=0.2794
#rain = buckets*0.2794
filters:
- multiply: 0.2794 #for mm
# - multiply: 0.011 # to inches
accuracy_decimals: 3
- platform: integration
name: "Rainfall per min"
id: rain_per_min
time_unit: min
unit_of_measurement: 'mm'
sensor: my_rain
- platform: total_daily_energy
name: "Total Daily Rain"
power_id: my_rain
unit_of_measurement: 'mm' ###change to mm if metric
icon: 'mdi:weather-rainy'
# x60 To convert to aggregated rain amount
filters:
- multiply: 60
### ADD WIND DIRECTION
- platform: adc
id: adc_sensor
pin: A0
name: ADC
internal: true
update_interval: 10s
filters:
# - multiply: 3.3 ##built into Wemos
# - multiply: 0.0009775171 #1/1023
- multiply: 0.96688422 # max is 4137, while example code has 4000
accuracy_decimals: 2 ##IMPORTANT to get resolution for resistance sensor!
- platform: resistance
sensor: adc_sensor
id: resistance_sensor
configuration: DOWNSTREAM
resistor: 10kOhm
internal: true
name: Resistance Sensor
accuracy_decimals: 1
filters:
- heartbeat: 10s
on_value:
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 3100
below: 3200
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "N"
- sensor.template.publish:
id: wind_heading
state: 0.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 1600
below: 1700
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "NE"
- sensor.template.publish:
id: wind_heading
state: 45.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 250
below: 350
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "E"
- sensor.template.publish:
id: wind_heading
state: 90.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 550
below: 650
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "SE"
- sensor.template.publish:
id: wind_heading
state: 135.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 900
below: 1100
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "S"
- sensor.template.publish:
id: wind_heading
state: 180.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 2300
below: 2450
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "SW"
- sensor.template.publish:
id: wind_heading
state: 225.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 3900
below: 4100
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "W"
- sensor.template.publish:
id: wind_heading
state: 270.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 3500
below: 3800
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "NW"
- sensor.template.publish:
id: wind_heading
state: 315.0
- platform: template
name: "Wind Heading"
id: wind_heading
unit_of_measurement: "°"
### ADD WIND CARIDNAL DIRECTION
### Your values may differ!
# Direction -- Resistance -- ADC Voltage
# N -- 3132Ω -- 0.79v
# NE -- 1643Ω -- 0.47v
# E -- 292Ω -- 0.10v
# SE -- 602Ω -- 0.19v
# S -- 974Ω -- 0.29v
# SW -- 2372Ω -- 0.63v
# W -- 3997Ω -- 0.94v
# NW -- 3657Ω -- 0.88v
- platform: sun
name: Sun Elevation
type: elevation
update_interval: 120s
- platform: sun
name: Sun Azimuth
type: azimuth
update_interval: 120s
## ADD Beufort
sun:
latitude: 52.3662558
longitude: 4.8354183
text_sensor:
- platform: template
name: "Wind Cardinal Direction"
id: wind_dir_card
- platform: sun
name: Next Sunrise
type: sunrise
update_interval: 4h
- platform: sun
name: Next Sunset
type: sunset
update_interval: 4h
# light:
# - platform: binary
# id: status_light_remote
# output: status_led_remote
output:
- platform: gpio
pin:
# pin D7
number: GPIO13
mode: OUTPUT
id: status_led_remote
interval:
- interval: 30s
then:
- output.turn_on: status_led_remote
- delay: 150ms
- output.turn_off: status_led_remote
- interval: 60s
then:
- sensor.integration.reset: rain_per_min
# Enable time component to reset energy at midnight
time:
- platform: sntp
id: my_time
Remarks:
bme280
installed, but if I would, then I'd need to change the platform to bme280_i2c
power_save_mode: none
fixed it - still quite a discussion subject on the forums[WT32-ETH01](https://www.google.com/search?q=WT32-ETH01)
for this project, but now I hope my wifi is in reach, on the roof :);
in lambda
I see that you are actively working on this integration as well. I used your yaml as a basis and made some improvements of my own. It, like yours, is still a work in progress, but I do have the anemometer working. I am working to reduce the readings and "average" the headings to account for the vane swinging wildly.
I also changed my units to imperial ;) I am also using a BME280 over 15' of CAT5 cable successfully on i2c inside the monitoring unit on the mast with a status LED.
An issue I discovered was although the total rain integration works, the my_rain sensor only measures upon the bucket tip then goes back to '0' between tips.
Within Homeassistant, I created a "Average Wind Speed" sampling and record gusts. It worked pretty well for a few recent storms, and data is comparable to local PWS.
configuration.yaml