Introduction: Connect Your Pycom Boards With Ubidots Over Wi-Fi

Picture of Connect Your Pycom Boards With Ubidots Over Wi-Fi

The Pycom boards offer an easy way to build Internet of Things applications using Wi-Fi, Bluetooth, Lte, LoRa, and Sigfox. If you desire to know a little bit more about Pycom and their development boards, check out their website at www.pycom.io

With a board in hand and project in mind, this article is designed to help assist in connecting your Pycom board using Wi-Fi to Ubidots' cloud.

Step 1: Requirements

Step 2: Setup

Picture of Setup

Before beginning, it is important check the points below to make sure your board is programmed correctly:

If this is your first time working with a Pycom board, we recommend you reference to their get started materials and then return to this guide for further instruction once you have become familiar.

Setting up the Project

1.- Open the Atom editor, and activate the Pymakr plugin.
2.- Connect the board with the Atom editor. Once the board is connected you will see the message "connected" in the status.

3.- To start, create a new directory called "ubidots" to manage the codes and libraries. Once the directory is created, in the Atom editor select Open a Project, and search for the directory "ubidots," which was previously created and open it.

4.- In the file "ubidots" we are going to manage the libraries and main/boot codes. Please reference and follow the structure below to build your project properly:

> ubidots

- boot.py

- main.py

> lib

-urequests.py

First, we are going to add the folder for the libraries. Right click on the folder "ubidots" and select "New folder", assign "lib" as name.

Now, we're going to add the main and boot files:

Right click the folder "ubidots" and select "New File", assign "boot.py" as the name. Repeat the above steps to create the main called "main.py.

To finish, we have to add the library file into the "lib" folder: Right click on the folder "lib" and select "NewFile", assign as name "urequests.py"

NOTE: If your are importing a library and after compiling receive a message like this one above, it's because you are using an external library and the file needs to be present alongside the boot.py and main.py. For this reason, we previously added the library file.

5.- Now synchronize the project. Press the "Sync" icon from the console, or select Packages > Pymakr > Synchronize project.

Coding time

Now that we have the project built and synchronized, it's time to code!
1.- Copy and paste the library from this link into the "urequests.py" file. Once you've pasted the code save it. urequests.py

2.- Next, copy and paste this code into the "boot.py". Save your code once you've uploaded to the "boot.py" file.

3.- Next, copy and paste this code into the "main.py" file.

Once you've pasted, assign your Ubidots Token and the Wi-Fi credentials where is indicated in the code, and save the code when finished. If you don't how find your Ubidots TOKEN, please reference this article below.

  • How to get your Ubidots TOKEN

Save your code once you've uploaded to the "main.py" with with your Wi-Fi credentials, save your work.

4. Now the project is ready to be run! But first verify if the project is synchronized and that all codes are saved properly. To run the project just press the "Run" icon from the console

NOTE: If you received a error message referring to ImportError: no module named 'urequests', synchronize the project again and then rerun the project.

5.- Go to your Ubidots account to visualize the device just created.

Step 3: Results

In a couple of minutes you are posting data to the Ubidots
cloud using any Pycom board via Wi-Fi. Now it is time to create a dashboard to control and manage the variables of your Pycom devices. To learn more about Ubidots widgets and events, check out these video tutorials.

Comments

About This Instructable

65views

0favorites

License:

Bio: Community manager @Ubidots, a startup empowering makers and hardware engineers to create applications for the Internet of Things #IoT
More by UbiMaker:Build an Energy Monitor Device Using a Particle ElectronDIY Raspberry Pi Temperature System With UbidotsTest You Internet Speed Using a Raspberry Pi + Ubidots
Add instructable to: