In this Mobile App Quick Start Guide, you will:
Set up the IoT Controller App
Build a workflow to send push notifications to the app
Here’s what you need to get started:
Medium One Prototyping Sandbox [Buy]
Medium One IoT Controller App
Important information before you begin:
The mobile app can consume your Medium One credits. It’s recommended to use it to send commands to Medium One’s cloud.
Each visualization widget refreshes every 2 second and will consume credits.
The GPS will transmit coordinates once every 5 seconds and will consume credits.
The control widgets will only consume credits when you send an event.
It is recommended to use the Dashboard on the desktop for visualization and mobile for control if you have limited credits.
Step 1. Create API User and Key
Log into Medium One.. Then go to Setup -> Manage Users
Create an API user. Note your username and password, you will need it later.
Then click Manage API keys, and + Add New API Key. Type any description and Save.
Note your API Key, you will need it later.
Step 2. Create a New Profile on the App
Note: these instructions are for the iOS app, but the Android app steps are similar
In the Iot Controller app, create a new profile. Click the + in the top righthand corner.
Open the “new” profile. Click API login and enter your credentials from above.
Click "Pro" and Done. Remember to click “Save” (only for iOS)
Step 3. Add Widgets on the App
Click the +Add New Widget button on the top.
Add a slider widget, then click on the slider icon to configure it (on Android, slide your finger to the right on the widget to configure it).
Enter "raw" for stream and "temperature" for tag
Now add the switch widget. Enter "raw" for stream and "switch" for tag
Your screen should look something like this
Go back to your Medium One dashboard.
Click on "Real Time Events Log". Select your user in the top right dropdown.
Observe the real-time event chart as your toggle the switch and change the slider on the mobile phone. You should see the events appear.
Congrats! You just sent events to Medium One’s cloud using your mobile device.
Want to learn more about what Medium One can do?
Additional notes on the different widgets
GPS: This widget will transmit geoPoints once every 5 seconds*
Gauge: This widget will query a stream/tag once every 2 seconds*
Notification: This widget will query a stream/tag once every 2 seconds for a text message*
Log: This widget will query a stream/tag once every 2 seconds for last 10 text message*
Map: This widget will query a stream/tag with type geoPoint to display location on the map*
JSON: This widget will transmit a JSON key value pair
* These widgets consume a lot of credits
Appendix: How to Send a Push Notification
If you allow push notifications on the mobile app, an FCM_token tag and key are created in the raw data stream when the profile is created.
Be sure to activate the FCM_token key by going to "Config" > "Data Streams", clicking on the "raw" stream, and checking the checkbox next to the tag. Then save the Data Stream.
If you don’t see it, you’ve probably disabled push notifications, or have not created a profile on the mobile app.
Next, click on Workflow Studio and “Create”.
Give your workflow a name like “Push Notification.”
Click on “Tags and Triggers” on the right panel and expand the raw stream. Drag “temperature” over to the center canvas.
Click on Modules on the right panel and under Foundation, drag “Base Python” to the center canvas as well.
Double click on Base Python. Expand IONodes to expose “Add Input”, click here to add an addition input to this module. Click Save.
You will now see two input nodes. Under Tags and Triggers on the right panel, drag “FCM_token” to the main canvas. Note, you need to activate the tag in order to see it and use it.
Drag FCM_token to the canvas and connect it to in2 of the module
Now we are going to write a simple workflow script. Double click on Python and replace the code with the snippet below. It’s important that the temperature and FCM_token triggers are in the same order as described to match the code
import FCM temperature = IONode.get_input(‘in1’)[‘event_data’][‘value’] FCM_token = IONode.get_input(‘in2’)[‘event_data’][‘value’] FCM.send_fcm_notification_to_m1_application([FCM_token],temperature, sound=”chime”)
Click "Save and Activate".
When you activate the workflow, it’s instantly live. In this case, when a temperature or FCM_token event is sent, it will trigger this workflow.
TIP: You may want to disable FCM_token as a trigger. To do so, simple double click on it, and uncheck “trigger.”
Note let’s trigger the workflow. Go back to your terminal and adjust the temperature slider again.
You should receive a push notification on your phone: