Skip to content

Commit cad1545

Browse files
committed
Major update. pipenv. pytest.
1 parent 5178575 commit cad1545

18 files changed

+954
-194
lines changed

README.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ This project realizes sending UART serial protocol data via power line, the send
77

88

99
## Challenge
10+
1011
The challenge has been to send data (e.g., temperature sensor readings) from an outside garage to a server (RasPi) inside the main house.
1112
The gerage is located some distance away from the house and multiple concrete walls are blocking the line of sight, making radio communication impossible.
1213
But, there is one single phased power line between the house and the garage. Just the power line, no empty conduit.
1314

1415

1516
## Solution Approach
17+
1618
The solution approach is to use the power line as carrier.
1719
A power line modem is used to send sensor readings periodically over the power line.
1820

@@ -32,11 +34,12 @@ Schematics:
3234

3335

3436
## Prerequisites
37+
3538
* Arduino Board, e.g. Arduino Pro Mini
3639
* Arduino Libraries:
3740
* SoftwareSerial (included in Arduino SDK)
38-
* DHT, https://github.com/adafruit/DHT-sensor-library
39-
* Deep sleep, https://github.com/n0m1/Sleep_n0m1
41+
* DHT, https://github.com/adafruit/DHT-sensor-library/releases/tag/1.4.3
42+
* Deep sleep, https://github.com/n0m1/Sleep_n0m1/releases/tag/v1.1.1
4043
* Python 3.5+
4144
* Install needed libraries with `pip3 install -r requirements.txt`
4245
* MQTT Server
@@ -47,21 +50,34 @@ Schematics:
4750
## Setup
4851

4952
### Software Setup Sender
50-
1. Setup wiring on RasPi, refer to wiring library documentation.
51-
2. Install neccessary Arduino libraries, see above and `garagenode_sender/garagenode_sender.ino`.
52-
3. Upload `garagenode_sender/garagenode_sender.ino` to Arduino board.
53-
1. Open in Arduino IDE
54-
2. Select Tools > Arduino Pro Mini, Processor ATmega328P 5V 16 Mhz
55-
3. Compile
56-
5. Click on upload and in the very next second
57-
5. Reset Arduino by pressing button (or shortly connecting RST+GND)
58-
4. Plug into power line.
53+
54+
1. Install neccessary Arduino libraries, see above and `garagenode_sender/garagenode_sender.ino`.
55+
2. Open `garagenode_sender/garagenode_sender.ino` in Arduino IDE
56+
3. Select
57+
* Tools > Arduino Pro Mini
58+
* Processor: ATmega328P 5V 16 Mhz
59+
* Programmer: AVR ISP
60+
* ![Arduino IDE Setup](./doc/arduino-ide-setup.png)
61+
4. Compile / verify
62+
5. Connect USB-Serial (TTY) to RXD, TXD, GND and VCC.
63+
* USB-TTY RXD <--> Arduino TXD
64+
* USB-TTY TXD <--> Arduino RXD
65+
* ![Arduino Pro Mini USB Serial](./doc/arduino-mini-pro_serial.jpg)
66+
6. Upload: click on upload and in the very next second reset Arduino by pressing button (or shortly connecting RST+GND)
67+
7. Done flashing.
68+
8. Check if it's working:
69+
* `screen /dev/ttyUSB0 9600`
70+
* ![Example output](./doc/example_output.png)
71+
9. Plug into power-line.
72+
5973

6074

6175
### Software Setup Receiver
76+
6277
0. Preparation:
63-
* Setup MQTT server
64-
78+
* Setup MQTT server
79+
* Setup wiring on RasPi, refer to wiring library documentation.
80+
6581
1. Hardware Setup
6682
| RasPi | KQ330 Powerline Modem |
6783
| ---------- | --------------------- |
@@ -76,6 +92,7 @@ Schematics:
7692

7793

7894
#### Receiver Autostart (systemd)
95+
7996
A systemd-service-script is located in `garagenode_receiver/systemd/garagenode.service`.
8097
For install, copy to `/etc/systemd/system` and enable with `systemctl enable garagenode.service`.
8198

@@ -85,23 +102,38 @@ For install, copy to `/etc/systemd/system` and enable with `systemctl enable gar
85102
![Wiring Sender](doc/GarageNode_sender.png)
86103

87104
The sender has:
105+
88106
* Fuse 125 mA
89107
* KQ-330F, sender pin is RX (!), connected to Arduino D11
90108
* DHT22, Arduino D2
91109
* LDR, Arduino A0
92-
* Reed switch, Arduino D3
110+
* switch 1, Arduino D3, pulldown circuit
111+
* switch 2, Arduino D4, pulldown circuit
112+
113+
| State | V | mA | digitalRead |
114+
| ----- | ----- | ------- | ----------- |
115+
| open | 0,0 V | 0,43 mA | 1 |
116+
| close | 4,4 V | 0,0 mA | 0 |
117+
118+
open: e.g., door open, water-level high
119+
120+
close: e.g., door closed, water-level low
121+
122+
93123

94124

95125
![Wiring Receiver](doc/GarageNode_receiver.png)
96126

97127
The receiver has:
128+
98129
* Fuse 125 mA
99130
* KQ-330F, receiver pin is TX (!), connected to e.g. RasPi
100131

101132

102133

103134

104135
## Power Line Communication
136+
105137
![Power Line Modem KQ-130F](doc/kq-130f_kq330.jpg)
106138

107139
* KQ-130F
@@ -130,6 +162,7 @@ The receiver has:
130162

131163

132164
## Arduino & Robust Serial Communication
165+
133166
* https://stackoverflow.com/questions/815758/simple-serial-point-to-point-communication-protocol
134167
* HDLC High-Level Data Link Control
135168
* High-Level Data Link Control (HDLC) is a bit-oriented code-transparent synchronous data link layer protocol developed by the International Organization for Standardization (ISO). The standard for HDLC is ISO/IEC 13239:2002.
@@ -142,6 +175,7 @@ The receiver has:
142175

143176

144177
## Arduino Pro Mini Power Consumption
178+
145179
Various approaches exist to reduce the power consumption of an Arduino. Of high impact is often to remove the power LED.
146180

147181
| Mode | with power LED | without power LED |
@@ -155,4 +189,5 @@ Various approaches exist to reduce the power consumption of an Arduino. Of high
155189

156190

157191
## License
192+
158193
AGPL3, see [LICENSE](LICENSE).

doc/GarageNode.pdf

-1010 KB
Binary file not shown.

doc/GarageNode.vsdx

-1.65 MB
Binary file not shown.

doc/GarageNode_sender.png

-104 KB
Loading

doc/Graphics.odp

-725 KB
Binary file not shown.

doc/arduino-ide-setup.png

45.4 KB
Loading

doc/arduino-mini-pro_serial.jpg

19.9 KB
Loading

doc/example_output.png

17.2 KB
Loading

garagenode_receiver/Pipfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
docopt = ">=0.6"
8+
python-dotenv = "*"
9+
pyserial = "==3.4"
10+
paho-mqtt = "==1.3.1"
11+
12+
[dev-packages]
13+
pytest = "*"
14+
pytest-env = "*"

garagenode_receiver/Pipfile.lock

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)