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/12/08 16:27] – [Orange Pi] kingkevin | spark_counter [2016/10/01 09:59] – [peacefair PZEM-004] address 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 37: | Line 39: | ||
The meter also provides a UART port to query the measured values. | The meter also provides a UART port to query the measured values. | ||
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:// | + | The source code is available [[https:// |
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:// | + | The source code is available [[https:// |
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:// | + | The source code is available [[https:// |
[[http:// | [[http:// | ||
Line 152: | Line 165: | ||
Also only Android supports the video hardware acceleration currently. | Also only Android supports the video hardware acceleration currently. | ||
The official [[http:// | The official [[http:// | ||
- | * such as [[http:// | + | * [[http:// |
* various [[http:// | * various [[http:// | ||
Since I'll only use it as server I decided to go with debian jessie minimal. | 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 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