Based on the idea by Robin (Robins Blog) I’ve created a LED Status Display using a stripe WD2812B and a Arduino Nano which is connected to pimatic as a homduino device (RF433MHz).
The display consists of 20 LEDs. Each single LED could be switched (on/off) with individual RGB color values to reflect a specific status send by the pimatic server.
To build and integrate the LED status display in your pimatic implementation you need the following items as listed on Robins Blog:
• Arduino Nano (or compatible device)
• 433 MHz Receiver
• 5 V Power Supply
• LED-Stripe with WD2812B-Controller (e.q. stripe with 20 LEDS - WS2812B)
• A picture frame to assemble the items to a nice status display
Before you start to assemble the LED display device you should prepare your pimatic configuration. Stop the pimatic server and add a ‘HomeduinoRFButtonsDevice’ to your config.json file.
{
"id": "ledstatusdisplay",
"name": "LED Status Display",
"class": "HomeduinoRFButtonsDevice",
"buttons": [
{
"id": "LEDwgOFF",
"text": "WGoff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000001",
"id": 21845
}
}
]
},
{
"id": "LEDwgTDAY",
"text": "WGtoday",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000010",
"id": 21845
}
}
]
},
{
"id": "LEDwgNDAY",
"text": "WGndays",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000011",
"id": 21845
}
}
]
},
{
"id": "LEDwpOFF",
"text": "WPoff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000101",
"id": 21845
}
}
]
},
{
"id": "LEDwpTDAY",
"text": "WPtoday",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000110",
"id": 21845
}
}
]
},
{
"id": "LEDwpNDAY",
"text": "WPndays",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00000111",
"id": 21845
}
}
]
},
{
"id": "LEDwyOFF",
"text": "WYoff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00001001",
"id": 21845
}
}
]
},
{
"id": "LEDwyTDAY",
"text": "WYtoday",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00001010",
"id": 21845
}
}
]
},
{
"id": "LEDwyNDAY",
"text": "WYndays",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00001011",
"id": 21845
}
}
]
},
{
"id": "LEDbdOFF",
"text": "BDoff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00010001",
"id": 21845
}
}
]
},
{
"id": "LEDbdTDAY",
"text": "BDtoday",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00010010",
"id": 21845
}
}
]
},
{
"id": "LEDbdNDAYS",
"text": "BDndays",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00010011",
"id": 21845
}
}
]
},
{
"id": "LEDasOFF",
"text": "ASoff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00100001",
"id": 21845
}
}
]
},
{
"id": "LEDasACTIVE",
"text": "ASactive",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:00100010",
"id": 21845
}
}
]
},
{
"id": "LEDotOFF",
"text": "OToff",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:10000001",
"id": 21845
}
}
]
},
{
"id": "LEDotCOLD",
"text": "OTcold",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:10000010",
"id": 21845
}
}
]
},
{
"id": "LEDotFROZ",
"text": "OTfroz",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:10000011",
"id": 21845
}
}
]
},
{
"id": "LEDgdCLOSE",
"text": "GDclosed",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:01000001",
"id": 21845
}
}
]
},
{
"id": "LEDgdOPEN",
"text": "GDopen",
"protocols": [
{
"name": "led2",
"options": {
"command": "code:01000010",
"id": 21845
}
}
]
}
]
},
For each LED on the stripe used for the display you need to define a corresponding button. Each button has a unique ‘id’, ‘text’ and a ‘command ‘in the protocol section for sending a code to the Arduino. The device definition can be easily customized to your individual needs by changing the button ‘id’s and ‘text’ for the labels.
Each button has assigned a unique RF code sequence defined under protocol. I’ve analyzed the 433MHz traffic of an old 16 channel remote and changed the RF device id and used codes to meet my demands.
For adapting the used number of LEDs on your stripe, just delete or add button definitions to the ‘buttons’ array.
After you finished the definition in config.json, start the pimatic server and check the pimatic-daemon.log under pimatic-app on configuration failures. For later use you should add the button device to your frontend so that you can use the GUI to switch the LEDs for test purposes.
In a second step the hardware components need to be assembled and connected as shown on Robins Blog . If everything is wired, connect the Arduino Nano via USB to your Arduino development environment and load the following sketch:
#include "FastLED.h"
#include <RCSwitch.h>
#define DATA_PIN 3
#define CLOCK_PIN 13
#define NUM_LEDS 20
CRGB leds[NUM_LEDS];
RCSwitch mySwitch = RCSwitch();
unsigned long WG1 = 5592321; // Restmüll - LED off;
unsigned long WG2 = 5592322; // Restmüll - Abholung heute;
unsigned long WG3 = 5592323; // Restmüll - Abholung morgen;
unsigned long WP1 = 5592325; // Papiertonne - LED off;
unsigned long WP2 = 5592326; // Papiertonne - Abholung heute;
unsigned long WP3 = 5592327; // Papiertonne - Abholung morgen;
unsigned long WY1 = 5592329; // Gelbe Säcke - LED off;
unsigned long WY2 = 5592330; // Gelbe Säcke - Abholung heute;
unsigned long WY3 = 5592331; // Gelbe Säcke - Abholung morgen;
unsigned long BD1 = 5592337; // Geburtstage - LED off;
unsigned long BD2 = 5592338; // Geburtstage - heute;
unsigned long BD3 = 5592339; // Geburtstage in den kommenden 7 Tagen;
unsigned long BA1 = 5592353; // Burglar Alarm - off;
unsigned long BA2 = 5592354; // Burglar Alarm - activated;
unsigned long GD1 = 5592385; // Garagentor - geschlossen-LED off ;
unsigned long GD2 = 5592386; // Garagentor - geöffnet;
unsigned long OT1 = 5592449; // Aussentemperatur >3°-LED off;
unsigned long OT2 = 5592450; // Aussentemperatur >0° <3°;
unsigned long OT3 = 5592451; // Aussentemperatur <0°;
void setup() {
Serial.begin(115200);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2;
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
if (mySwitch.available()) { //If a message is sended with RF Code
unsigned long value = mySwitch.getReceivedValue(); // Copy the value
Serial.println(value);
if (value == BA1) { // Burglar Alarm - off;
leds[19] = CRGB::Black;
FastLED.show();
}
if (value == BA2) { // Burglar Alarm - activated;
leds[19] = CRGB::Red;
FastLED.show();
}
if (value == GD1) { // Garagentor - geschlossen;
leds[17] = CRGB::Black;
FastLED.show();
}
if (value == GD2) { // Garagentor - geöffnet;
leds[17] = CRGB::Red;
FastLED.show();
}
if (value == BD1) { // Geburtstage - keine;
leds[15] = CRGB::Black;
FastLED.show();
}
if (value == BD2) { // Geburtstage - heute;
leds[15].setRGB( 230, 50, 230);
FastLED.show();
}
if (value == BD3) { // Geburtstage in den kommenden 7 Tagen;
leds[15].setRGB( 86, 10, 86);
FastLED.show();
}
if (value == WG1) { // Restmüll - -LED off;
leds[13] = CRGB::Black;
FastLED.show();
}
if (value == WG2) { // Restmüll - Abholung heute;
leds[13] = CRGB::OrangeRed;
FastLED.show();
}
if (value == WG3) { // Restmüll - Abholung morgen;
leds[13] = CRGB::Green;
FastLED.show();
}
if (value == WP1) { // Papiertonne - -LED off;
leds[12] = CRGB::Black;
FastLED.show();
}
if (value == WP2) { // Papiertonne - Abholung heute;
leds[12] = CRGB::OrangeRed;
FastLED.show();
}
if (value == WP3) { // Papiertonne - Abholung morgen;
leds[12] = CRGB::Green;
FastLED.show();
}
if (value == WY1) { // Gelbe Tonne - -LED off;
leds[11] = CRGB::Black;
FastLED.show();
}
if (value == WY2) { // Gelbe Tonne - Abholung heute;
leds[11] = CRGB::OrangeRed;
FastLED.show();
}
if (value == WY3) { // Gelbe Tonne - Abholung morgen;
leds[11] = CRGB::Green;
FastLED.show();
}
if (value == OT1) { // Aussentemperatur >3° - LED off;
leds[9] = CRGB::Black;
FastLED.show();
}
if (value == OT2) { // Aussentemperatur >0° <3°;
leds[9].setRGB( 67, 69, 1);
FastLED.show();
}
if (value == OT3) { // Aussentemperatur <0° ;
leds[9].setRGB( 1, 21, 79);
FastLED.show();
}
}
mySwitch.resetAvailable();
}
Beside the communication functions from ‘RCSwitch.h’, the sketch use ‘FastLED’ a LED animation library for Arduino . With this library it is very easy to address and control a single LED on the stripe. For details you should study the FastLED documentation available on the internet.
The sketch monitors incoming commands send by the pimatic homeduino interface and apply (switch) a color to the LED corresponding to the received code.
As you can see I’m using the LED status display to get informed about critical state in my house (activated Alarm System, open garage door, …) and to inform my family about upcoming occurrences like garbage collection days or birthdays.
With the following simple rules the status of my garage door is displayed:
"if garageDOORstatus is opened then press LEDgdOPEN "
"if garageDOORstatus is closed then press LEDgdCLOSE "
Before you start customizing buttons, code definitions or colors you should test the display with the button device on your web frontend. If everything is working you can easily adapt or enhance the display to your specific needs.
Have fun!