Many years ago I used to have a power monitor that changed colours depending on how much power was being consumed from the grid. It was pretty cool but sadly died some time ago, so I wanted to do something similar. I had a neopixel ring doing nothing as such, so thought it would make a nice base for my power usage monitor.
The features are:
- On initial startup, it shows a message on the screen saying that it’s fetching data
- If power is being consumed from the grid, the left hand arc of 12 LEDs light in colours ranging from yellow to red depending on how much is being consumed.
- If power is being generated, the right hand arc of 12 LEDs light in colours ranging from blue to green, depending on how much is being generated
- Each LED represents one kW of power (rounded to the nearest kW - eg 1,350W = 1kW = 1 LED) to a maximum of 12.
- If power is being consumed from the grid, then the OLED shows how much is being consumed
- If power is not being consumed from the grid, then the OLED shows how much solar power is being generated
- To make this bedroom friendly, at a defined time at night both the neopixel ring and OLED screen are switched off (technically the neopixel turns the LEDs down to 0%, and the OLED displays a blank screen. This is because the neopixel is powered directly from the 5V pin of the esp device so it is, let’s say, challenging to actually turn off the ring without using a relay. Even if you put the esp into deep sleep, the ring will still be powered. The OLED is also a special case as, unlike with a LCD panel it does not have a backlight to turn off so making it display a black screen provides the desired result!)
- At a defined time, the neopixel ring and OLED screen are turned back on again. This time can be varied based on day of week - for example I’d prefer it to come on later in the morning on the weekend.
The code itself is located at SSD1306 OLED panel for Neopixel stand by TheRealNinkasi - Thingiverse
Normally I would post the code here, but it is quite big and even just trying to post it by itself I get “An error occurred: Body is limited to 32000 characters; you entered 36658.” I’ll split is up and post it here, but the whole file is it at Thingiverse.
Notes:
- This is not a tutorial on how to get this data into home assistant, but just some information on a way to display it. FWIW Personally I use a Rainforest dongle and mqtt to capture grid usage from our smart meter, and solar generation info comes directly from my Fronius inverter.
- If you use an esp32 device that supports bluetooth, you could also use this as a ble scanner eg for room presence monitoring. This does however use up a lot of resources, and could easily make the device unstable due to memory issues causing random rebooting. I have however put some sample code in there, commented out, to give an indication of what you can do.
- I found that the ESP32-WROOM-32U board I had purchased from Aliexpress had WiFi issues when powered from the USB-C port - just a warning there. The resolution was to power it directly from the 5V pin.
- Feel free to change the colour scheme for the LEDs
- Feel free to change the number of LEDs that light up based on power - for example, if you have a smaller solar system, you may want to change the increments so each LED represents 500W
- On wakeup in the morning the system does not show anything until something changes that triggers the “on_value_range” - I might update the code at some point to allow for this, but it’s not a huge priority for me…
- The code does have references to my specific sensors - you will need to go through it of course to change to suit your specific system.
- If printing the case, I’d suggest the base can be printed in standard (ie 2mm) resolution, the other parts should be in high (ie 1mm) resolution. Speaking of which, the case I printed using designs that are on thingiverse - actual locations are referred to in the code that I’ve tried to make as descriptive as possible.
- I have set the default brightness to 30% - depending on your environment, and how far in you push the ring into the case, you may want this brighter or dimmer. A future update may be the addition of a light sensor so I can vary the brightness based on ambient light.
- Yes, if you look not that closely you’ll see a small piece of tape on my stand. This was my first trial print and it had a small black smudge from a prior print, so the tape is currently performing the dual purpose of covering the mark and keeping the ring straight. This is only a first draft anyway - I plan to print it again, possibly providing space for motion and light sensors. When I’m happy, I’ll just use a small dab of glue to keep it all in place.
Hardware required:
- An esp32 or esp8266 of some form. I like the Wemos D1 mini, although if you later plan to potentially add in extra sensors (eg proximity, motion, temperature, etc) then the more powerful esp32 is definitely the way to go.
- A neopixel ring. In my case I got a 24 led version - there are larger and smaller out there, but that seemed to be the Golidlocks size ie not too big or too small.
- Optional - a 0.96 inch oled display (SSD1306 128x64) - the ring is used to give an approximation of the amount of power being consumed from the grid and/or being generated by your solar panels if you have them. The oled display is a nice to have as it can be used to provide more detail. Note that past experience has shown me that these displays are not always the same physical size, so you may need to tweak the 3D case if you use what I put together.