8. Custom Weather Station: Rain Sensor

in #diy4 years ago

Welcome back, this post is going to cover connecting and integrating the rain sensor from the wind / rain sensor assembly.

Connecting

Started off by cutting off the connector the sensor came with and adding my own connector that was easier to plug wires into. I have been using the following guide as a reference for most sensors. The rain sensor is unlabeled in the image in the top left. It has just two wires and connects to GPIO button 6.

rainfall_bb.png

Made a simple example program which ran without issue.

from gpiozero import Button
from signal import pause

rain_sensor = Button(6)
rain_count = 0

def spin():
    global rain_count
    rain_count = rain_count + 1
    print("spin" + str(rain_count))

rain_sensor.when_pressed = spin
pause()

Ros 2

Added the sensor as a new node in the project rain_sensor.py. The node operates a bit differently than other nodes in the project. Instead of sending messages at known intervals the node only sends messages when it records rainfall. This is sent as a header message, which includes a time stamp and a frame_id where I added the amount of rain recorded. The recorded rain amount is always the same. This data is meant to be captured into a database then other more interesting post processing information such as rain fall per period of time can be reported. The message is reported on the /rainfall topic.

I will be adding this sensor along with the wind speed and wind direction to the master launch file later, for now launch with ros2 run mimir rain_sensor

Please like and subscribe.

  1. Building a Custom Weather Station in ROS2 Parts and Plans (DIY BLOG)
  2. Custom Weather Station: Installing Ros2 (DIY BLOG)
  3. Custom Weather Station: Temperature, Pressure, Humidity Sensor Install
  4. Custom Weather Station: UV Sensor install
  5. Custom Weather Station: Ground Temperature Sensor
  6. Custom Weather Station: Wind Speed Sensor
  7. Custom Weather Station: Wind Direction Sensor

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.028
BTC 65780.00
ETH 3522.63
USDT 1.00
SBD 2.47