/GarageSensorNode

This project realizes sending UART serial protocol data via power line, the sender being an Arduino board, the receiver is a Raspberry Pi with a Python program which publishes to MQTT.

Primary LanguagePythonGNU Affero General Public License v3.0AGPL-3.0

Garage Sensor Node via Power Line Modem

This project realizes sending UART serial protocol data via power line, the sender being an Arduino board, the receiver is a Raspberry Pi with a Python program which publishes to MQTT.

Challenge

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

Solution Approach

The solution approach is to use the power line as carrier. A power line modem is used to send sensor readings periodically over the power line.

Concept

The involved components:

  • Arduino Pro mini as sender
    • garagenode_sender/garagenode_sender.ino
  • Raspberry Pi 2a as receiver
    • garagenode_receiver/garagenode_receiver_mqtt.py
  • 2 power line modems, KQ-330F (KQ-330), UART

Schematics:
SENSORS <---> Arduino <---> Modem <-- Power line --> Modem <---> Raspberry Pi

Prerequisites

Setup

Software Setup Sender

  1. Install neccessary Arduino libraries, see above and garagenode_sender/garagenode_sender.ino.
  2. Open garagenode_sender/garagenode_sender.ino in Arduino IDE
  3. Select
    • Tools > Arduino Pro Mini
    • Processor: ATmega328P 5V 16 Mhz
    • Programmer: AVR ISP
    • Arduino IDE Setup
  4. Compile / verify
  5. Connect USB-Serial (TTY) to RXD, TXD, GND and VCC.
    • USB-TTY RXD <--> Arduino TXD
    • USB-TTY TXD <--> Arduino RXD
    • Arduino Pro Mini USB Serial
  6. Upload: click on upload and in the very next second reset Arduino by pressing button (or shortly connecting RST+GND)
  7. Done flashing.
  8. Check if it's working:
    • screen /dev/ttyUSB0 9600
    • Example output
  9. Plug into power-line.

Software Setup Receiver

  1. Preparation:
  • Setup MQTT server
  • Setup wiring on RasPi, refer to wiring library documentation.
  1. Hardware Setup

    RasPi KQ330 Powerline Modem
    +5 VCC VCC
    GND GND
    RXD = Pin 10 = WiringPi 16 = GPIO 15 TX
  2. Install Python libraries with pip3 install -r requirements.txt

  3. python garagenode_receiver/garagenode_receiver_mqtt.py /dev/ttyAMA0 9600 This assumes a MQTT server on localhost. If not, then look at the CLI parameters (--help).

Receiver Autostart (systemd)

A systemd-service-script is located in garagenode_receiver/systemd/garagenode.service.
For install, copy to /etc/systemd/system and enable with systemctl enable garagenode.service.

Hardware Wiring

Wiring Sender

The sender has:

  • Fuse 125 mA
  • KQ-330F, sender pin is RX (!), connected to Arduino D11
  • DHT22, Arduino D2
  • LDR, Arduino A0
  • switch 1, Arduino D3, pulldown circuit
  • switch 2, Arduino D4, pulldown circuit
State V mA digitalRead
open 0,0 V 0,43 mA 1
close 4,4 V 0,0 mA 0

open: e.g., door open, water-level high

close: e.g., door closed, water-level low

Wiring Receiver

The receiver has:

  • Fuse 125 mA
  • KQ-330F, receiver pin is TX (!), connected to e.g. RasPi

Power Line Communication

Power Line Modem KQ-130F

Arduino & Robust Serial Communication

Arduino Pro Mini Power Consumption

Various approaches exist to reduce the power consumption of an Arduino. Of high impact is often to remove the power LED.

Mode with power LED without power LED
Idle 9.5 mA 6 mA
Power Down Sleep 2.9 mA (0.01 W) 0.15 mA (0.000495 W)
Sending 9 mA 1.2 mA

3.3 V * 0.00015 A = 0,000495 W
3.3 V * 0.0029 A = 0,00957 W

License

AGPL3, see LICENSE.