Python-based gateway service for GrovePi.
This code is based on gateway-python-SDK. You need to install SDK before using this repo. The way to install SDK is explained
- Python 2.7: This SDK is based on the Python 2.7.3
- Download the OS for Raspberry Pi form RASPBIAN JESSIE
- Format you SD card
- Use window install the OS image to the SD card. you can use Win32 Disk Manager. I strongly recommend you do this using Windows, I have met many issues when i installed it by mac OS
- Attach the SD card to the Raspberry Pi
You also can follow this instructions
- Check the version of python that Raspberry Pi has. This sample code is based on python 2.7.3 or later. in most time, the Raspberry Pi os have installed the python 2.7.3 or later, if not, you can install the python follow here.
-
Make sure your Raspberry Pi is connected to the Internet.
-
Open Terminal.
-
Type the following commands in terminal window.
sudo apt-get update sudo apt-get install rpi.gpio
-
Reboot your Raspberry Pi board.
Your SD card now has what it needs to start using the GrovePi. More information about installing GrovePi SDK
-
Download and install DevIoT python SDK.
git clone https://wwwin-github.cisco.com/DevIoT/gateway-python-sdk.git cd gateway-pythohn-sdk python setup.py install
-
Download the gateway service for GrovePi.
cd ../ git clone https://wwwin-github.cisco.com/DevIoT/gateway-python-grovepi.git cd gateway-python-grovepi
-
Configure sensors.json according to types and pin of connected sensors.
You can use Text Editor in Raspberry Pi, or Vim editor in the terminal window.
vim sensors.json
In Vim editor, you can only change the file in insert mode. Press 'i' and change the content. After modifying, press 'Esc' button and save the file and exit Vim editor by type ':wq' and press 'Enter'.
In sensors.json, there is the information of each sensor inside the parenthesis {}.
{
"type": "light",
"pin": "A2",
"name": "GroveLight",
"options": {}
}
- type: The name of a sensor class file. The python file having this name should be in cisco_grovepi.
- pin: The pin which the sensor is connected to. It should be string like "A1" or "D4", or pin number. You can check the details about it in here.
- name: The display name of sensor on DevIoT.
-
Run gateway service on Raspberry Pi.
python main.py