Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

NodeMCU Power meter

Nodemcu script that logs power consumption pushes metrics to pushgateway.


elog.lua is inspired by/modified code from Power Meter pulse logger with ESP8266 running NodeMCU.



  • prometheus pushgateway

  • NodeMCU module

    • firmware 1.5.1 newer than 2016/01/15 - float, with modules: node, file, gpio, wifi, net, tmr, http -
  • Analog Light Intensity Sensor Module 5528 Photo Resistor for AVR Arduino UNO (or similar) on ebay


  • Connect sensor to nodemcu, GND<->GND, VCC<->3V, SIG<->D1.

  • modify config.default.lua a file and save it as config.lua

    • PIN - pin number default 1 for D1

    • MIN_PW - minimum wait time (in ms) till script registers new impulse (prevents logging light echo)

    • SSID - your WiFi SSID

    • PASSWORD - your WiFi password

    • GATEWAYIP - your network gateway (IP address of router)

    • IP - static IP you want to set for nodemcu (connects faster without using DHCP)

    • REFRESHINTERVAL - in seconds how often should logger detect if logging is still working, if counter doesn't increase value for X seconds nodemcu pushes last metrics and restarts

    • PUSHGATEWAY - url of pushgateway server

    • PUSHINTERVAL - how often should metrics be pushed (in seconds)

    • DEBUG - debug flag true or false

  • Upload all .lua files to nodemcu and restart