Sat. Nov 27th, 2021
App Generation Example: TapNPass and Modbus

In this part, we generate a cellular app for a product that’s geared up with a TapNPass wireless-Modbus adapter. This app will talk with a tool by the TapNPass, utilizing Modbus-RTU communication protocol.

1. TapNPass Connection

The goal product used on this instance is a Schneider Electric SEPAM10 safety relay however the process is similar for any Modbus-RTU accessible system.

1.1 Modbus Target Settings

Here are the settings we’ll use in Section 3.2 to configure the Modbus communication in IoTize Studio IoTized Application | Target System, and the variables (set in Section 3.3) we’re going to monitor, or management.

Serial Port RS485
Target Protocol Modbus
Slave Address 1
First Register Address 1
Baudrate 38400
Parity None
Length 8
Stop bits 2
Handshake None
Timeout 50

1.1.1 Modbus Variables

Name Address Unit-size Quantity Byte Order Comments
I1 0x130 INT32 1 B3_B2_B1_B0
Imean 0x13A INT32 1 B3_B2_B1_B0
Imax 0x140 INT32 1 B3_B2_B1_B0
Telecommand 0xF0 INT16 1 B1_B0 Writing 2 to this variable sends the Rearm command on the SEPAM10

1.2 Hardware Installation

The TapNPass helps bodily connection on USB, or RS485/RS232 through an RJ45 connector, and comes with completely different cables tailored to every kind of connection.

In the case of our SEPAM-10 system, Modbus is out there on a easy screw terminal. The quickest strategy to join is to make use of a easy RJ45 Ethernet cable, reduce it in two sections and wire one part to the terminal in accordance with the next desk:

Cable Signal RJ45 pin
Blue Modbus A 4
Blue/White Modbus B 5
Brown/White DC+ 7
Brown DC- 8

Modbus solely makes use of the Blue pair to speak. However, it’s possible you’ll use the Brown pair to energy the TapNPass Fixed model (the Nomad model can’t be powered by this connection).

If you do not know distinguish the Modbus A and B alerts, don’t be concerned, inverting them won’t injury TapNPass or the goal. It will trigger the communication to fail. If you invert these, you’ll be able to simply unscrew and change these connections to check the second mixture.

1.3 Testing With Toolbox

Now that the TapNPass is related to your system, we’ll take a look at it utilizing IoTize ToolBox.

Toolbox is a free cellular app that lets you ship easy Modbus frames by your TapNPass. You can discover it both on the Play retailer or the App retailer:

TapNPass default configuration permits ToolBox to make direct Modbus requests.

Install the app in your cellphone and launch it. It will open on the connection web page: Click on the BLE SCAN button to search out accessible gadgets, and click on in your TapNPass to connect with it.

Open the menu (click on on the higher left nook or swipe from left) and open the Settings panel.

Set the communication settings in accordance with your system parameters. Then, click on on Apply Settings.

If your TapNPass has already been reconfigured, it’s possible you’ll encounter the next error: Ox81: UNAUTHORIZED. If so, you’ll be able to log as an admin consumer to be allowed to replace the settings and ship Modbus requests. This will be carried out with the Login button within the menu (default credentials are username admin and password admin).

Open the menu (3 bars) and select Modbus. Open Modbus Settings by clicking on the gear icon within the higher proper nook, or on the displayed parameters. In this panel, set the parameters in accordance with the modbus request you want to ship, and click on on Save.

Then, click on on Read to ship the Modbus request. If you wish to enter knowledge, use the Data Input area, and click on on Write.
For a learn request, test the response to the request within the Toolbox. For a write, confirm the response on the goal system (ex. a worth has modified that’s seen on the system or that triggers an motion).

If the request failed, confirm that the communication settings match your Modbus goal system settings. If TapNPass is related on a screw terminal, you’ll be able to strive switching the Blue connections (Modbus A and B) to test if these connections had been inverted.

Read requests screen knowledge in B3_B2_B1_B0 byte order. Check the IoTize ToolBox Documentation to see discover your personal modbus parameters.

After the TapNPass is related to your Modbus system and the communication has been examined, you’ll use the IoTize program to configure the TapNPass.

2. Software Requirements

To create an app, first set up the next program:

2.1 IoTize Studio

The configuration software for all IoTize merchandise. You can obtain it right here.

3. TapNPass Configuration

3.1 Project Creation

Open IoTize Studio, and create a brand new venture (File | New, or CTRL+N). You will see the next display screen:

Give it a identify and a location. In Tap mannequin, select TapNPass, and click on on create. You may present a Modbus Dictionary you probably have one.

The Modbus Dictionary is a CSV file that lists Modbus variables with their very own parameters.
In this presentation, we’re going to create these variables manually. If you wish to create a
CSV Modbus Dictionary, go to part 3.1.1. beneath. Otherwise, you’ll be able to go straight to Communication Settings.

3.1.1 Generate a Modbus Dictionary CSV file

