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.
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 source code is interrupt driven when possible (timers, USART, SPI, nRF24 IRQ).
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.
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`).