summaryrefslogtreecommitdiff
path: root/trasmitter
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-03-23 14:37:08 +0000
committerdakkar <dakkar@thenautilus.net>2018-03-23 14:37:08 +0000
commitfb2dc5cb30a5f2a866bc143e1c211fd37a1e9406 (patch)
tree81eb9e71cd72bb0e06136432d65327c7cd82486e /trasmitter
parentmove into subdir (diff)
downloadthermostat-fb2dc5cb30a5f2a866bc143e1c211fd37a1e9406.tar.gz
thermostat-fb2dc5cb30a5f2a866bc143e1c211fd37a1e9406.tar.bz2
thermostat-fb2dc5cb30a5f2a866bc143e1c211fd37a1e9406.zip
start of transmitter
seems to produce the right waveform, but the receiver doesn't react
Diffstat (limited to 'trasmitter')
-rw-r--r--trasmitter/.gitignore1
-rw-r--r--trasmitter/Makefile19
-rw-r--r--trasmitter/README.rst.txt25
-rw-r--r--trasmitter/radio-reading.txt8
-rw-r--r--trasmitter/sender.ino76
5 files changed, 129 insertions, 0 deletions
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