diff options
-rw-r--r-- | trasmitter/README.rst.txt | 6 | ||||
-rw-r--r-- | trasmitter/sender.ino | 48 |
2 files changed, 29 insertions, 25 deletions
diff --git a/trasmitter/README.rst.txt b/trasmitter/README.rst.txt index f48643f..e231527 100644 --- a/trasmitter/README.rst.txt +++ b/trasmitter/README.rst.txt @@ -5,6 +5,9 @@ Some links: https://damn.technology/controlling-british-gas-wr1-receiver-arduino http://rossharper.net/2015/11/decoding-a-siemens-rcr10433-thermostat-signal-to-control-a-boiler-from-a-raspberry-pi/ +IMPORTANT: the transmitter prefers 3.3V, it stops working after a +while on 5V. + Reveng ====== @@ -23,3 +26,6 @@ The two sequences are: * ``nnnnnnWnWnnMnnMnnnnnWnnnnMnMWn`` * ``nnnnnnWnWnnMnnMnnnnnnnnnnWMMWn`` + +Actually no, the pulses are not ½ high and ½ low, they're shaped +weird. The source code has the correct widths. diff --git a/trasmitter/sender.ino b/trasmitter/sender.ino index 937d065..9373875 100644 --- a/trasmitter/sender.ino +++ b/trasmitter/sender.ino @@ -1,50 +1,48 @@ +const uint16_t pulseScale = 520; // usec per sample unit + +// alternate HIGH and LOW, first one of each array is HIGH const uint8_t prologue[] = { - 2, 2, 2, 2, 2, 2, 4, - 2, 4, 2, 2, 3, 2, 2, - 3, 2, 2, 2, 2, 2, + 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, + 2,3, 1,1, 2,2, 1,1, 1,1, 2,1, + 1,1, 1,1, 1,2, 1,1, 1,1, 1,1, + 1,1, 1,1, }; -const uint8_t prologueSize = sizeof(prologue) / sizeof(uint8_t); +const size_t prologueSize = sizeof(prologue) / sizeof(uint8_t); + const uint8_t epilogue[] = { - 3, 4, 3, + 1,2, 2,2, 1,3, // the last value doesn't much matter }; -const uint8_t epilogueSize = sizeof(epilogue) / sizeof(uint8_t); +const size_t epilogueSize = sizeof(epilogue) / sizeof(uint8_t); const uint8_t onSignal[] = { - 4, 2, 2, 2, 2, 3, 2, + 2,2, 1,1, 1,1, 1,1, 1,1, 2,1, 1,1, }; -const uint8_t onSize = sizeof(onSignal) / sizeof(uint8_t); +const size_t onSize = sizeof(onSignal) / sizeof(uint8_t); const uint8_t offSignal[] = { - 2, 2, 2, 2, 2, 4, 3, + 1,1, 1,1, 1,1, 1,1, 1,1, 2,2, 2,1, }; -const uint8_t offSize = sizeof(offSignal) / sizeof(uint8_t); - -const int pulseScale = 260; // usec per sample unit +const size_t offSize = sizeof(offSignal) / sizeof(uint8_t); const int nTxPin = 7; // Arduino digital pin you're using for radio data. -void transmitArray(const uint8_t pulses[], uint8_t pulseCount) { - for(int pulse = 0; pulse < pulseCount; ++pulse) { - int pulseWidth = pulses[pulse]; +void transmitArray(const uint8_t pulses[], size_t pulseCount) { + for(size_t idx = 0; idx < pulseCount; idx+=2) { + digitalWrite(nTxPin, HIGH); + delayMicroseconds(pulseScale*pulses[idx]); - if (pulseWidth>0) { - digitalWrite(nTxPin, HIGH); - delayMicroseconds(pulseScale*pulseWidth); - } - else { - digitalWrite(nTxPin, LOW); - delayMicroseconds(pulseScale*(-pulseWidth)); - } + digitalWrite(nTxPin, LOW); + delayMicroseconds(pulseScale*pulses[idx+1]); } } -void transmitSignal(const uint8_t signal[], uint8_t signalSize) { +void transmitSignal(const uint8_t signal[], size_t signalSize) { transmitArray(prologue,prologueSize); transmitArray(signal,signalSize); transmitArray(epilogue,epilogueSize); } -void sendTrain(const uint8_t signal[], uint8_t signalSize) { +void sendTrain(const uint8_t signal[], size_t signalSize) { transmitSignal(signal,signalSize); delay(1000); transmitSignal(signal,signalSize); |