From fb2dc5cb30a5f2a866bc143e1c211fd37a1e9406 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 23 Mar 2018 14:37:08 +0000 Subject: start of transmitter seems to produce the right waveform, but the receiver doesn't react --- trasmitter/.gitignore | 1 + trasmitter/Makefile | 19 +++++++++++ trasmitter/README.rst.txt | 25 +++++++++++++++ trasmitter/radio-reading.txt | 8 +++++ trasmitter/sender.ino | 76 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 trasmitter/.gitignore create mode 100644 trasmitter/Makefile create mode 100644 trasmitter/README.rst.txt create mode 100644 trasmitter/radio-reading.txt create mode 100644 trasmitter/sender.ino (limited to 'trasmitter') diff --git a/trasmitter/.gitignore b/trasmitter/.gitignore new file mode 100644 index 0000000..cebbcdf --- /dev/null +++ b/trasmitter/.gitignore @@ -0,0 +1 @@ +/build-*/ diff --git a/trasmitter/Makefile b/trasmitter/Makefile new file mode 100644 index 0000000..9815090 --- /dev/null +++ b/trasmitter/Makefile @@ -0,0 +1,19 @@ +ARDMK_DIR = /home/dakkar/src/Arduino-Makefile +ARDUINO_DIR = /usr/share/arduino +MONITOR_PORT = /dev/ttyACM* +CURRENT_DIR = $(basename $(CURDIR)) +AVR_TOOLS_DIR = /usr +AVRDUDE_CONF = /etc/avrdude.conf + +PROJECT_DIR = $(CURDIR) +BOARD_TAG = uno +MONITOR_BAUDRATE = 115200 + +CFLAGS_STD = -std=gnu11 +CXXFLAGS_STD = -std=gnu++11 +CXXFLAGS += -pedantic -Wall -Wextra + +include $(ARDMK_DIR)/Arduino.mk + +check-syntax: + $(CXX) -c -include Arduino.h -x c++ $(CXXFLAGS) $(CPPFLAGS) -fsyntax-only $(CHK_SOURCES) diff --git a/trasmitter/README.rst.txt b/trasmitter/README.rst.txt new file mode 100644 index 0000000..f48643f --- /dev/null +++ b/trasmitter/README.rst.txt @@ -0,0 +1,25 @@ +Some links: + +* capturing radio signals + http://www.stevenhale.co.uk/main/2013/08/home-automation-reverse-engineering-a-worcester-bosch-dt10rf-wireless-thermostat/ + 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/ + +Reveng +====== + +Sampled at 192k samples/second, found that the transmissions had 3 +types of (presumably square) pulses: + +======== ======= ======== +name samples duration +======== ======= ======== +narrow 200 ~ 1ms +middle 300 ~ 1.5ms +wide 400 ~ 2ms +======== ======= ======== + +The two sequences are: + +* ``nnnnnnWnWnnMnnMnnnnnWnnnnMnMWn`` +* ``nnnnnnWnWnnMnnMnnnnnnnnnnWMMWn`` diff --git a/trasmitter/radio-reading.txt b/trasmitter/radio-reading.txt new file mode 100644 index 0000000..3d58ee9 --- /dev/null +++ b/trasmitter/radio-reading.txt @@ -0,0 +1,8 @@ +sample frequency: 192k /s + +narrow: 200 samples ~ 1ms +mid: 300 ~ 1.5ms +wide: 400 ~ 2ms + +nnnnnnWnWnnMnnMnnnnnWnnnnMnMWn +nnnnnnWnWnnMnnMnnnnnnnnnnWMMWn diff --git a/trasmitter/sender.ino b/trasmitter/sender.ino new file mode 100644 index 0000000..e53bd72 --- /dev/null +++ b/trasmitter/sender.ino @@ -0,0 +1,76 @@ +const uint16_t arrOn[] = { + 2, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 3, 2, 2, 3, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 3, 2, 3, 4, 2, +}; +const int nOnLen = sizeof(arrOn)/sizeof(uint16_t); +const uint16_t arrOff[] = { + 2, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 3, 3, 4, 2, +}; +const int nOffLen = sizeof(arrOff)/sizeof(uint16_t); +const int nTxPin = 7; // Arduino digital pin you're using for radio data. +const int pulseScale = 260; // usec per sample unit + + +void transmitArray(const uint16_t pulses[], int pulseCount) { + for (int repeat=0; repeat < 3; ++repeat) { + for(int pulse = 0; pulse < pulseCount; ++pulse) { + int pulseWidth = pulses[pulse]; + + digitalWrite(nTxPin, HIGH); + // Widths are in units of 500us, for the full-period square wave + delayMicroseconds(pulseScale*pulseWidth); + + digitalWrite(nTxPin, LOW); + delayMicroseconds(pulseScale*pulseWidth); + } + } +} + +void sendTrain(const uint16_t pulses[], int pulseCount) { + transmitArray(pulses,pulseCount); + delay(1000); + transmitArray(pulses,pulseCount); + delay(2000); + transmitArray(pulses,pulseCount); +} + + +/** + * The setup() function is called when a sketch starts. Used to initialize + * variables, pin modes, start using libraries, etc. The setup function will + * only run once, after each powerup or reset of the Arduino board. + */ +void setup() +{ + pinMode(nTxPin, OUTPUT); + digitalWrite(nTxPin, LOW); + + Serial.begin(9600); + Serial.println("Press 0 to turn off heating"); + Serial.println("Press 1 to turn on heating"); + +} + + +/** + * The loop() function loops consecutively, allowing the program to change and + * respond. Used to actively control the Arduino board. + */ +void loop() +{ + if (Serial.available() > 0) + { + int nIncomming = Serial.read(); + if (nIncomming == 49) { // char code for 1 + Serial.println("ON"); + sendTrain(arrOn, nOnLen); + } + + if (nIncomming == 48) { // char code for 0 + Serial.println("OFF"); + sendTrain(arrOff, nOffLen); + } + + Serial.println("Press 0 to turn off heating"); + Serial.println("Press 1 to turn on heating"); + } +} \ No newline at end of file -- cgit v1.2.3