All Collections
Connect your Devices
Connect an Onion Omega2 to Ubidots over TCP/UDP
Connect an Onion Omega2 to Ubidots over TCP/UDP

Learn to setup the Onion Omega2 to send data to Ubidots using TCP/UDP

S
Written by Sergio M
Updated over a week ago

The Omega is an ultra small Wi-Fi development board. Based on Linux, this board was designed specifically for wireless IoT applications. Despite its tiny size, the Omega comes with everything you need to connect your project to the Internet. Then once sending your data to Ubidots you can develop and deploy your custom IoT Application to end-users with ease. 

By working through and completing this guide you will be able to send data taken from the pins of the Omega2 board to Ubidots in just a couple of minutes!

Requirements

Step-by-Step

  1. System Setup

  2. Sending data to Ubidots

  3. Summary

1. System Setup

1.  Turn ON the Omega2 board by connecting it to your computer using an USB Cable.

2. Wait until the amber LED stops blinking, indicating that the Omega has booted up.

3. Establish the connection with board over serial by using the command line. This step is going to be different based on the OS of your computer. 

Refer to the below steps to connect to the Omega based on your computer's OS:

Windows:

  • Download and install the Silicon Labs CP2102 driver for Windows.

  • Go to Computer Management and look for Silicon Labs CP210x USB to UART Bridge under Ports (COM & LPT), and take note of the COM number in brackets.

  • Open PuTTY, select Serial for the connection, enter the COM port of Silicon and enter 115200 for the speed; then click on the Open button to complete this step.

OSX:

  • Download and install the Silicon Labs CP2102 driver for OS X.

  • Run the commnad ls /dev/tty.*  inside the Mac's computer terminal to see if the USB-to-Serial device can be detected. If the driver is successfully installed, you should be able to see a device with a name similar to /dev/tty.SLAB_USBtoUART

  • Then, execute the following command to establish the communication with the board /dev/tty.SLAB_USBtoUART 115200

Linux:

  • Download and install the Silicon Labs CP2102 driver source files, for kernel 3.x.x and higher and for kernel 2.6.x.

  • Build and install the driver, if you don’t know how to do this, you can easily follow Onion guide here.

  • Inside the computer's terminal write ls /dev/ttyUSB, if the driver is successfully installed you should be able to see a device with a name similar to */dev/ttyUSB0** .

  • Then, write the following command to establish the communication with the board /dev/ttyUSB0 115200 

4. After establishing communication with the board over serial, it's time to setup the WiFi connection. To do this, run the command below:

wifisetup 

Then,  follow the instructions provided and assign the SSID and password of the chosen network to establish the connection to the internet. 

5. With board properly connected to internet, it's time to upgrade the firmware of the Onion Omega2. To upgrade all the packages available, run the command below:

upgrade

Then, update the board with the last packages previously upgraded. To do this, run the command below:

opkg update

6. When the Onion completes the update process, it is highly advisable to install the Ubidots Client. To do this, run the command below and wait until the Ubidots Client is installed:

opkg install ubidots-client 

2. Sending data to Ubidots

With the following sample code you will be able to send readings taken from the inputs #5 and #6 of the Onion Omega2 board to Ubidots.

In the command line execute the following steps:

1. Create a new file using “nano” editor.

    nano ubidots.sh

2. Copy and paste “ubidots.sh” inside the file and modify the parameters located at the bottom of the code to match with your preferences:

  • -t: Your Ubidots TOKEN.

  • -d: The device label of the device that will be created. “Omega” by default.

  • set: The data to send.

#The line below tells Linux which shell to use for execution

#!/bin/bash

fast-gpio -q set-input 5
fast-gpio -q set-input 6
VALUE=value
VALUE2=value

#Replace xxxx for your Ubidots TOKEN
TOKEN=xxxXXX
DS_LABEL=mydatasourcename

VALUE=$(echo  $(fast-gpio read 5) | awk '{ print $4}')

VALUE2=$(echo  $(fast-gpio read 6) | awk '{ print $4}')

echo $VALUE2

MESSAGE="{\"temperature\":${VALUE},\"humidity\":${VALUE2}}"
echo $MESSAGE
ubidots -t $TOKEN -d $DS_LABEL set $MESSAGE

To save the file changes in the nano editor press Ctrl + x , then type “Y”  and press the enter key.

3. Finally, run the file inside the Onion Omega by using the following command:

sh ubidots.sh

With your Omega now connected to the Internet and transmitting data to Ubidots API, you will fins a new device created called “Omega” in your Ubidots account

3. Summary 

With this simple tutorial you are able to send data to Ubidots with the ease of Onion Omega2 hardware. If your wish to find more examples to handle context or timestamp values in your request, you can learn more about Ubidots REST API by clicking here

Now its time to create Ubidots Dashboards to visualize your data and deploy your IoT solution!  Happy Developing! :) 

Other readers have also found useful...

Did this answer your question?