This project creates a connected Wattmeter using a TapNLink module. The project uses TapNLink's embedded Java Virtual Machine (JVM) as the application processor. The JVM runs a simple Java program retrieves power consumption data from the Wattmeter.
*** WARNING ***
THE WATTMETER IN THIS DESIGN CONNECTS DIRECTLY TO 220 VOLT MAINS POWER.
Physical contact with any component of the design can cause electrocution resulting in serious INJURY, or DEATH.
DO NOT reproduce this design without appropriate knowledge of, and protective measures for working with mains power.
Disconnect power before handling the material or manipulating the connections. Ensure that material is properly grounded and isolated. Always work with another adult present in case of an emergency.
*** DISCLAIMER ***
This electrical project is provided ONLY for testing and experimentation by qualified persons in electronics design labs.
The person reproducing this example accepts full responsibility to any injury, or damage that may result.
This example is not a product. This example is not Certified, Qualified, Approved, or Recommended for any commercial use, or for any use by the general public.
Note: Before starting, learn how TapNLink and the associated tools work in this Getting Started.
This project is on GitHub !
The project has 4 folders:
app_generated/WattTap.apk: The sources for the mobile application that was automatically generated by the IoTize mobile app build server.
java/WattTap.java: The Java code that is executed by the
iotize_studio/WattTap.iotz: The IoTize Studio configuration file that is used to configure the TapNLink for this demo.
doc/WattTapDemo.pdf: The illustrations and the readme file for the
The Main Components
The main components in this project, and where you can purchase them are:
- The TapNLink communication module is available from these distributors.
- The BL0937 power sensor is available here.
- The plastic casing is available here.
How it Works
The pictures below show the hardware set up. An extension cord has been cut and each half has been connected to the board:
Wattmeter, cord assembly
The wattmeter acts as a spy between the mains plug and the load.
Inside the plastic casing
Inside the plastic case, the TapNLink module is linked to the board using a ribbon cable.
Kapton tape is added for isolation between the TapNLink and the main board to avoid a short.
General view of the project
The general diagram shows the mains plug connected to the wattmeter. The wattmeter is based on a single component (BL0937) that measures both the current and the voltage and calculates the instantaneous power consumption. The TapNLink module reads the information from the wattmeter and transmits the data to a smartphone. This data is viewed in an app that is generated automatically by the IoTize software tools based on the configuration of the TapNLink.
The current is measured through R1 (1 mOhm resistor). The voltage is divided through a series of 330ko resistors before reaching the sensor. Using several resistors is preferred because of the high voltage.
BL0937 to TapNLink
The TapNLink has two extension connectors. The 'target connector' is used as a set of simple GPIOs. Because the data is sent as a series of pulses, the input will be configured as counters. The power is proportional to the frequency of the output signals. The BL0937 has two outputs:
CF0(power) is connected to TARGET_RST of the TapNLink
CF1(current/voltage) is connected to the
TARGET_SWDIOpin The selection of current or voltage is done with
SELconnected to the
TapNLink target connector
Java code executed by the
onCheck() method is called periodically (the period is specified in the
TapNLinkVar construct). With this method, we get an image of the power by considering the differences of the pulse counts during the elapsed time period.
- For more
Javacode information, click here !
- Open the TapNLink configuration project
iotize_studio/WattTap.iotzwith IoTize Studio. For more information about Studio, click here.
- In the
User internal JVMto
Yesand set the
- In IoTize Studio, execute
javabuild to generate the
- Configure your
- Reboot the TapNLink to apply the new configuration.
Running the 'WattTap' App
- Because this app has not been published on the app stores, you have to install it manually. See how this is done here.
- After your circuit is properly connected, and your TapNLink configured, launch the mobile app. The fastest way is to approach your mobile phone (with NFC enabled) to the plastic casing. NFC will launch the app and connect the mobile to the TapNLink automatically.
Wattmeter connected to an electric radiator
TapNLink, you can now monitor the instantaneous power consumption, or the consumption data that has been stored in the module.
Viewing in the app
Because the components used are not very precise, you should calibrate our Wattmeter using a multimeter. Our focus is on measuring active power and requires a a pure resistor. We use an electric radiator. Do not use an appliance like your washing machine that may have high inductance.
Loginto the WattTap application using the admin account to access more parameters.
- After connecting, the
Calibrationview is displayed. Click on this.
- Now, set the active power, current and voltage factors to 1.
Calibration value4. Now the pulse from active power, current and voltage are not adjusted by a calibration factor.
Here are examples for calculating the calibration factor for each of the values:
- Read the voltmeter value (ex. 230V)
- Read the WattTap value (ex. 1765)
- Divide the voltmeter value by the WattTap value: (ex. 230 / 1765 = 0.1303116147308782)
- Set the voltage calibration value in WattTap to the calculated value. (ex. 0.13031)
- Read the voltmeter value (ex. 4 A)
- Read the WattTap value (ex. 561)
- Divide the voltmeter value by the WattTap value: (ex. 4 / 561 = 0.0071301247771836)
- Set the Electric Current calibration value in WattTap to the calculated value. (ex. 0.00713)
- Take the Voltage and Current values from the voltmeter. (ex. 230V and 4A)
- Read the Active Power value in WattTap. (ex. 985)
- Multiply the voltmeter values for Voltage and Current. (ex. 230 * 4 = 920)
- Divide this calculated value by the Active Power value from WattTap. (ex. 920 / 985 = 0.934010152284264)
- Set the Active Power calibration value in WattTap to the calculated value. (ex. 0.93401)
Send Data Message to AWS
Login with the TapNLink admin account and set update shadow on AWS to `active`.
Turn on MQTT messaging to AWS
You must set the correct
AWSinformation in the TapNLink
IoT Platform (MQTT). If not, the
JVMwill be stopped after a few seconds when TapNLink tries to send the messages.
When everything is correctly set up, data messages are received for the AWS Thing for your TapNLink.
AWS MQTT message
- For more information about the creation of this project, click here.