electricity meter monitoring system (using STM32F103 micro-controller, PZEM-004T meter, SDM120 meter, DDM100TC meter, ESP8266 WiFi module)
Go to file
King Kévin eee70f4263 remove template text and add project description 2017-01-19 23:33:38 +01:00
lib fix value calculation (integer vs float division) 2017-01-19 13:29:38 +01:00
libopencm3@ad5ec6af08 add libopencm3 and STM32duino-bootloader submodules dependencies 2016-01-15 15:36:00 +01:00
.gitignore ignore generated documentation 2016-08-14 19:26:46 +02:00
.gitmodules remove STM32duino-bootloader 2016-08-14 19:03:17 +02:00
Doxyfile update documentation 2016-09-11 22:44:27 +02:00
Makefile switch to blue pill development board 2017-01-19 13:30:03 +01:00
README.md remove template text and add project description 2017-01-19 23:33:38 +01:00
global.c remove memmem 2016-10-04 11:16:13 +02:00
global.h add timer channel macros 2017-01-19 23:31:58 +01:00
main.c add status LEDs and timer to measure DDM100TC meter pulse 2017-01-19 23:11:43 +01:00

README.md

This is the firmware for the spark abacus.

project

summary

The spark abacus is a system to monitor electricity consumption. A micro-controller collects data from various electricity meters placed at the entry of the 3-phase 4-wire mains electricity distribution installation, and sends it over a local network to a computer storing the values in a database. The measurements can then be visualized. More information is available on the wiki.

board

The development board used for this project is a blue pill. This offers a STM32F103C8T6 micro-controller.

peripherals

ESP8266

The ESP-01 WiFi module (based on the ESP8266 chip) is used to join the local network, connect to the influxDB database on the SBC, and store the measurement values gathered from the electricity meters.

AT firmware v0.51 from the espressif NONOS SDK 1.5.0 has been used for this project. Be sure to have configured the module to connect to the right access point beforehand using the following AT commands:

  • set station mode: AT+CWMODE_DEF=1
  • enable DHCP: AT+CWDHCP_DEF=1,1
  • set access point to connect to: AT+CWJAP_DEF="essid","password"

When booting the micro-controller will reset the device and wait until the module connects to the access point and gets an IP.

Connections ESP-01 <-> board:

  • GND, pin 1; ground
  • TX, pin 2; PA10, USART1_RX
  • GPIO2, pin 3; not connected
  • CH_PD, pin 4; pull-up resistor
  • GPIO0, pin 5; not connected
  • RST, pin 6; pull-up resistor
  • RX, pin 7; PA9, USART1_TX
  • VCC, pin 8; +3.3V (add a large capacitor to cope with power spikes)

code

dependencies

The source code uses the libopencm3 library. libopencm3 is already a git submodules. To initialize and update it you just need to run once: git submodule init and git submodule update.

firmware

To compile the firmware run make.

documentation

To generate doxygen documentation run make doc.

flash

The firmware will be flashed using SWD (Serial Wire Debug). For that you need an SWD adapter. The Makefile uses a ST-Link V2 along OpenOCD software (per default), or a Black Magic Probe. To flash using SWD run make flash.

debug

SWD also allows to debug the code running on the micro-controller using GDB. To start the debugging session run make debug.

USB

The firmware offers serial communication over USB (using the CDC ACM device class). This is mainly used to show the activity and help debugging to code. Type help to get a list of additional available actions.

You can also reset the board by setting the serial width to 5 bits over USB. To reset the board run make reset. This only works if USB CDC ACM is running correctly and the micro-controller isn't stuck.