diff options
authorKing Kévin <kingkevin@cuvoodoo.info>2015-11-11 10:47:58 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2015-11-11 10:47:58 +0100
commitc56bee6ad101343ed2a19027f649fe145b2bfc6f (patch)
parent2924e77619e25955226579a0254a0e5c212677a5 (diff)
new features documents: AES, CRC, OTA, influxdb info
1 files changed, 32 insertions, 15 deletions
diff --git a/README.md b/README.md
index a1460e1..9ee5fc6 100644
--- a/README.md
+++ b/README.md
@@ -20,18 +20,18 @@ Arduino Nano firmware for the remote power meter side of the spark counter.
the source files are written in C and intended for the Atmel ATmega328P micro-controller.
This does not use the Arduino IDE.
It requires avrdude and avr-libc.
+It also includes the [AVR-Crypto-Lib](https://www.das-labor.org/wiki/AVR-Crypto-Lib/en) library to encrypt the over the air communication.
Connect the peacefair PZEM-004 power meter to the UART port of the Arduino Nano and the nRF24L01+ radio transceiver to the SPI port (detailed information in `nrf24.h`).
The spark counter firmware will periodically read the measurement values from the power meter (voltage, current, power, energy) and send them using the radio transceiver.
-The destination address and channels for the radio communication can be set in EEPROM.
-The format is the following:
-- 4 bytes source address
-- 4 bytes destination address
-- 1 byte channel number
-- 1 byte CRC8-ibutton checksum over the previous data
-The default values are defined in `main.h` but will be overwritten by the raw EEPROM data in `eeprom.bin`.
-Don't forget to use `make eeprom` to write the configuration data on the micro-controller.
+The node configuration is hard coded in `main.h`:
+- arduino node ID for the RPi to identify the source
+- nRF24 source address of the arduino
+- nRF24 destination address of the RPi
+- nRF24 channel for both devices to communicate
+- request period to define how frequent to query the values from the power meter
+- 128 bites key and IV for over the air encryption. /!\ don't forget to change them and not leave the default known values
The source code is interrupt driven when possible (timers, USART, SPI, nRF24 IRQ).
@@ -53,12 +53,22 @@ rpi
Raspberry Pi program for the computer side of the spark counter.
-the source files are written in C and require the [RF24 library](https://tmrh20.github.io/RF24/RPi.html) for the nRF24L01+ radio transciever and libcurl to save the measurement data in the influxdb time series database.
+the source file is written in C++ (mostly C except for RF24) and requires the following libraries:
+- [RF24 library](https://tmrh20.github.io/RF24/RPi.html) for the nRF24L01+ radio transceiver
+- libcurl to save the measurement data in the influxdb time series database
+- [tiny-AES128-C](https://github.com/kokke/tiny-AES128-C) to decrypt the radio packets (included in source)
+- [AVR libc CRC](http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html) to verify the checksum of the radio packets (included in source)
on the Raspberry Pi the [raspian](https://www.raspberrypi.org/downloads/raspbian/) OS is installer and the bcm2835 SPI kernel module is enabled (through `rasp-config`).
connect to nRF24L01+ to the SPI port of the Raspberry Pi and set up an influxdb database.
+to save the values in the InfluxDB database you have to provide the database name, username, and password as arguments when running `spark_counter_receiver`.
+fancy or long arguments might not work (due to the very simple implementation).
@@ -81,14 +91,21 @@ GPIO10/MOSI,P1_19,6,MOSI
+the power meter values (voltage, current, power, energy) are transmitted over the air (OTA) using nRF24L01+ modules.
+the message format is the following:
+- 1 bytes ID to identify the source sender (and thus which AES 128 bits decryption key to use)
+- 4x4 bytes of measurement values, single precision little endian 32 bits IEEE 754 float, AES 128 bits CRC encrypted
+ * voltage (V)
+ * current (A)
+ * power (W)
+ * energy (Wh)
+- 1 byte CRC 8 bits Dallas/Maxim/iButton/1-Wire on the plain 16 bytes values (to verify if the right IV has been used for decryption)
a simple script to query measurement values from the peacefair PZEM-004 power meter.
connect the power meter UART port using a USB to UART converter.
-- provide influxdb hostname, username, and password as parameter