This documentation is for WSO2 IoT Server 3.0.0. View the documentation for the latest release.
Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
Raspberry Pi - IoT Server 3.0.0 - WSO2 Documentation
||
Skip to end of metadata
Go to start of metadata

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:

Prerequisites 

  • A Raspberry Pi board that is Internet enabled (Wi-Fi or Ethernet).
  • An Adafruit DHT11 temperature sensor.
  • An LED bulb.

Start the Raspberry Pi

  1. Sign in to the Device Management console.

     Click here for more information.
    Follow the instructions below to sign into the IoTS device management console:
    1. Start the server.

    2. Access the device management console.

      • For access via HTTP: 
        http://<HTTP_HOST>:9763/devicemgt/ 

        For example: http://localhost:9763/devicemgt/
      • For access via secured HTTP: 
        https://<HTTPS_HOST>:9443/devicemgt/ 
        For example: https://localhost:9443/devicemgt/ 
    3. Enter the username and password, and sign in.

      The system administrator will be able to log in using admin for both the username and password. However, other users will have to first register with IoTS before being able to log into the IoTS device management console. For more information on creating a new account, see Registering with IoTS.

    4. Click LOGIN. The respective device management console will change, based on the permissions assigned to the user.
      For example, the device management console for an administrator is as follows:

  2. Click Enroll New Device.
  3. Click Raspberry Pi to enroll a device of the type Raspberry Pi.
  4. Connect the DHT11 Temperature Sensor and the LED to the Raspberry Pi board.

  5. 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.

  6. Download the device agent.
    1. Click Download Agent.
    2. Enter a preferred name on the download agent form.
    3. Click DOWNLOAD NOW to download the device agent on your machine. If you select this option move to step 7.
      Click COPY LINK to directly download the agent to the Raspberry Pi board via the generated cURL command. If you select this option move to step 8.
  7. Unzip the downloaded agent file and copy the unzipped file onto your Raspberry Pi board.
  8. Navigate to the downloaded agent that is on the Raspberry Pi board.
    Example: 

    cd <RASPBERRY_PI_BOARD>/agent
  9. Test to confirm that the agent is working as expected.

    ./testAgent.sh

    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.

    1. You will be prompted to get the apt-get updates and continue. Enter Yes to get the updates or enter No to continue without the updates.
      Example: Continue without receiving the apt-get updates.

      Do you wish to run 'apt-get update' and continue? [Yes/No] No


    2. 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.

      What's the time-interval (in seconds) between successive Data-Pushes to WSO2-IoTS (ex: '60' indicates 1 minute) > 45


    3. Run the test agent as a virtual agent. Enter Yes to run it as a virtual agent or enter No if 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.

      Do you want to run this as a virtual agent? (Yes/No) Yes

    Once the virtual agent starts you can view the data being pushed to the IoT Server.

    Example:

    RASPBERRY_STATS: Temp=25.0*C  Humidity=28.0%
    send: 'POST /raspberrypi/controller/push_temperature/ HTTP/1.1\r\nHost: 10.100.7.35:9443\r\nAccept-Encoding: identity\r\nAuthorization: Bearer 88f4940a2c26ef2b7b5d02d2767182c7\r\nContent-Type: application/json\r\nContent-Length: 84\r\n\r\n'
    {"owner":"admin","deviceId":"1h7ldn73eha2f","reply":"10.100.7.35:5678","value":"25"}
    ~~~~~~~~~~~~~~~~~~~~~~~~ Pushing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~
    send: '{"owner":"admin","deviceId":"1h7ldn73eha2f","reply":"10.100.7.35:5678","value":"25"}'
    reply: 'HTTP/1.1 204 No Content\r\n'
    header: Date: Wed, 20 Jan 2016 06:01:55 GMT
    header: Server: WSO2 Carbon Server
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    RASPBERRY_STATS: 204
    RASPBERRY_STATS: No Content
    RASPBERRY_STATS: Response Message
    Date: Wed, 20 Jan 2016 06:01:55 GMT
    Server: WSO2 Carbon Server
  10. 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.


    ./startService.sh

Try out the Raspberry Pi device

Once you start and deploy the Raspberry Pi agent you can try out the following actions:

ActionDescription
View device details

Navigate to the Device Details page to view the device details, carry out operations and monitor real-time data.

Control the bulb
  • 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.
Monitor real-time data

Click View Device Analytics to monitor real-time data via the Device Details page.

Example:

What's next?

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.

     Click here for more information on navigating to the Device Management page.
    1. Sign in to the Device Management console.
    2. Click the menu icon.
    3. Click Device Management.
  • Select a device from your device dashboard and check the available operations and monitor real-time data.
  • No labels