This tutorial will help you create a device that will connect your old inductive power meter to the Internet. And what kind of meter exactly is it? It is the kind of oldest, but still used power meter. It has the rotary disk, which has reflective paint all the way round it with a little black stripe. Each time you see that black part passing by, it means one rotation has been completed. In this project 120 turns are equal to consumption of 1 kWh.
2) Microcontroller, IoT network and other stuff usedSo, we will need Arduino MKRFOX1200, which has the Sigfox (and that is the network) connectivity. Sigfox is LPWAN network, that allows to connect anything to the Internet. The network works in ISM band 868 MHz and allows us to send 140 messages (12 bytes of payload each) daily uplink. But that is not all just about network. Sigfox gives us an opportunity to customize the way we want to work with messages. In fact all messages are stored on Sigfox cloud, from where we can retrieve them by defining their destination - callbacks, etc.
ThingSpeak:
ThingSpeak is an IoT platform for the user-friendly display of data. In this project it is the Sigfox callback destination that displays received consumption using charts as soon as the transfer occurred.
One more time - which electric energy power consumption meter will we use?
This one:
- 1. Connect all listed parts as shown in the wiring diagram. I will not explain the theory behind connection, if anything is unclear, feel free to ask. Do not forget to give it some juice :) (usb power bank, or your laptop usb output, etc.).
- 2. Write a code. You will find the Code attached on the bottom of this page. Again, if anything in code is unclear to you, feel free to ask.
- 3. Create ThingSpeak Channels with Analysis. Register on https://thingspeak.com/ and create channel no. 1 by giving it name, description and Field 1 - Consumption. Create channel no. 2 based on channel no. 1, but with different name. Then select Matlab Analysis option on channel no. 2 and write the following code:
readChannelID = TYPE_CHANNEL1_ID_HERE;
readAPIKey = 'TYPE_CHANNEL1_READ_API_KEY_HERE';
writeChannelID = TYPE_CHANNEL2_ID_HERE;
writeAPIKey = 'TYPE_CHANNEL2_API_KEY_HERE';
data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey,'OutputFormat','table');
analyzedData = data;
analyzedData.('Consumption') = (data.('Consumption') + YOUR_CURRENT_CONSUMPTION_STATUS_IN_WH)/1000 ;
thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);
- 4. Create Sigfox Callback. I hope you already registered yours MKRFOX1200 in backend so I am gonna skip tutorial on how to do this. After you logged in on https://backend.sigfox.com/ go to the callbacks section and create one as following:
- TYPE: DATA UPLINK
- CHANNEL: URL
- CUSTOM PAYLOAD CONFIG: status::uint:32:little-endian
- URL PATTERN:
https://api.thingspeak.com/update?api_key=
EXPLAINED1
&field1={customData#status}
- USE HTTP METHOD: GET
*EXPLAINED1 - replace this with Channel 1 ThingSpeak WriteApiKey
4) Device installation & logic behindSo you already have accomplished most difficult parts of this project. Now attach the CNY70 sensor to the glass of your power meter with double sided tape - take care to place it on the centre of rotary disk (fig. Installation). Next, press the device button two times and do the calibration - if the sensor reads reflective part of disk, the diode should light up. If the sensor reads black stripe, the diode should go off. After successful calibration, press the device button one more time. Now the device starts reading the power consumption and sends this value every 30 minutes to Internet using Sigfox. The precision of reading is set to 25 Wh (in our case every 3 disk turns).
After all these steps you will be able to see your actual electric energy consumption in a beautiful ThingSpeak chart as below.
Comments