BirdyIO: bird nesting IoT

In 2020, while watching small birds nesting in my garden, I decided that I wanted to learn more – from a time series data mining point of view – about their apparent restless activity. After some initial brainstorming I realized I got into something really cool relating to digital electronics, sensors and signal processing & storage. Here’s some implementation detail:

+ Birdhouse fitted with dual-channel, pulsed-IR (38kHz) barriers
+ Atmega 328 µ-Controller acting as pulse source for the IR LEDs
+ Postgres database for long term event storage
+ NodeMCU ESP8266-12E µ-Controller as master:
  • fifo-type binary event buffer for 2 event channels (IR light barriers)
  • regular-expression style evaluation of event pattern + pattern duration (see table below):
  • detection of direction: (out > in) vs. (in > out) and depth of a connected action:
    • show: penetrate, retract from single barrier
    • peek: penetrate, retract through two barriers
    • look: penetrate, retract through two barriers, freeing initial one
    • walk: penetrate, retract through two barriers, passing both ones
  • anti-flicker filtering, suppressing repeated state alternations < 10ms
  • detection loop frequency achieved: ~ 800Hz
  • NTP time sync
  • periodic sensor self-checks on IR barrier function
  • birdhouse connected to wifi home network
  • local buffering of up to 200 qualified events in a transactional log
  • birdhouse webservice (json) endpoint to deliver event logs to a backend
  • Server backend (python) polling BirdyIO endpoint for new events

Event table

how this looks like in practice

full in/out transitions and other events in the 2020 nesting season

sample JSON message delivered by BirdyIO endpoint
directed in>out / out>in transitions (blue) and other activities (red) in the 2020 season

AirStation: environmental monitoring

Wifi-enabled weather stations are available in a great variety, usually covering: temperature, atmosperic pressure and relative humidity. Through my own interest in environmental factors related to covid-19 and the possible impact on the 2020 lockdown on air quality, I decided to use my existing knowledge in IoT/digital electronics to build a comprehensive, multi-sensor data source for long term monitoring and time series analysis

current project state:

After a few month of test operations in late 2021, I experiences frequent dropouts and system reboots, specifically in early morning low temp & moisture conditions. I concluded: NodeMCU needs improved sealing to withstand adverse weather conditions, actual sensors appear tolerant to moisture and temperature variations but MCU needs efficient sealing. Moreover, O3 sensor calibration requires temperature and rH% stability over several days of sample time. This needs to be repeated in a controlled environment.

implementation details:

  • NodeMCU ESP8266-12E µController with sensors:
    • BME280, digital, temperature, pressure and rel. humidity
    • SDS011, digital + laser-based, 2.5µm/10µm particulate matter (PM)
    • Winsen MQ131, analog, low-concentration O3 sensor
  • Custom library myTaskScheduler for asynchronous scheduling of data sampling (this library is also central to the StratoExplorer project).
  • µC acting as WiFi client in local network
  • OTA (over the air) updating of NodeMCU code
  • JSON endpoint to deliver sensor data:
    • average + standard deviation in sample interval
    • min/max values in sample interval
    • NTP based time information
    • sensor health status
  • Normal atmospheric pressure (QNH, hPa) corrected for temperature and humidity according to DWD standards
  • O3 sensor corrected for temperature and humidity
  • O3 sensor (long term) calibration mode
  • Backend process (python, cronjob) polling AirStation endpoint for data
  • Postgres database for long term storage and data analysis
prototype assembly (from left to right) of O3 / laser-PM / T-P-rH sensors and NodeMCU ESP8266-12E

covid-19 & air quality

A couple days after attending the EU Space Conference in Brussels end of January 2020, I got sick with fever and mild respiratory and digestive tract symptoms, and additionally, what I remember as the perception of a strange odor or somewhat misled olfaction. Things improved after about a week and I did not spend a though whether this could have been a sars-cov-2 infection (note: later on, I discovered that the first cases officially identified and recorded in Belgium date back to early February 2020 which indeed made it plausible that my infection could have been the real thing). Covid-19 at this time still seemed to be an Asian “problem” with news gradually spreading on infection rates picking up in the Middle East and eventually Southern Europe. As we all know, the situation got increasingly dynamic in March and April with aggravating reports on high death tolls in Iran and Northern Italy. In the evening of April 27 2020, I had a chat with friends from the bio-medical field who had launched into an analysis of molecular mechanisms and patient phenotypes associated with the disease. As a physicist, I had less to contribute from a solely medical point of view, but I had already undertaken own research on data available on environmental factors – specifically those who seem to relate to pulmonary function, which appears most critically targeted by the virus. Although direct pathogenic impact and the complexity of the human immune and inflammatory response seem to be a rich playground for research, I was not ready to give up the idea that environmental factors, notably particulate matter and ground based (tropospheric) ozone, are contributing factors to a deadly course of the disease.

source: EEA Report No 13/2017 “Air quality in Europe – 2017” Section 5.2 (https://www.eea.europa.eu/publications/air-quality-in-europe-2017)

Particulate matter (PM) in ambient air is commonly recognized as an agent that induces lung damage and aggravation of chronic disease, such as asthma. Ozone (O3), which is known to exercise strong oxidative stress on the pulmonary system, not only occurs in a layer high up right below the stratosphere, but also exists as ground level (tropospheric) ozone catalyzed by the influence of UV radiation on volatile organic compounds (VOCs) and NOx/CO co-emitted with particulate matter. The EU commission had just recently published a survey of European air quality and when I looked at the graphics depicting critical PM and O3 levels throughout Europe, together with similar data available for the Middle-East and China, those maps just looked strikingly similar to the ones depicting covid-19 fatality rates. The disaster was already real for Northern Italy, and I got very concerned about Eastern Europe, specifically Poland.

While I have to admit that my considerations regarding covid-19 are far from a rigorous scientific analysis, in the light of the dramatic situation in spring 2020, I decided that scientific gut-feeling and intuition was enough to let some people higher up know that a political connection between environmental protection and handling the pandemic crisis should at least be given a thought.

Consequently on April 28 2020, I sent an email to EU commissioner for climate action Frans Timmermans and the ambassador of the Polish Republic to Germany, Prof. Przylebski:

Email sent to VP Timmermans and Ambassador Przylebski on 28 March 2020.
Note: The link given in the email has changed: https://www.eea.europa.eu/publications/air-quality-in-europe-2017
I was not particularly hopeful that my message would ever be answered, at most expecting perhaps a pre-formatted reply from the commission’s PR department or an envelope with shiny EU stickers.

When I started to forget about it, on 08 April 2020 I received a message with a letter enclosed from the EU Directorate General Environment – ENV.C3:

Dear Dr. Göschl, Thank you for your message to Vice-President Timmermans regarding the correspondence between the expansion of COVID-19 outbreak and some areas with elevated levels of air pollution in the EU, and your specific concerns about Poland. I have been asked to reply on his behalf. […]

Wow ! My trust was restored and I felt honored that the organization was sharing with me, in an elaborate 1+ page letter, their sympathy for my considerations and their political actions, specifically regarding Poland (for confidentiality reasons, I am unable to publish the full content of the communication). I did not receive any reply from the Ambassador of Poland, though.

Eventually, once more uniting communication with creativity and technology, I started to work on my AirStation project.