This is the final post in a series of post that explains how I installed an electrical energy meter in my house and connected it to the internet.
Here are the steps involved:
Here are the steps involved:
- Installing a 3 phase energy meter in your home [Blog post here]
(I used Selec MFM383C Modbus capable energy meter, connected it to my router using USB<>RS485 interface based on FT232RL and MAX485)Modbus capable energy meter - Installing OpenWrt 15.05 Chaos Calmer on TP-LINK TL-MR3020 [Blog post here]
(required adding a USB hub to it, a USB flash drive to hold the rootfs, an FT232RL widget for getting console access to the router over serial and another FT232RL based USB<>RS485 UART for interfacing to the energy meter using modbus. Instead of TL-MR3020, you can use TL-MR3040 as well which has its own battery pack in it.)TL-MR3040 (White color) with a USB hub sporting an 8GB Flash drive and USB<>RS485
convertor.A TL-MR3020 with a USB hub (Flash drive in one of the ports) and
an FT232RL used to gain console access. - Compiling the binaries for libmodbus and mfm383c [Blog post here]
- Install drivers for FT232RL based RS485 bridge, curl and some other important stuff on your router:
# opkg update# opkg install kmod-usb-serial-ftdi kmod-usb-acm kmod-usb-serial curl coreutils-stty usbutils libmodbus bash nano grep getopt ip-full syslog-ng
- Installing CA Certificates on your TL-MR3020 running OpenWrt
We need HTTPS support to upload datapoints to initialstate.com, so to avoid the "(51) Cert verify failed: BADCERT_NOT_TRUSTED" error thrown by cURL, we need to install the certificates, do this by issuing the commands to your router:
# opkg update
# opkg install ca-certificates - Sign up for an Initial State account.
- Write script to execute mfm383c.out, read all the registers from the energy meter over modbus and use cURL
Script is appended below, place it in /root of your router. Make sure to use your own access key and bucket key from your initial state account and add them to the script accordingly.
- Finally add it to the crontab - use the web GUI and set the script to execute once every minute.
![]() |
Configuring the router to run the script every minute |
![]() |
This is what my initial state tiles view looks like. It not only has data coming in from my energy meter but also from my weather station. |
1 | #!/bin/bash |