Both sides previous revisionPrevious revisionNext revision | Previous revision |
spark_counter [2017/01/18 21:14] – [peacefair PZEM-004] kingkevin | spark_counter [2024/01/07 17:49] (current) – external edit 127.0.0.1 |
---|
{{:spark_counter:dsc02371.jpg?0x300|complete spark counter}} | {{:spark_counter:dsc02371.jpg?0x300|complete spark counter}} |
| |
**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.** | **warning: the electricity meter I am presenting will only work for 1-phase 2-wire power distribution systems. I have a 3-phase 4-wire system and I was doing it wrong. This has been fixed with the [[spark abacus]].** |
| |
====== peacefair PZEM-004 ====== | ====== peacefair PZEM-004 ====== |
I removed the pizeo-element to prevent this annoying sound. | I removed the pizeo-element to prevent this annoying sound. |
| |
{{:spark_counter:dsc02344.jpg?0x200|PZEM-004 board front}} | {{:spark_counter:pzem-004-01.jpg?0x200|PZEM-004 board front}} |
{{:spark_counter:dsc02325.jpg?0x200|PZEM-004 board back}} | {{:spark_counter:pzem-004-02.jpg?0x200|PZEM-004 board back (without buzzer)}} |
{{:spark_counter:dsc02327.jpg?0x200|PZEM-004 board IC}} | |
| |
The power meter uses a single chip solution, the [[http://www.sdicmicro.com/products.html?ic=SD3004|SDIC microelectronics SD3004]] ({{:spark_counter:sd3004_datasheet_v0.2c.pdf|datasheet}}). | The power meter uses a single chip solution, the [[http://www.sdicmicro.com/products.html?ic=SD3004|SDIC microelectronics SD3004]] ({{:spark_counter:sd3004_datasheet_v0.2c.pdf|datasheet}}). |
| |
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://git.cuvoodoo.info/spark_counter/|in this git]]. | The source code is available [[https://git.cuvoodoo.info/kingkevin/spark_counter/|in this git]]. |
I prefer directly writing in the registers as described in the [[http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf|datasheet]] rather than using an [[https://www.arduino.cc/en/Main/Software|abstract IDE]] and [[https://github.com/TMRh20/RF24|libraries]]. | I prefer directly writing in the registers as described in the [[http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf|datasheet]] rather than using an [[https://www.arduino.cc/en/Main/Software|abstract IDE]] and [[https://github.com/TMRh20/RF24|libraries]]. |
This way I learn how it works in details. | This way I learn how it works in details. |
| |
On the [[#ATmega328P|micro-controller]] side I implemented the complete SPI-based protocol using the [[https://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf|datasheet]]. | On the [[#ATmega328P|micro-controller]] side I implemented the complete SPI-based protocol using the [[https://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf|datasheet]]. |
The source code is available [[https://git.cuvoodoo.info/spark_counter/|in this git]]. | The source code is available [[https://git.cuvoodoo.info/kingkevin/spark_counter/|in this git]]. |
| |
On the [[#Raspberry Pi|computer]] side I use the [[https://github.com/TMRh20/RF24|RF24 library]]. | On the [[#Raspberry Pi|computer]] side I use the [[https://github.com/TMRh20/RF24|RF24 library]]. |
| |
To receive the measurements I used a [[#nRF24L01+|nRF24L01+ transceiver]] with the [[https://github.com/TMRh20/RF24|RF24 library]]. | To receive the measurements I used a [[#nRF24L01+|nRF24L01+ transceiver]] with the [[https://github.com/TMRh20/RF24|RF24 library]]. |
The source code is available [[https://git.cuvoodoo.info/spark_counter/|in this git]]. | The source code is available [[https://git.cuvoodoo.info/kingkevin/spark_counter/|in this git]]. |
| |
[[http://elinux.org/RPi_Low-level_peripherals#P1_Header|RPi]] - nRF24L01+ connection: | [[http://elinux.org/RPi_Low-level_peripherals#P1_Header|RPi]] - nRF24L01+ connection: |