Single Phase Energy Monitoring using Armtronix Wifi RS485 (IA013) and PZEM-016


In this blog we would like to show you Energy monitoring Using Peacefair’s single phase RS485 energy meter PZEM-016 and Armtronix IA013.

  • PZEM-016
  • Armtronix IA013 (Arduino compatible)
NOTE : In this blog we are using IA013-Type A device.

To communicate with the PZEM, we will utilise the  library. This simplifies the process of sending Modbus commands to the device and makes data retrieval a snap. This modbus library contains all the necessary error handling when sending or receiving Modbus commands.

Step 1: Loading the firmware on the IA013

You can find the code on Armtronix github account link given below

So to upload the code on Esp32 of IA013 you need a micro – usb cable (As IA013 has in built USB to UART converter) and Arduino ide installed . and make sure the programming jumpers are placed properly on header J5

ie Connect Pin1 (TXDE) with Pin2 (TXD) and Pin7 (RXDE) and Pin8 (RXD) as shown in the below fig.

And we had to install the following libraries in arduino ide

once you are done with adding all the libraries and code is compiled, you can upload the code by selecting proper port.

We are reading the following Input registors:

Step 3 connection:

make the connection as per the below wiring diagram shown below

Step 4 : Configurartion

Once you are done with the proper connection turn on the main supply and when the IA013 is turned on for first time you have to configure it using your wifi ssid password. so here IA013 will a host will be hosting as an access point (Eg : Armtronix-94-4f-54 where alphanumeric is mac last six digits of mac address of IA013), once you are connected to the AP enter in your browser, A webpage will be loaded as shown below. there are two IOT options available ie HTTP and MQTT. To operate IA013 on HTTP you have to just fill Ssid and password (if exist) and select http button and click on submit and for mqtt you have to fill all the credentials ie ssid, password(if exist), mqtt broker, mqtt username(if exist), mqtt password(if exist), Subscribe topic, Publish topic and click on submit.

Mqtt topics Example:

If the Device MQTT publish topic is “MP” and subscribe topic is “MS”

Then the following topics you have to subscribe to get the data

  • “MP/Voltage” for voltage
  • “MP/Current” for current
  • “MP/Power” for Power in watts
  • “MP/Wh” for energy in Wh
  • “MP/Frequency” for frequency in Hz
  • “MP/PF” for power factor
  • “MP” you will receive all data in a single String.

Here is an Example where have used mqtt and Openhab for Energy monitoring

Note: For this example we have already configured mqtt binding for openhab2.

IA013 Mqtt topic details for IA013

  • Publish Topic: MP
  • Subscribe Topic: MS

Openhab2 config files:

  1. sitemap file
sitemap demo label="Armtronix Demo" 
     Group item=energy label="Energy Monitoring" icon="group"
		Text item=voltage          label="Voltage"  
		Text item=current          label="Current"   
		Text item=power            label="Power" 
		Text item=Watth            label="Wh"
		Text item=frequency        label="Frequency"
		Text item=powerfactor      label="PF" 

2. items file:

Group All 

String voltage "Text: [%s]" { mqtt="<[broker:MP/Voltage:state:default]"}
String current "Text: [%s]" { mqtt="<[broker:MP/Current:state:default]"}
String power "Text: [%s]" { mqtt="<[broker:MP/Power:state:default]"}
String Watth "Text: [%s]" { mqtt="<[broker:MP/Wh:state:default]"}
String frequency "Text: [%s]" { mqtt="<[broker:MP/Frequency:state:default]"}
String powerfactor "Text: [%s]" { mqtt="<[broker:MP/PF:state:default]"}
Screenshot from 2019-07-05 18-38-53

Leave a Reply