@Korttoma, Iāve been doing research, but I specifically want to use this in my vera. Is there any ways you could do a simple write up of how you did all the hardware (And what is needed) to accomplish this? I would like to use this behind my Bathroom Mirrors (there is a gap between the mirrors and the wall).[/quote]
The hardware is pretty basic. In addition to your Arduino/radio combo, youāll need
4x NPN MOSFETS (I use 30N06L) to handle the regulation of the 12V power to the LED strip
4x 120 ohm resistors
I donāt have the schematic handy but in a nutshell:
D3 ā resistor ā PIN #1 MOSFET #1
D5 ā resistor ā PIN #1 MOSFET #1
D6 ā resistor ā PIN #1 MOSFET #1
D9 ā resistor ā PIN #1 MOSFET #1
MOSFET #1 PIN #2 ā LED strip RED
MOSFET #2 PIN #2 ā LED strip GREEN
MOSFET #3 PIN #2 ā LED strip BLUE
MOSFET #4 PIN #2 ā LED strip WHITE
All MOSFETs have PIN #3 connected to ground.
RGB Strip V+ goes to the 12V+
IMPORTANT TO NOTE:
With the pin configuration used here, you will move the radioās CE pin (PIN #9) to PIN #4 of the Arduino. Weāre using PIN #9 for the WHITE pin so the sketch is written for the radio on PIN #4.
Make sure the Arduino GND is linked to the 12V+ supply ground. I use an UNO for this since it already has a DC jack built on it and will run off the 12V supply. It also provides the 3.3V for the radio.
Hereās the modified code for the dimmers (one change to the multiplier in the original sketch to correct for 100% turning the LEDs off):
[code]// Example sketch showing how to control RGBW LED Strip.
//IMPORTANTE NOTE!!! one of the āradioā pins has been moved from pin 9 to pin 4 because the White is connected to pin 9 !!!
// This code should generate 4 Dimmer devices in Vera so you can control the RED, GREEN, BLUE and WHITE individualy
#include <Relay.h>
#include <SPI.h>
#include <EEPROM.h>
#include <RF24.h>
// Set RADIO_ID to something unique in your sensor network (1-254)
// or set to AUTO if you want gw to assign a RADIO_ID for you.
#define RADIO_ID 4
#define RED 3 // pin for red LED
#define GREEN 5 // pin for green
#define BLUE 6 // pin for blue
#define WHITE 9 // pin for white
Relay gw(4,10);
void setup()
{
Serial.begin(BAUD_RATE); // Used to write debug info
gw.begin(RADIO_ID);
// Register all sensors to gw (they will be created as child devices)
gw.sendSensorPresentation(RED, S_DIMMER);
gw.sendSensorPresentation(GREEN, S_DIMMER);
gw.sendSensorPresentation(BLUE, S_DIMMER);
gw.sendSensorPresentation(WHITE, S_DIMMER);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(WHITE, OUTPUT);
analogWrite(RED, 0);
analogWrite(GREEN, 0);
analogWrite(BLUE, 0);
analogWrite(WHITE, 0);
// Request/wait for relay status
gw.getStatus(RED, V_DIMMER);
setDimmerStatus(gw.getMessage()); // Wait here until status message arrive from gw
gw.getStatus(GREEN, V_DIMMER);
setDimmerStatus(gw.getMessage());
gw.getStatus(BLUE, V_DIMMER);
setDimmerStatus(gw.getMessage());
gw.getStatus(WHITE, V_DIMMER);
setDimmerStatus(gw.getMessage());
}
/*
- Example on how to asynchronously check for new messages from gw
*/
void loop()
{
if (gw.messageAvailable()) {
message_s message = gw.getMessage();
setDimmerStatus(message);
}
}
void setDimmerStatus(message_s message) {
if (message.header.messageType=M_SET_VARIABLE &&
message.header.type==V_DIMMER) {
int incomingDimmerStatus = atoi(message.data);
// Change Dimmer level
analogWrite(message.header.childId, 255*incomingDimmerStatus/100);
// Write some debug info
//Serial.print("Incoming change for dimmer on pin:");
//Serial.print(message.header.childId);
//Serial.print(", New status: ");
//Serial.println(incomingDimmerStatus);
}
}[/code]
Hope this helpsā¦if someone wants to post the schematic before I dig it upā¦
Remember tooā¦this will create 4 separate dimmers in Vera. I renamed mine under the Advanced tab for each device since the plugin will use generic names. Screenshot attached.