To create your Register Dictionary, you should use our Excel spreadsheet template, which you’ll be able to obtain right here:

IoTize Modbus Register Dictionary generator

Open this spreadsheet and go to the Registers List tab. Here, enter the data for the Modbus variables of your goal system:

Property Description Possible Values
Name The identify that shall be utilized by IoTize Studio to seek advice from the variable String*
Address The modbus tackle of the variable Integer or Hexadecimal worth instance 0xF0
Group Name of the set the variable shall be grouped in. This doesn’t corresponds to any Modbus parameter, however helps to arrange them in IoTize Studio, particularly if there are many registers. String*
Type Data kind of the variable. The first letter stands for signed s, unsigned u or float f, adopted by the variety of bytes.
8bits 16bits 32bits
unsigned u8 u16 u32
signed s8 s16 s32
float f32
Quantity Number of Type values to fetch. These shall be given as an array of Type. Integer
ByteOrder This represents the endianness of the variable. Only for 16- and 32-bits sorts.
32-bits variables 16-bits variables
B3_B2_B1_B0 B1_B0
B1_B0_B3_B2 B0_B1
Slave The tackle of the slave that the variable refers to. Integer
DataModel Data mannequin utilized by your Modbus implementation. If you do not know which is used, set it to Default**.

This spreadsheet is configured to create a CSV file in a predefined format. DO NOT change its construction, in any other case IoTize Studio won’t have the ability to learn your Modbus Register Dictionary..

*The CSV makes use of commas or semi-colons as separators. String properties (Name and Group) should not comprise these charaters.

**These values will be chosen inside a dropdown menu that seems when the cell is chosen

3.2 Communication Settings

Now that the venture is created, go to IoTized Application -> Target System within the IOTZ Explorer view, and enter your Modbus communication settings (as described in part 1.1):

If you’ve a Modbus Register Dictionary (SVD/XML/CSV), it’s possible you’ll specify it right here. This will create the record of the variables linked to your system.

3.3 Variable Settings

Inside the Resource view, proper click on on Custom symbols and choose New absolute image. Then click on on the brand new image, and fill within the correct info for it: modbus and tackle and unit-size (described in part 1.1). Here are the correctly set variables for our instance:

3.4 Users

A TapNPass configuration can comprise clients with completely different entry rights. Here, we’ll use the predefined nameless profile, to permit entry to the present configuration with out logging in.

See User Documentation for extra info on create clients and set their entry rights.

3.5 Bundles

Bundles are units of variables that share the identical consumer entry rights.

Here, we’ll create a bundle Sensors to group variables with learn solely entry (Current, Maximum, Mean): Right click on on Bundles, click on on New Bundle, and rename it to Sensors. From the Resource View, drag and drop these variables into the bundle.

From the Profiles, drag the nameless consumer and drop it within the bundle. This permits nameless to entry the variables in Sensors. Select the consumer within the bundle and make Access rights to Sensors = learn.

Anonymous is the default profile used for anybody who connects to a TapNPass and has not logged in.

Now create a brand new bundle named Commands. Add the Telecommand variable to this bundle. Drag and drop the nameless profile on this bundle. Change the Access rights to Commands to write.

See Bundle Documentation for extra info on bundle creation and parameters.

3.6 HTML Generation settings

Now that variables are linked to bundles, we outline how the variables ought to be displayed. Click on a Sensors variable: you will note within the IOTZ Explorer its HTML Generation settings. Define these in accordance with the variable (Display as Floating Point: No, Display as unsigned: No, Byte Order: B3_B2_B1_B0), and repeat for every variable.

For the Telecommand variable, set Propose Submit to sure. This will create the related enter within the generated app, because the variable is writeable.

3.7 Connection to TapNPass

In IOTZ Explorer, choose Studio.

Here, set your communication protocol to attach your pc to the Tap. You could use direct BLE if accessible in your pc, or socket, with the Tap Manager Relay (Android or iOS).

See this documentation for extra info on set this connection. Here, we’ll use the pc’s BLE to instantly hook up with a NFC/BLE TapNPass.

3.8 Configuration and Tests

Once the communication along with your TapNPass is enabled, take a look at it with Test -> Test Connection. On the primary take a look at, you can be requested if you wish to replace your venture with knowledge from the TapNPass (Serial Number and cloud info). Click OK.

Click on Configure, then Test -> Teboot Tap to add the configuration we made into the TapNPass. Then, click on on Monitor to check the configuration on the Generated HTML that’s displayed on the proper aspect of IoTize Studio:

4. Application Generation

We will now create an app with the present configuration of the TapNPass.

4.1 Configuration

4.1.1 Application Project

First, open the Mobile App view (IOTZExplorer -> IoTized Application -> Mobile App) and choose Generated app in “App type”. You will then see the Generated App Settings.

These settings are by default related to the capabilities of your TapNPass. For this instance, we’ll solely set the situation of the generated app:

