top of page

The RGB LED Notifier

Background

Since moving in to my house two years ago, I have been using Home Assistant for a variety of automations. I really love how customizable it is and with such a large and active community, there are tons of plugins that help you do whatever you can think of.


I have cameras around my house, such as by the garage and at the front door. They feed into an NVR system, Blue Iris, which can detect motion, cars, people, etc. I get push notifications to my phone when this happens, but I wanted a simple way to be alerted that wasn't as distracting as a phone notification but was just enough to see what was going in my peripheral when I was on my computer. I also wanted to use Arduino for this, and ESPHome seemed like a great way to link the Arduino project with Home Assistant.


Hardware I found an STL design that I could 3D print on Thingiverse that held a 128x64 OLED screen and a Wemos D1 Mini Arduino board. It was originally meant to be used as an Octoprint screen, but this would work for my purposes. I remixed the design by adding a round 5mm hole on top of it, so I could place an RGB LED inside. The project was going to be a very basic but very helpful LED notification system that would sit right in front of my keyboard.

This is what I used

The wiring diagram will look like this:


Inside the back of the notifier

Software

As mentioned, I will be using ESPHome for this. The programming for ESPHome is a lot different than Arduino's C++, but it is arguably a lot easier to do and simpler to look at. Here is my code I'm using for this project which does two things currently:

1) If there is a person detected at the garage, the OLED will print "Garage"

2) If there is a person detected at the front door, the OLED will print "Front Door"


Alongside these two things, I have Home Assistant automations that, when these events occur, they will also turn the RGB LED different colors. For example, garage motion turns the LED green, and a person at the front door turns the LED blue.


Another great feature with this is that these boards can be updated over the air (OTA) so after the initial set up is done, you can simply change the program around as long as it is connected with your Wi-Fi. Better yet, if the Wi-Fi fails, it will create it's own fail-over Wi-Fi network so you can connect to it and diagnose the issue.


Here is the YAML for the automation that turns on the blue LED when a person is detected at the front door, for example:

alias: Turn RGB Notifier blue when a person is detected at the front door
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.blue_iris_person_ai
    to: "on"
condition: []
action:
  - service: light.turn_on
    data: {}
    target:
      entity_id:
        - light.oled_led_blue
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id:
        - light.oled_led_blue
mode: single

Here is my ESPHome code, which uses lambda to output text to the OLED display:

esphome:
  name: oled-led-notifier

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "myKey"

ota:
  password: "myPassword"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Oled-Led-Notifier"
    password: "myFailoverPassword"

captive_portal:

output:
  - platform: gpio
    id: "oled_led_notifierRed"
    pin: D5
  - platform: gpio
    id: "oled_led_notifierGreen"
    pin: D7
  - platform: gpio
    id: "oled_led_notifierBlue"
    pin: D4
    
light: 
  - platform: binary
    output: "oled_led_notifierRed"
    name: "OLED LED Red"

  - platform: binary
    output: "oled_led_notifierGreen"
    name: "OLED LED Blue"

  - platform: binary
    output: "oled_led_notifierBlue"
    name: "OLED LED Green"

i2c:
  sda: D2
  scl: D1
  frequency: 800kHz

binary_sensor:
  - platform: homeassistant
    id: human_detected_front_door
    entity_id: sensor.blue_iris_person_ai
    internal: true

  - platform: homeassistant
    id: garage_person
    entity_id: sensor.blue_iris_garagewide_person
    internal: true
font:
  - file: 'slkscr.ttf'
    id: font1
    size: 20
    
display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    rotation: 180

    lambda: |-
      //Use sensor to print on OLED
      if (id(garage_person).state) {
        it.printf(64, 25, id(font1), TextAlign::CENTER , "Garage");
      } else {
      }

      //Use sensor to print on OLED
      if (id(human_detected_front_door).state) {
        it.printf(64, 25, id(font1), TextAlign::CENTER , "Front Door");
      } else {
      }

The Result

The final product is just what I wanted. A small, customizable, functional notification gadget. It's worth noting too that you are not limited to simply red, blue, or green either, as you can combine any combination of colors. In the future, for example, I could have a cyan colored alert for vehicle detection or a purple alert if a dog is found.


bottom of page