This project implements TapNLink in a relay, so that the state of the relay can be changed from a mobile app. The project uses TapNLink's embedded Java Virtual Machine (JVM) as the application processor. The JVM runs a simple Java program to control the relay.
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/TimerSwitch.apk
: The sources for the mobile application that was automatically generated by the IoTize mobile app build server. -
java/TimerSwitch.java
: The Java code that is executed by theJVM
. -
iotize_studio/WattTap.iotz
: The IoTize Studio configuration file that is used to configure the TapNLink for this demo. -
doc
: The illustrations and the readme file for the java code.
The Main Components
The main components of this project, and where you can purchase them are:
-
TapNLink communication module is available from these distibutors.
-
Plastic casing is available here.
How it Works
These pictures show the hardware. An extension cord has been cut and each half has been connected to the relay board.
Assembly of the relay
The relay acts as a switch between the mains plug and the load.
Inside of the relay casing
Inside the plastic casing, the TapNLink module is linked to the relay with a ribbon cable.
Tap relay
The relay element switches the current to the device on and off.
Overview
General view of the project
Schematic
Electrical diagram
Java code
The Java
code embedded in the JVM
allows us to do an onCheck()
call at each time interval (This interval is defined in a TapNLinkVar
construct). With this onCheck()
method, by verifying that the provided id
corresponds to the desired id
, we will be able to perform data recovery tasks. The TapNLinkVar
value updates or sends an MQTT message.
- For more
java
code information, click here !
IoTize Studio
- Open the TapNLink configuration project
iotize_studio/TimerSwitch.iotz
with IoTize Studio. For more information about IoTize Studio, click here. - In the
IoTize_Studio/Tap
section, setUser internal JVM
toYes
, and set the.java
file pathjava/TimerSwitch.java
. - In IoTize Studio execute
java
build to generate the.bcb
file. - Configure your
TapNLink
withIoTize Studio
:- Setup the connection to your TapNLink
- Click on the
Configure
button and wait for the end of the configuration process.
- Reboot the TapNLink to apply the new configuration.
Running the 'TimerSwitch' App
- Because this app has not been published on 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.
- With
TapNLink
, you can now monitor and control the relay status.
Active Mode
Defining the mode in the State panel allows you to either force the state of the relay (On/Off), or to set it to Auto so that the system manages the state according to a daily set up.
State panel
Manual On
Pressing the button to manually change the state to On has priority. Pressing the button switches the state to On for the amount of time that is defined in the Access panel.
Manual On duration and progress
Automatic Run
This option makes it possible to automatically return to Auto mode at the change of the hour. When Automatic Run is active, the mode is retrieved from the daily setup at the change of the hour.
Return to Auto mode