The ./generatedApp is a path relative to the configuration venture file (.iotz). The location may be an absolute path, like C:TapNPassDemoapp**.

4.1.2 Variables

Select a variable within the IOTZ Explorer. You will see a brand new set of choices: Details for the generated App.

Here you’ll be able to choose the screen mode of the variable. Here are the settings we’ll use for this demonstration:

Variable Mode Show In Card Options
Current Chart Yes
Mean Gauge Yes Min: 0, Max: 1000
Maximum Text Yes
Telecommands Buttons Yes List of selection: 2=Rearm;

Different modes have completely different particular choices. See the App Generator documentation for extra info on these parameters. You may also seek advice from the contextual assist that seems on the underside of the view, when an possibility is chosen.

4.2 Project Generation

Now that the app settings are outlined, click on on Generate App. This will create the app venture within the folder specified earlier in location. You can observe the progress of app new release within the Output window.

The first new release of the venture could also be gradual because the App Generator may also obtain the venture dependencies. Subsequent builds will get sooner.

When the app is generated, it’s possible you’ll now serve it, to screen it in IoTize Studio and take a look at it utilizing the previously configured TapNPass.

Click on Serve App. You shall be requested if you wish to screen and take a look at the generated app. Click sure, and watch for it to look on the proper aspect of IoTize Studio.

To take a look at the app utilizing TapNPass, you’ll nonetheless have to click on on Monitor*.

Here are the generated views, with the monitoring on:

The Current variable is displayed as a line graph. The Mean variable is displayed as a gauge.

The Maximum variable is displayed as a uncooked worth. The Telecommand variable is a Rearm button. When clicked, the worth 2 is distributed..

We will now construct this venture right into a cellular software.

4.3 Mobile App

4.3.1 Requirements

The initiatives that we generate this fashion with IoTize Studio use Ionic and Apache Cordova to construct cross-platform apps (Android/iOS) that run as native apps on the system.
Therefore, you’ll need to put in the next instruments:

  • Ionic
    npm set up --global @ionic/cli
  • Cordova
    npm set up --global cordova
  • Platform particular requisites documented by Cordova:
  • You may also want native-run, a command software used to routinely set up and launch your software in your system.
    npm set up --global native-run

4.3.2 Android

To run an IoTize generated app on an Android system, you’ll need a tool arrange for growth. The following is a standard strategy to do it, however you might have to test Android Documentation for extra info.

  • Enable USB debugging on the system: Open Settings, navigate to Developer choices, and allow USB debugging. The Developer choices menu could should be enabled first. This is often carried out by clicking 7 instances on the Build quantity, in About cellphone -> Software info
  • Ensure the system has permission to connect with the pc. When USB Debugging is enabled on the system, an alert often seems on the cellphone to present this permission on connecting to the pc. If such alert doesn’t seem, it’s possible you’ll use the command adb gadgets to launch the debugging service in your pc, and attempt to un plug and then plug in your cellphone once more.

Once your system is ready up for growth, open a command immediate contained in the venture folder and run:

npm run android

To simply open a command immediate in your venture folder on Windows 10, it’s possible you’ll open it within the explorer and kind cmd or powershell within the tackle bar to open the command immediate you wish to use.

This command will create an APK (Android Package Kit), set up it in your system and run it.

The first construct could take a while to create the Android venture. As with IoTize Studio, as soon as the venture is created, subsequent builds will get sooner.

Your generated app will open on the join web page. Connect to your TapNPass: click on on Bluetooth and seek for your IoTize system, then choose it. You may method your Android system to the TapNPass to make use of NFC for pairing.

Once related, the app will diplay the Public dashboard that was displayed in IoTize Studio earlier:

The generated APK is positioned right here:


You could share this file to put in it on one other Android system. In order to take action, ship it to your cellphone (utilizing USB switch, mail, cloud service, or another means) and open it along with your cellphone’s file explorer / mail / cloud app.

You could have to permit the applying you employ to open the file to Install unknown apps. Android often proposes opening the settings and toggling this selection whenever you open the apk. If Android doesn’t do that, you’ll find this selection in Settings -> Apps, choose the applying and Advanced -> Install unknown apps**

To learn to make a launch model and publish it on the Play Store seek advice from the Ionic Documentation

4.3.3 iOS

In order to construct an app for iOS, it is advisable to use a MacOS pc, and have your app venture on it. As IoTize Studio will not be accessible on MacOS, you’ll need to repeat your venture folder from Windows to your Apple system.

node_modules and platforms folders comprise numerous recordsdata that may be put in or constructed once more out of your Mac. It is often higher to NOT copy them when transferring your venture folder. To reinstall node_modules, merely run npm set up on a terminal in your folder.*

You may also generate the venture from the .iotz file solely, with the next command:

iotize-app-get begin  --tapConfig 

This requires the IoTize App Generator be put in in your Mac. If iOS requisites are met, merely run:

npm run ios

You can seek advice from the documentation for additional info on iOS app growth.

By admin