What Bin Is It?

Bin Schedule

I had a crazy idea recently. That, in itself, isn’t that unusual, what’s odd about this one is that I actually followed through with it. Here’s how it went: E-ink displays seem to be becoming pretty commonplace, and once set to display something require no power. Would it be possible to build something small enough to stick on the side of the fridge, that could display some useful information that updated periodically. For example, something that told me which bins I need to put out every Sunday. I need a smart fridge magnet. 

Now, I should say this up front: I’m a software guy. I’ve earned my living writing software for decades. Hardware? That’s definitely out of my comfort zone. I’ve dabbled a little in the past, and I did get an Arduino to flash a couple of LEDs at me a while back, but that’s about as far as I ever got. This is going to be a journey.

So, back to the bins. Some background:

As many people in the UK will appreciate, whilst we get our bins emptied every week, local councils are forever coming up with schedules that make it hard to keep up with which particular bin is going to be emptied on any given week. For example, we have four different bins: general waste, recycling, garden waste and food waste. Our council, runs on a “1-2-3” schedule: food waste is emptied every week, recycling and garden are emptied every two weeks (alternating) and general waste is emptied every three weeks. Keeping track of what bin is going to be emptied next demands feats of memory and  mental arithmetic prowess that have long deserted me. The council do produce a handy PDF calendar that you can print out and stick to the fridge, but that’s tedious to use. First you have to remember what date it is, and then look up the appropriate bins in the calendar grid. This is 2025. We’re supposed to have hoverboards by now. Surely there must be easier ways to figure out what bin to put out.

Some years ago. I wrote an Alexa skill to scrape the council web site, look up the bin schedule and then report back. Long story short: that was a real pain to write, but it worked really well for a while. After a couple of years, the council changed the way the web site worked, and that broke everything. I couldn’t face going through all that again so scrapped that particular idea.

The downfall of the Alexa skill was that I wanted it to work for everybody in the district. That placed an undue dependence on navigating the council web site. If I only care about it working for me, I can make a whole lot of assumptions. The schedule is published well in advance and follows a predictable pattern. That simplifies a lot of things.

So, back to the fridge magnet idea. A little bit of googling later, I see that Waveshare make a whole bunch of small e-ink displays. One display in particular catches my eye: 2.9″ Red/Black/White E-Ink E-Paper Display Module for Raspberry Pi Pico That looks like you can plug it into a Raspberry Pi Pico and then write software to make it do whatever you need. That sounds like a fairly simple plug and play approach. I’ve no idea what a Pico is though, so I look it up. It’s a little microcontroller that claims to be easily programmable. Sounds good. I buy the display and a Pico 2 W.

Apparently there’s an H version of some of the Picos, which means they have headers attached (the pins that let you plug them into things). They don’t seem to have any in stock for the one I want, so I buy some headers and hope I can successfully attach them myself. I do at least have a long forgotten soldering iron left over from my brief Arduino foray.

A couple of days later, everything arrives, and I even manage to solder the headers on without major incident. I plug everything together, and nothing blows up. That’s a win in my book.

Raspberry Pi Pico 2W plugged into an e-ing display

Now to make it actually do something. There seem to be two main options here – C/C++ or MicroPython. I’ve dabbled in Python before, but that was a good while ago. My C++ however, is very rusty. MicroPython seems like the quickest and easiest way to get something up and running.

There are drivers and example code on GitHub, so I download those and install them – it all works just fine.

E-ink display show the output from the example code

So, now to work. It doesn’t take long to get a Bins class up and running – the logic is pretty straightforward. But when it comes to writing to the display, there’s a problem. The example code includes a method to display text on the display, but it uses portrait orientation to do so. I want my display to be landscape. After some digging, there doesn’t appear to be an obvious way to change the rotation of the display using their standard Python driver. That might be possible if I switch to C, but I don’t really want to go down that route right now.

The way the display works, is that you create a FrameBuffer object, which is essentially a byte array, and draw the pixels into that.That then gets passed to the display driver and copied onto the display. To get around the orientation problem, I create a FrameBuffer in landscape orientation, populate that with my text, and then copy it, pixel by pixel, into a new FrameBuffer that is in portrait orientation, rotating as I go. And it works.

E-ink display showing a bin schedule

Doing a rotational transform, pixel by pixel, in Python isn’t ever going to be speedy, but here, it doesn’t really matter. It’s an e-ink display and slow to update – the tiny overhead caused by the rotation is never going to be noticed.

One benefit of this particular display is that it is three-colour – black, white and red. That means I can use the red to highlight which bins need to be put out for the next collection, making it easy to see at a glance.

OK, so aesthetically it’s not great, but it is functional. I can tart it up later. The code is available over on GitHub.

Ultimately, I want to run this off battery, so I can stick it on the side of the fridge and not have to worry about wires and power supplies. To make that viable, I need to minimise power consumption. I need to be able to shut the Pico down and have to come back to life to refresh the display – once per day should be fine.

But there’s a problem. While the Pico does have a deep sleep mode, it seems that it is not available from MicroPython. Maybe I do need to brush up on my C/C++ skills again and get my hands dirty. We’ll see.

To be continued…

Comments

2 responses to “What Bin Is It?”

  1. Graham Avatar
    Graham

    This is great, really interested, we are always forgetting which bin to put out and my Wife asks me, well I have no idea either lol. We have 3 bins in QLD Australia, household waste, recycling, and garden waste.

    1. dopiaza Avatar

      It’s definitely a fun little project, and I think it’s going to be really useful.

Leave a Reply

Your email address will not be published. Required fields are marked *