During my studies I lived in a big skyscraper in Erlangen. The „Langer Johann“, as it is called by locals, is a 24 floors high complex and a lot of people live there. I shared with various roommates and of course we had a fun time at our apartment.
Shortly after I started working at Method Park I decided to move. I am very happy in my new home as now have a lot more space available and my roommates won’t steal my food from the fridge anymore. It is also a lot quieter as there is no big road next to the building and we can now enjoy sitting on the balcony. While moving I had to rebuy some stuff that I couldn’t take with me as it was shared property and would stay at the shared apartment.
Unfortunately, things like my new couch came with a lot of packaging, which was piling up. In the shared apartment one of my roommates (or me) would have taken these packages out to trash containers at the back of the building at some point. The building had huge containers since a lot of people will obviously produce a lot of trash. Although those containers would be emptied regularly I never really knew what the schedule was. Obviously we also had to take out the trash in the new apartment, but I didn’t know the schedule for the garbage collection here either. Inevitably the piles were getting bigger, the garbage collection came by and the pile was still inside the apartment.
I must admit this happened more than once so I had to do something about it. As a member of Team IoT and in possession of an unused Raspberry Pi equipped with GPIOs I decided to automate the „Take the trash out“-process. I took 4 different LEDs and wrote an initial Python script to control the GPIOs and used them to light up the LEDs. After setting up the „Hello World!“-Program for IoT I decided to switch the language to one I hadn’t tried before.
I decided to use „Go“. My plan was to light up one of the four LEDs for each type of garbage that would be emptied on the next day. To achieve this, I needed to find out on which day of the week and on which schedule the different kinds of garbage would be collected. After a quick search on the web, I found the schedule for my block. The site provides a calendar containing the next 10 entries for each kind of trash in an iCal format (registering with an email address was required). I then had to download the iCal file and parse it by using appropriate libraries like „net/http“ and „https://github.com/lestrrat-go/ical„. This also goes to show the flexibility of the Go language and how easy it is to use external libraries hosted on platforms like GitHub.
Putting it together
By comparing the dates from the calendar file to the date of the next day I was able to decide which of the LEDs should glow up depending on which kind of garbage would be collected. I decided to only take „Restmüll“, „Biomüll“, „Gelber Sack“ and „Papier“ into account. The LEDs were chosen in a suitable color: green for organic waste, yellow for recyclables, blue for paper and white for residual waste.
After some time we were finally able to reduce the pile of paper in our apartment. But then we realized that this wasn’t the only question about garbage collection we had. At some point my girlfriend asked: „When is the next time the ‚Gelber Sack‘ is collected?“. Looking at my LEDs I realized I had no clue.
I then took a leftover OLED display that was lying around and connected it to my Raspberry Pi. The display used the Pi’s 3.3V power supply and was able to communicate via I2C with it. I started on an implementation for writing to the display. I used another library providing an I2C connection to the OLED display on the Pi’s I2C1 bus by using the display’s static address
0x3c. After identifying the correct start byte sequence for this specific display I implemented different methods to open and close the connection, to turn the display on and off, set some pixels and also clear pixels. I also started implementing my own set of ASCII fonts but then decided to go with a byte font I found while browsing the web.
I could now write to my display and print the information provided by the calendar from the Raspberry Pi. The breadboard is placed under my monitor and it always remind me when garbage will be collected. I also thought about integrating the information to the status bar of my i3wm but this is probably better suited on my non-Raspberry Pi machines.
- G[lr]ow up! A story about LEDs, Raspberry Pis and Garbage Collection - 23. Februar 2023