Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon icon

Arduino IoT Based Energy Meter

Added to IoTplaybook or last updated on: 01/07/2023
Arduino IoT Based Energy Meter


In this tutorial, we will show you how to create an energy meter which allows you to track your energy consumption through the Arduino IoT Cloud. Regardless of whether you want to save energy, automate your home accordingly or simply become more aware of your consumption, measuring your electricity consumption is a good idea.

This tutorial provides a step-by-step explanation of how to set up your new energy meter, using the widely used Modbus protocol to monitor your data. If you are new to the topic, we recommend you read our article on Modbus before getting started. For those who are already familiar with Modbus and have used it before simply follow the steps in the following sections.

This project is dealing with high voltages that can result in serious harm! We advise you to check with your electrician before continuing with this project!

Things used in this project

Hardware components

Arduino MKR WiFi 1010
Arduino MKR WiFi 1010
× 1


Arduino MKR 485 Shield
Arduino MKR 485 Shield
× 1

Finder TYPE 7M.24
× 1


DIN rail panel mount power supply
× 1


3D printed Enclosure
× 1


The standard mounting system for electrical equipment is DIN rail which can be found in most fuse boxes. Simply download the template provided in this tutorial to 3D print your enclosure for both your MKR WiFi 1010 and your MKR 485 Shield.

Step 1 Assemble the Enclosure

Download the files and print both the cable clamp and the accompanying lid. Put the MKR 485 Shield on top of the MKR WiFi 1010 and place both of them inside the case. There are small nobs for each of the four holes found on the MKR boards to keep everything in place.

Step2 Connect the energy meter and the power supply

Note that the colour code for electrical wiring is dependent on your location and it is important that you check the specification for your country!

The next step is to connect the live wire and the neutral wire to the energy meter and the power supply as shown below:

Step3 Connect the MKR 485 Shield

The MKR 485 Shield has three little switches with numbers from 1 to 3. Make sure to set them to the following position:

  • 1 Off (Y/Z communication)
  • 2 Off (Half duplex communication)
  • 3 On (Termination switch on)

If you want to learn more about how Modbus communication via RS485 works check out this tutorial.

Modbus communication
Modbus communication

To power our setup we will connect 5V and GND from the power supply to the back of the MKR 485 Shield as shown below:

Power supply
Power supply



Now it is time to set up the Arduino IoT Cloud. If you have never used the Cloud before just follow this quick tutorial to add your board and connect it to the WiFi network.


After setting up your board you need to add three variables:


Copy and upload the code from here.


Create a new dashboard and add these widgets:


You should see something like this


You have now created your own Arduino IoT Cloud-based energy meter! If you want to expand this setup or hook it up to your existing Arduino automations systems check out our Arduino IoT Cloud subscription plans to unleash its full potential.

Custom parts and enclosures - MKR DIN Case

Schematics - Setup

Code - Energy Meter Arduino




This content is provided by our content partner, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.

This article was originally published at It was added to IoTplaybook or last modified on 01/07/2023.