Unit 3: Configure and Connect the Raspberry Pi to EnOS¶
After setting up the Raspberry Pi, configure the Raspberry Pi before running the sample code.
Step 1: Install Libraries and cURL¶
Update if necessary:
pip3 install --upgrade setuptools
Install enos-mqtt-sdk-python library:
pip3 install enos-mqtt-sdk-python
Install seeed-python-dht library:
pip3 install seeed-python-dht
Install grove:
curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
If an error message “Check whether I2C enabled and Grove Base Hat RPi or Grove Base Hat RPi Zero inserted” is encountered, fix it with the below.
Give permissions to edit adc.py.
sudo chmod 666 /usr/local/lib/python3.7/dist-packages/grove/adc.py
Locate and edit the adc.py file in /usr/local/lib/python3.7/dist-packages/grove.
At approximately line 57 in adc.py, change
def __init__(self, address = 0x04)
todef __init__(self, address = 0x08)
.
Step 2: Install Code to Connect to EnOS¶
Download
the code
to connect to EnOS.Edit the code to enter the Group ID and Group Secret of the registration group.
nano main.py
The Device Provisioning Service will verify the device and register the device on EnOS. Once successfully registered, the device verification is passed from EnOS to the Device Provisioning Service and device information can be passed from the Device Provisioning Service back to the device.