First you will need a 433Mhz RF transmitter which can be bought cheaply off ebay. You will also need to download the RCSwitch library.
The Bye Bye Standby units use a quad state code which the RCSwitch library does not support. However on Tinkerman's blog he details the few changes that need to be added to get this supported. Its a very good blog so well worth reading any way.
The RF transmitter can work with a supply voltage up to 12V and with a good antenna can have a range of many hundreds of meters. A good option when interfacing with an Arduino is to run it off the built in 5V supply and solder a 17cm long wire to the antenna pad. I found that I was able to reliably control a device behind the TV in the front downstairs room from the back bedroom.
Next all you need are the codes for the Bye Bye Standby which I have included in the following sketch.
#include <RCSwitch.h>
#define MAX_STRING_LEN 25
RCSwitch mySwitch = RCSwitch();
String lineinput = "";
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
mySwitch.setProtocol(1);
mySwitch.setRepeatTransmit(10);
mySwitch.setPulseLength(300); // Bye Bye Standby
}
void loop() {
while (Serial.available() > 0)
{
char c = Serial.read();
if (c != '\n')
{
lineinput += c;
}
else {
// handle entered data or request
Serial.println("Entry='" + lineinput + "'");
lineinput.trim();
if (lineinput == "1on")
{
mySwitch.sendTriState("X0X1F00XXX11");
}
if (lineinput == "1off")
{
mySwitch.sendTriState("X0X1F00XXXF1");
}
if (lineinput == "2on")
{
mySwitch.sendTriState("X0X1F00XXX1F");
}
if (lineinput == "2off")
{
mySwitch.sendTriState("X0X1F00XXXFF");
}
if (lineinput == "3on")
{
mySwitch.sendTriState("X0X1F00XXXX1");
}
if (lineinput == "3off")
{
mySwitch.sendTriState("X0X1F00XXX01");
}
if (lineinput == "4on")
{
mySwitch.sendTriState("X0X1F00XXX1X");
}
if (lineinput == "4off")
{
mySwitch.sendTriState("X0X1F00XXXFX");
}
if (lineinput == "5on")
{
mySwitch.sendTriState("X0X1F00XXX10");
}
if (lineinput == "5off")
{
mySwitch.sendTriState("X0X1F00XXXF0");
}
if (lineinput == "6on")
{
mySwitch.sendTriState("X0X1F00XXXXX");
}
if (lineinput == "6off")
{
mySwitch.sendTriState("X0X1F00XXX0X");
}
if (lineinput == "allon")
{
mySwitch.sendTriState("X0X1F00XXXXF");
}
if (lineinput == "alloff")
{
mySwitch.sendTriState("X0X1F00XXX0F");
}
lineinput = "";
}
}
}
No comments:
Post a Comment