Datalogger reading kWh pulses from a utility grid meter and publising it via MQTT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
marcel 0db325e930 Bill of material added. 4 weeks ago
hardware Bill of material added. 4 weeks ago
CHANGELOG.md Final release 4 weeks ago
LICENSE Initial commit 2 months ago
MQTT_energymeter.ino Final release 4 weeks ago
README.md Added photographs. 4 weeks ago

README.md

Datalogger reading kWh pulses from a utility grid meter and publising it via MQTT

(C) 2023 M. Konstapel https://meezenest.nl/mees

Inspired by https://www.instructables.com/A-Simple-MQTT-PubSub-Node-With-Arduino-UNO-and-ENC/

Board layout

Design

Most mains energy meters have an LED which flashes 500 or 1000 pulses for every measured kWh. A photo-diode mounted in front of this LED detects the flashes. Every pulse is converted to a clean digital signal by an adjustable comparator with hysteresis followed by a 74HC14 Schmitt-trigger. The resulting pulses can be inverted by means of a jumper. A falling edge triggers an interrupt of the ATMega328. The firmware counts the interrupts and calculates the equivalent energy in Wh. Every 60 seconds the result is published to the MQTT broker on topic 'distributioncabinet/energy/solar'.

Schematic

Features

  • Runs on low spec microcontroller (Uno, Nano, Mini, and other ATMega328-based boards)
  • Wired ethernet via ENC28J60 Ethernet module
  • Gets ip address via DHCP
  • Stores data in EEPROM to prevent data loss
  • Easy to configure via telnet port 1000

Prototype

Requirements

  • Arduino IDE (version 2.0.2)
  • UIPEthernet library by Norbert Truchsess, CassyArduino and Juraj Andrassy (version 2.0.12)
  • PubSubClient library by Nick O'Leary (version 2.8)

Configure

The Device gets its IP address via DHCP. Make sure you have a working DHCP server on the network.

The ip address and port of the MQTT broker can be set by connecting to the device via telnet on port 1000.

To set the ip address of the MQTT broker use the command ": ". For example, to set the ip address to 192.168.1.10 type ": 192.168.1.10" and hit enter.

To set the port number of the MQTT broker use the command "P ". For example, to set the port number to 1883 type "P 1883" and hit enter.

To show the current settings type "I".

To save the settings to EEPROM type "S" and hit enter.

IMPORTANT: after making changes, power cycle the device.