Pet projects

Tomato observatory


My PhD course gave me an opportunity to enjoy Mediterranean climate of Lugano. It has also triggered my green thumb, and resulted in a number of flora world representatives inhabiting balconies at my apartment. The main problem for me was that my academic schedule sometimes required me to travel for extended periods of time (2 weeks+) and I could not really count on my flatmates to water my plants.


A home-grown irrigation system was to come for help. Following advice of my flatmate Matteo I have taken into consideration using Arduino, lack of WiFi and good good experience with RPi I have decided to use autonomous RPi for it. The first prototype was quite simple…

but they have quickly evolved into observation and watering station. Due to the fact that RPi doesn’t have analog inputs, I have built an RC-charging circuit with a photo-resistor. Flipping directionality of a GPIO pin would discharge the capacitor. Afterwards, it would slowly charge through the photo-resistor, reaching TTL level at some point in time. The time it took to charge the capacitor is inversely correlated with the intensity of light. I used a simple python script to measure it. Later on I have added additional soil humidity sensors, but had no luck with getting reasonable measurements. Most likely because sensor surface corrosion having much bigger influence than soil humidity itself.

Finally, I have noticed that the water flow is actually quite dependent on the throughput of nozzles, and not-so-much on the time that pump is running. In order to take water throughput into account I have installed a small, rotation-encoder based flow-meter.

The logical view of the system follows:

Live webcam snapshots and current weather conditiuons are available online under:


The tomato observatory project in 2013 has resulted in a pretty decent fruit yield and a time-lapse video:

Currently, the project (and tomatoes) have relocated to Zurich Enge, and it is broadcasting live from this location:, and collecting material for the new time-lapse.

The current set-up set-up at our balcony looks like this:

To be done

  • Recently I have bought a water-level sensor and I’m planing to use it for issuing early warning before water runs out in the container.
  • the quality, and in particular reliability of the USB webcam connected to the Pi leaves a lot to be desired. It is going to be soon replaced with either outdoors wifi camera, or a GoPro shooting through the window.
  • the system is not yet coupled to the home-automation MQTT bus running on our home RPi. It should be operated and calibrated with a web-app providing cross-platform (mobile & desktop) compatibility.

Bedroom curtains


It is quite simple - sliding bedroom curtains open and closed. Closed in the evening, open before the sunrise.


An ESP32s coupled with a 4 way relay switch. Powered by the two-voltage (12v and 5v) power supply and a resistor gives a four-speed, two-speed mover. Additionally, in order to estimate curtain move I have installed a rotation encoder together with an edge state detection switch.


Controlling curtains is done via wireless usb numpad connected to our home network computer (RPi 2) that hosts Mosquitto MQTT broker. A simple python script collects keystrokes and transmits them over MQTT to the curtain controller.

The complete code repository for the project can be found here.


To be done

As of now, the position of the curtains is not persisted, hence move has to be triggered and stopped manually. Mid-term plan is to implement document based state state persistence (MongoDB) and build a simple web-app (nodeJS & React) to control and calibrate curtains moves.

Wake-up light


Waking up early ain’t easy. Waking up before sunrise is even harder. If there is no natural light to wake up to, maybe at least an artificial would do. Inspired by the availability of the LED stripes, I decided to give it a try and got myself a 5v rated, 5m long, 150 led strip from here.


With a little experimentation, I have tapped the led stripe into the power supply together with the reliable ESP32s and Adafruit NeoPixel library. It can draw quite some current (3-5A in my case), so make sure that you have enough power at hand.


At first, everything seemed to run smoothly, but as soon as I wanted to connect it to home MQTT automation, I started having trouble with the reliable programming of the LED stripe. Specifically what I was getting were completely random colors. I have narrowed it down to the interference between WiFi and NeoPixel library. The reason for the interference was that the led programming (electric) handshake is extremely time sensitive and interrupts generated by the WiFi and MQTT were disrupting it. I found no good way of solving this issue by switching off interrupt handling so I decided to give a try to an alternative LED library - FastLED. Initially I had no luck with it either, but eventually, I found that there is a way to instruct it to disallow interrupts. It did the trick.

To be done

For now the wake-up light is adjusted manually with use of the wireless remote numeric-pad that I use to control the curtain mover. This is surely sub-optimal, and the ultimate plan is to connect it to the Actions on Google API, to be able to schedule and adjust the light with use of an android phone.



  • most likely due the noise generated by the power supply with little or no load, the LED strip would occasionally get wrong color for few (one, two) LEDs. This in turn would make a bright flash in the middle of the night. Adding a large stabilizing capacitor at the power supply should help with it.
  • due to the same power-line issue I needed to use separate power supply for the ESP32s. Luckily they are happy to share ground connector, and it was no problem for the LED stripe control line.


  • for some reason building code that references FastLED in Platform.IO fails due to the multiple inclusions of libstdc++. I didn’t really find a good solution for it. Luckily building with original Arduino environment works just fine.

Bedroom alarm-clock radio (decommissioned)


The owl schedule all-so-typical for academics made it really difficult for me to get myself out of bed. I found it quite good to be woken up with old-good-rock radio. Given rather poor offer of local radio in Ticino, I grew fond of Virgin Radio Italy.


I have built a small RPi with an USB audio DAC and USB WiFi adapter and installed MPD on it. It served for years for a cron-scheduled wake-up radio. Later on I have installed on it ShairPort and used it quite a bit with AirAudio. Finally, after few relocations the project was decommissioned and replaced with a Spotify compatible dongle (Audiocast) connected to my old, reliable stereo.