Connecting an Omega2 Board
Follow the instructions below to connect your device to the Cloud4RPi control panel.
Install/update the required packages.
opkg update opkg install wget python3 python3-pip pip3 install --upgrade setuptools pip
You can use alternative methods to install pip.
The Cloud4RPi library is compatible with Python 3.2+ and Python 2.7.9+ versions.
Getting the Cloud4RPi Client Library
Install the library using your preferred Python version. The following command installs and integrates Cloud4RPi with your OS's default Python interpreter (usually Python 3):
pip3 install cloud4rpi
Hacking Together some Code
We have prepared sample code for several platforms in the cloud4rpi-omega2-python repository to demonstrate sending data to the Cloud.
Get Cloud4RPi examples for your device:
mkdir cloud4rpi-omega2-python && cd cloud4rpi-omega2-python repo="https://raw.githubusercontent.com/cloud4rpi/cloud4rpi-omega2-python/master" wget "$repo/omega2.py" "$repo/control.py"
You can install git if your board has sufficient memory and you prefer using it, and clone this repository with the following command:
opkg install git git-http ca-bundle && git clone https://github.com/cloud4rpi/cloud4rpi-omega2-python.git && cd cloud4rpi-omega2-python
Before running a sample (control.py), remember to replace the
__YOUR_DEVICE_TOKEN__ string with your real device token. Use a text editor (for instance,
vim) to replace
__YOUR_DEVICE_TOKEN__ with the token displayed at the top of the device page on cloud4rpi.io. If you have no token yet, open the Devices page, create a device using the New Device button in the top right corner, and use its token.
Execute the script with a Python interpreter, for example:
If you have installed Cloud4RPi to a non-default Python, use the version with the Cloud4RPi library.
If the script output looks right, open the Devices page to see if the device status has changed.