Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Visualizing Rainfall Amounts From Acurite 5n1 Sensor To InfluxDB and Grafana

  1. Home

By Khalid on 2022/08/16 - 12:57, last updated 2022/11/12 - 11:46

Many weather sensors just report a cumulative rainfall amount to their display unit. That is, when installed the sensor will start with 0 millimeters, and then as rain falls, it will just keep adding to that number, until the sensor loses power, or is reset.

Since it took me a long time to reach a working solution, I am posting this information to save people looking for the same hours and hours of fruitless searching, and frustrating experimentation.

Acurite 5n1 Message Capture And Conversion To MQTT

One such sensor is the Acurite 5n1.

The details of capturing the messages from the sensor are beyond the scope of this article.

But in summary, this is done using any RTL-SDR USB dongle, with the excellent rtl_433 program, and some Python glue code to start rtl_433, then capture the message and transform it to JSON, and send it to the MQTT server.

From MQTT, the messages are captured to any application that is subscribed to the topic. This includes Home Assistant and Weewx.

Acurite 5n1 MQTT Message Format

A sample partial message from the above sensor transformed into MQTT JSON format is as follows:

{
  "time": "2022-08-16 11:54:46",
  "model": "Acurite-5n1",
  "subtype": 49,
  "id": 1234,
...
  "wind_avg_km_h": 4.3112,
  "wind_dir_deg": 135,
  "rain_mm": 42.12,
}

The field "rain_mm" keeps increasing as more rain falls, and then resets to zero if there is a power loss on the sensor.

The fact that the 'rain_mm' amount is cumulative poses a challenge to some applications, but not others. For example, Weewx handles all this internally without any special configuration.

Other applications do not have such built-in smarts, and need to be told how to calculate rainfall properly, by minute, week, month, ...etc.

One application that I use is Grafana which is an interactive visualization tool, with an underlying InfluxDB time series database that is fed from Home Assistant MQTT.

The key here is to use non_negative_difference() for the bar graph, and adding cumulative_sum() for the gauge, as follows:

Grafana InfluxDB Panel Bar Graph For Rainfall

This panel will display a bar graph for the time range that is selected.

FROM default mm WHERE entity_id = local_rainfall
SELECT field(value), last(), non_negative_difference()
GROUP BY time($__interval)

Grafana InfluxDB Panel For Rainfall Amount

This panel will display the cumulative amount of rain for the time range that is selected.

FROM default mm WHERE entity_id = local_rainfall
SELECT field(value), last(), non_negative_difference(), cumulative_sum()
GROUP BY time($__interval)

The above two panels will look like this:

Contents: 
Software
Tags: 
Acurite
MQTT
Grafana
InfluxDB
Home Assistant
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.