This example demonstrates different scenarios of using Cloud4RPi service on C.H.I.P.:
- Monitoring events
- Controling a GPIO pin
- Monitoring temperature with the DS18B20 sensor
For detailed instructions on how to run this example, refer to the How To article.
Running the Sample Code
- Update your system and make sure you have the latest versions of all required software:
sudo apt update && sudo apt upgrade -y sudo apt install python python-pip git -y sudo pip install --upgrade setuptools pip
- If you are going to use GPIO, install the CHIP_IO library using the instructions from the CHIP_IO repository.
- Install the Cloud4RPi client library:
sudo pip install cloud4rpi
- Clone this repository:
git clone https://github.com/cloud4rpi/cloud4rpi-chip-python.git && cd cloud4rpi-chip-python
- Log into your Cloud4RPi account or create a new one.
- Copy your device's Device Token. If you have no devices, create one on the Devices page and copy its Device Token.
- Replace the
__YOUR_DEVICE_TOKEN__string in the control.py file with your device token using any text editor (nano, vim, sed or other):
sed -i 's/__YOUR_DEVICE_TOKEN__/replace-this-text-with-your-real-device-token/' control.py
- Run the
sudo python control.py
- Notice that the device went online and started sending data.
- Go to the Control Panels page and add a new control panel.
- Add a new Gauge widget and bind it to the
- Add a new Switch widget and bind it to the
- Add a new Text widget and bind it to the
STATUSvariable. Configure different colors for "IDLE", "RING" and "BOOM!" strings.
- If you have DS18B20 sensor connected to your C.H.I.P., add a new Chart widget and bind it to the
You can use this control panel to monitor variables and control a logical state on a hardware pin.