Skip to content

Instantly share code, notes, and snippets.

@raimohanska
Created February 21, 2015 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raimohanska/da867e604df59d193b91 to your computer and use it in GitHub Desktop.
Save raimohanska/da867e604df59d193b91 to your computer and use it in GitHub Desktop.
Arduino enocean dimmer
int SIGNAL_LED = 13;
int POWER_LED = 11;
byte buffer[100];
byte myAddress[] = {-1, -114, 70, -125};
void setup() {
Serial.begin(9600);
pinMode(SIGNAL_LED, OUTPUT);
pinMode(POWER_LED, OUTPUT);
}
void loop() {
if (Serial.available() > 3) {
int sync1 = Serial.read();
int sync0 = Serial.read();
if (sync1 == 165 && sync0 == 90) {
int length = Serial.read() & 31;
byte result = Serial.readBytes((char*)buffer, length);
if (result >= length) {
if (isForMe()) {
setBrightness(buffer[2]);
}
}
}
}
}
void setBrightness(int brightnessIn) {
Serial.print("Brightness ");
Serial.println(brightnessIn);
int powerLedBrightness = map(brightnessIn, 0, 100, 0, 255);
analogWrite(POWER_LED, powerLedBrightness);
blink();
}
void blink() {
digitalWrite(SIGNAL_LED, HIGH);
delay(100);
digitalWrite(SIGNAL_LED, LOW);
}
int isForMe() {
for (int i = 0; i < 4; i++) {
if (myAddress[i] != buffer[i + 5]) return false;
}
return true;
}
@raimohanska
Copy link
Author

Use Enocean TCM320 to receive enocean packets. Connection:

  • Pins 1 (GND) and 2 (MODE_SEL) to Arduino GND
  • Pin 8 (SER_TX) to Arduino RX (0)
  • Pin 15 (VDD) to Arduino 3.3V

Arduino pin 11 is used to dim your LEDs using PWM. Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment