Zerynth enables Python for microcontrollers by creating a virtual machine with a multithreaded Real-Time OS on your device.
This tutorial will guide you through the process of connecting your Zerynth enabled Flip&Click SAM3X development board to the WolkAbout IoT Platform. It covers the following steps:
- Setting up physical device and virtualising it within Zerynth Studio - the device is a Flip&Click by MikroElektronika (based on the microcontroller SAM3X by Microchip).
- Creating a project in Zerynth studio.
- Cloning the examples from the GitHub repository.
- Importing a device template on the WolkAbout IoT Platform that defines what data the device will exchange with the Platform.
- Creating a device, from the device template, that will give you credentials to use within your example project.
- Creating a dashboard on WolkAbout Platform that will display the information received from the device.
- Running the example on the device.
Requirements
- Flip&Click SAM3X
- WiFi 4 click
- Zerynth Studio (2.1 or greater)
- WolkAbout account
Hardware setup
- Place WiFi 4 click in microBUS socket A
- Connect a USB micro-B cable to the device and the other end to your PC
Zerynth Setup
If you are already familiar with Zerynth, virtualise your device and jump to Connecting the device section.
For those of you who are using Zerynth for the first time, follow these steps:
- Download and install the Zerynth Studio using the installation guide for additional assistance
- Continue with the Getting Started guide paying close attention to the Connect, Register and Virtualise your Device section
- Once your device is properly virtualised in Zerynth you can continue to the next step
Connecting the device to the cloud
Now that you have a virtualised device, create a new project in Zerynth Studio.
Get up and running with your IoT application by getting the example code from WolkAbout's GitHub repository:
git clone https://github.com/Wolkabout/wolkabout-iot.git
Then you can copy the content from
wolkabout-iot/examples/Controlled_publish_period/main.py
into your Zerynth project's main.py and make some changes to it:
- Enter the SSID and password of your WiFi network
- After that, you will be required to enter the device key and password
- To do that, go to the WolkAbout IoT Platform and create the device by following the next step
WolkAbout IoT Platform Setup
This section will guide you through the process of importing device template, creating a device from that template and creating dashboard to display the information received from the device on the WolkAbout IoT Platform.
- Go to the WolkAbout IoT Platform and log into your account
- If you don't have an account, you can register here
- Select Devices from the navigational menu
- Change to the Device templates tab
Device template page contains the list of templates you have created on the Platform.
- Click Add template
There are two ways in which you can create a template: from scratch or by uploading it.
- Choose Upload and navigate to the Simple-example-deviceTemplate.json file located in wolkabout-iot/examples/Controlled_publish_period/
You can now create a device from the template that was imported.
- Click the Create device button to do so
Simple-example template will already be selected, so just click on the Next step button
- Proceed by entering the device name, in this example Flip&Click SAM3X
- Click the Save button
You are now presented with the device key and password that are needed for connecting your device to the Platform, so use one of the options to save this information, for example, email.
You have now completed the process of creating a device on the WolkAbout IoT Platform.
Let’s now proceed to enter these credentials into the code.
- Open your email, or any other way used to store device credentials
- Copy the device key and password into your Zeryth project's main.py in Zerynth Studio
- Change the Target device to Flip & Click SAM3X
- Click the Verify button
Click the Uplink button and wait for the sending of bytecode to complete.
The device is now ready to connect and send data to WolkAbout IoT Platform when powered on. To display data that will be sent from the device, create a dashboard with widgets on the Platform.
- Select the Dashboards tool from the navigational menu
- Click the + button
- Enter the name for your dashboard, for example, Flip&Click SAM3X Dashboard
- Click the Save changes button
Now, you can start adding widgets to the dashboard.
- Click the + Add Widget button in the corner
- Then select Cards
- Now select: Temperature from your Flip&Click SAM3X,and click the Save button
You are now ready to display the information sent from the device to your dashboard
If you now power on your device and go to the dashboard, you should be able to see the data the Platform is receiving from your device.
That’s it! You are now publishing data from your Zerynth enabled Flip&Click SAM3X board to the WolkAbout IoT Platform! Read the repository's README for additional functionality like controlling state of device actuators, debugging, device configuration options and alarms that are all included in our other example. Finally, from for a more in-depth view into how the library works, see the documentation page.
Comments