In this tutorial, you will connect a Raspberry Pi to WSO2 IoT Server and manage it. The following subsections explain how you can work with the Raspberry Pi device type:
Before you begin
- Make sure to have the following ready:
- A Raspberry Pi board that is Internet enabled (Wi-Fi or Ethernet).
- An Adafruit DHT11 temperature sensor.
- An LED bulb.
Navigate to the
<IOTS_HOME>/samplesdirectory and run the
Start the WSO2 IoT Server broker, core and, analytics profiles in the given order. For more information, see how to start the WSO2 IoT Server.
Let's get started!
Start the Raspberry Pi
Sign in to the Device Management console.Click here for more information.
- Click Enroll New Device.
- Click Raspberry Pi to enroll a device of the type Raspberry Pi.
Connect the DHT11 Temperature Sensor and the LED to the Raspberry Pi board.
Set up your Raspberry Pi device as shown in the schematic diagram.
Ensure that your Raspberry Pi Board is Internet enabled, either via Wi-Fi or Ethernet.
- Download the device agent.
- Click Download Agent.
- Enter a preferred name on the download agent form.
- Click DOWNLOAD NOW to download the device agent on your machine.
- Unzip the downloaded agent file and copy the unzipped file onto your Raspberry Pi board.
Navigate to the downloaded agent that is on the Raspberry Pi board.
Test to confirm that the agent is working as expected.
You can run the script on your local machine, on which the agent was downloaded.Click here to know more about testing the agent.
Follow the steps given below to confirm that the agent is working as expected.
You will be prompted to get the apt-get updates and continue. Enter
Yesto get the updates or enter
Noto continue without the updates.
Example: Continue without receiving the apt-get updates.
Enter the time interval that you require for the device to push data to WSO2 IoTS, in seconds.
Example: Push data to the IoTS every 45 seconds.
Run the test agent as a virtual agent. Enter
Yesto run it as a virtual agent or enter
Noif you wish to run the test on the Raspberry Pi device itself.
If the Raspberry Pi device is not connected to the IoT Server and if you enter
No, you will run into errors as the server will not be able to find the device.
Example: Running the agent as a virtual agent.
Once the virtual agent starts you can view the data being pushed to the IoT Server.
Start and deploy the agent as a service on the Raspberry Pi board once you have tested the agent as explained in step 9.
The registered service will be loaded on boot up.
Control the bulb
Once you start and deploy the Raspberry Pi agent, follow the steps given below to turn on or turn off the bulb connected to the Raspberry Pi board.
- Click Bulb On/Off under Operations on the Device Details page.
- Enter On to switch the bulb on and click Send to Device. Enter Off to switch the bulb off.
View device analytics
Clickto monitor real-time data via the Device Details page.
Follow the options given below to see what you can do next.
Navigate to the Device Management page to view all the devices created by you.
- Select a device from your device dashboard and check the available operations and monitor real-time data.