Connecting Cloud-JAM to Medium One’s Prototyping Sandbox

This tutorial uses the Cloud-JAM WiFi board and Medium One’s Prototyping Sandbox to control an LED and get your geolocation data.

 

In this Quick Start Guide, you will:

  • Set up an Arduino environment
  • Program the Cloud-JAM board to send data to your Medium One account
  • Use Medium Workflows to switch the LED and create motion alerts
  • Use the Medium One IoT Controller app to control the LED and visualize sensor data

Here’s what you need to get started:

  • Medium One Prototyping Sandbox Account + Cloud-JAM [Buy Kit]
  • Windows PC or Mac OS
    • Note, this tutorial is based on MacOS
  • 4 GHz WiFi Internet Access
  • Medium One IoT Controller App [download]

 

STEP 1: SET UP YOUR MEDIUM ONE PROTOTYPING SANDBOX ACCOUNT

Click “Setup” in the left-hand sidebar of your Medium One account.  Go to “MQTT” and copy down your PROJECT MQTT ID for later use.

 

Go to “Manage Users” and click “Add New User”.

 

Give your new device a USERNAME and PASSWORD. You will want to copy these down for later use as well. Then click “Save”.

 

You will also want to copy down the USER MQTT ID that shows up after you click Save.

 

Go to “Manage API Keys”, click “Add New API Key”, give your API Key a description, and click “Save”. You will want to copy down the API KEY for later use.

 

STEP 2: SET UP THE MOBILE APP

Note: These instructions are for the IoS app, but the Android app is similar.

 

Open the IoT Controller app and click on the plus sign in the top right corner.

 

Now you can give your project a name and input your Username, Password, and API Key from the account set up. Then press “Done”.

 

If you entered it correctly, you should see a green check box beside API login.

 

Next, press “+Add New Widget”.

 

Select “Switch”.  Press the power icon on the left-hand side of the switch to access the settings.

 

Type “raw” for the stream, and “switch” for the tag. Then press “Done”.

 

Press “+ Add New Widget” again and scroll down to select “Gauge”.

 

Press the marker icon on the left-hand side of the gauge and type “raw” for the stream and “temperature” for the tag. Then press “Done”.  Note: you will not see any sensor data yet.

 

Now press “Save” at the bottom of the app. You should get a confirmation that it was saved.

 

Checkpoint

Go to your Medium One account and go to the “Dashboard” from the left-hand sidebar.  Click “Single User Real Time Events Stream”.

 

Select your user in the right hand corner of the widget.

 

Now, on the app, click on the switch to turn it on.

 

You should see an event show up on the widget.

 

Click the save icon (floppy disk) in the top right corner of the dashboard.

 

STEP 3: FLASH THE CLOUD-JA M BOARD

Plug the Cloud-JAM board into your computer. You should see it come up as a USB stick

 

Drag and drop the binary you downloaded before into CLOUD-JAM.

 

After the binary has finished transferring, the board should automatically disconnect and reconnect. If you open it now, it should just have DETAILS.TXT and MBED.HTM

 

STEP 4: SET UP THE CLOUD-JAM BOARD

Plug your Cloud-JAM board into your computer and open the terminal.

 

Windows

Install TeraTerm or equivalent serial terminal.

Select the COM of the device, and set 115200 as baudrate.

 

MAC

Find out which port your board is plugged into and type screen /dev/tty.XXXX 115200.

Note: if you do not know how to find the port, try typing “screen /dev/tty.” in your terminal and hit the tab key to show autocomplete options. Unplug your board and see which option goes away. This is the port you want!

Copy-Pasting of the data into the terminal may have issue, so write the data manually and very carefully.

 

Linux

After you plug the board run:

dmesg | grep tty

Then run screen with the tty device dmesg printed.

screen /dev/ttyUSBX 115200

 

Press the reset button on your board

 

Press and hold the user button until a prompt comes up asking for you to enter an SSID. This is the name of your WiFi network. Enter that, your WiFi password, your WiFi protocol, MQTT Project ID, MQTT User ID, user password, API key, and a name for your device.

 

You should see on the screen the board connect to WiFi, connect via MQTT, then send data.

 

STEP 5: WRITE WORKFLOW 1: SWITCH LED

Go to “Config” from the left-hand sidebar on your Medium One account and click “Data Streams”.

 

Click “raw” and then click the active checkboxes next to “acc_x”, “acc_y,” “acc_z,” and “switch”. Then click “Save Data Stream”.

 

Now go to your Workflow Studio on your Medium One account and click “Create”.

 

Give your workflow a name. We named ours “switch led”.

 

Click the “Tags and Triggers” icon, which is the first icon on the right-hand sidebar.

 

Click “raw” and drag the “switch” tag into the main area of the workflow.

 

Now click on the “Modules” icon (the second icon in the sidebar), click on “Foundation” and drag a “Base Python” module into the workflow.

 

Connect the bottom end of the switch tag to the “in1” circle on the Base Python module.

 

Double-click on the Base Python module and copy and paste the following code (follow link) into the Script section, replacing any code that is originally there.

 

Now click “Save and Activate”.

 

Checkpoint

Plug the board in and open the IoT Controller app.

After the board is done setting up (within a minute), turn your switch on the app on and off. You should see the LED on the board turn on and off.

Unplug the board.

STEP 6: WRITE WORKFLOW 2: MOTION ALERT

Under Tags and Triggers, under raw, drag x_acc, y_acc, and z_acc.

 

Now, click on “Modules.”

 

Click on “Foundation.”

 

Click and drag “Base Python” onto the screen. Your workflow should look like this.

 

Double click on “Base Python.” A box should come up.

 

Click on “Inputs/Outputs.”

 

Click “Add input” twice. It should look like this. Click “Save.”

 

There should now be three white circles on the top of the blue box, labeled “in1,” “in2,” and “in3.” Drag the white circle under the green box that says sensor_data.x_max to “in1, ” the white circle under the green box that says sensor_data.y_max to “in2,” and the white circle under the green box that says sensor_data.z_max to “in3.”

Now we are going to add the python code. Double click on the blue box, and delete everything in the text area so it is empty.

 

Copy and paste the following python code into the text area:

 

 

On line 6, replace the phone number with your phone number, excluding country code. Make sure to keep it in the quotation marks. On line 7, replace the email with your email address. Make sure to keep it in the quotation marks.

Click “Save and Activate.”

Checkpoint

Shake your board back and forth for about twenty seconds, until you see more event data show up on the Real Time Log. If the magnitude is outside of the normal range. In addition to the board event, you should get two GPS events in your Events Stream.

 

Congratulations!  You have successfully completed the Cloud-JAM tutorial!  To learn more about the Medium One Sandbox and all its capabilities go here [Medium-One-Docs].

 

joyceml22@gmail.com'

Author: Joyce Li