spark_counter
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
spark_counter [2015/11/02 22:54] – add datasheet kingkevin | spark_counter [2016/10/01 10:01] – [peacefair PZEM-004] connector kingkevin | ||
---|---|---|---|
Line 12: | Line 12: | ||
{{: | {{: | ||
+ | |||
+ | **warning: the electricity meter I am presenting will only work for 1 phase 2 wires power distribution systems. I have a 3 phases 4 wires system and I am doing it wrong.** | ||
====== peacefair PZEM-004 ====== | ====== peacefair PZEM-004 ====== | ||
- | The [[http:// | + | The [[https:// |
It: | It: | ||
* measures voltages 80-260 V AC | * measures voltages 80-260 V AC | ||
Line 35: | Line 37: | ||
{{: | {{: | ||
- | The meter also provides a UART port to query the measured values. | + | The meter also provides a UART port (using an XH-4P connector) |
Two opto-couplers isolate the main power meter circuits from the TX and RX UART ports. | Two opto-couplers isolate the main power meter circuits from the TX and RX UART ports. | ||
+ | |||
+ | ^ UART ^ PZEM-004 ^ note ^ | ||
+ | | 5V | VDD | 3.3V is not enough | | ||
+ | | TX | RX | the UART pin needs to be able to sink ~4 mA | | ||
+ | | RX | TX | the UART pin needs to be idle high | | ||
+ | | GND | GND | | | ||
+ | |||
+ | I used a CP2102 based USB to UART converter. | ||
+ | CH340 based USB to UART converters will not work (it seems to not be able to sink enough current). | ||
+ | And when using the Arduino you should not use the USB port (for serial), since that interferes with the UART signals. | ||
The {{: | The {{: | ||
The UART configurations is 9600 bps 8N1. | The UART configurations is 9600 bps 8N1. | ||
- | Before querying | + | All commands include a device address (i.e. C0 A8 01 01 = 192.168.1.1). |
- | Else it won't reply to the other commands. | + | Only the device with the specified address will respond. |
- | The manual uses an IP as address (192.168.1.1 = C0 A8 01 01). | + | This allows to query multiple devices on the same UART port, one after another, when they have different addresses. |
- | No idea why you would set an IP for a UART address. | + | Thus you have to set the device' |
+ | This address | ||
The commands use the following 7 bytes message format: | The commands use the following 7 bytes message format: | ||
Line 85: | Line 98: | ||
USART to query the power meter, SPI to communicate with the nRF24L01+, and the nRF24L01+ protocol are implemented in C (using a lot of interrupts). | USART to query the power meter, SPI to communicate with the nRF24L01+, and the nRF24L01+ protocol are implemented in C (using a lot of interrupts). | ||
- | The source code is available [[https://to.do|in this git]]. | + | The source code is available [[https://git.cuvoodoo.info/ |
I prefer directly writing in the registers as described in the [[http:// | I prefer directly writing in the registers as described in the [[http:// | ||
This way I learn how it works in details. | This way I learn how it works in details. | ||
Line 109: | Line 122: | ||
On the [[# | On the [[# | ||
- | The source code is available [[https://to.do|in this git]]. | + | The source code is available [[https://git.cuvoodoo.info/ |
On the [[# | On the [[# | ||
Line 123: | Line 136: | ||
To receive the measurements I used a [[# | To receive the measurements I used a [[# | ||
- | The source code is available [[https://to.do|in this git]]. | + | The source code is available [[https://git.cuvoodoo.info/ |
[[http:// | [[http:// | ||
Line 137: | Line 150: | ||
The values are then simply stored in an [[https:// | The values are then simply stored in an [[https:// | ||
+ | |||
+ | Note: there is no ARM build of grafana (armel for RPi 1, armhf for later versions). | ||
+ | This is also because there is no ARM release of [[http:// | ||
+ | I'm running grafana on my local computer (amd64), using the remote database on the RPi. | ||
{{: | {{: | ||
+ | |||
+ | ====== Orange Pi ====== | ||
+ | |||
+ | The [[http:// | ||
+ | This single board computer is based on an [[https:// | ||
+ | |||
+ | For this price the hardware is unbeatable, but the software support is really poor. | ||
+ | Also only Android supports the video hardware acceleration currently. | ||
+ | The official [[http:// | ||
+ | * [[http:// | ||
+ | * various [[http:// | ||
+ | Since I'll only use it as server I decided to go with debian jessie minimal. | ||
+ | |||
+ | The pin header is the same as the [[http:// | ||
+ | The SPI port to connect the nRF24L01 is also available over ''/ | ||
+ | But else this board is not really worth spending time on. | ||
+ | |||
+ | Also don't forget to put a heat sink on the CPU, else they will be slowed down quite often because of the high temperatures. |
spark_counter.txt · Last modified: 2024/01/07 17:49 by 127.0.0.1