Oracle by Example brandingConnect a Wireless Device Having Location Sensors with Oracle IoT Asset Monitoring Cloud Service

section 0Before You Begin

This 20-minute tutorial shows you how to configure PixieBoard PRO PLUS to connect with Oracle IoT Asset Monitoring Cloud Service. PixieBoard PRO PLUS is a powerful but small wireless computer with location sensors that can help to track and monitor assets in Oracle IoT Asset Monitoring Cloud Service application.


PixieBoard PRO PLUS, a tiny computer running on Arch Linux®, has an integrated 9-axis inertial measurement unit (IMU) comprising a gyroscope, an accelerometer, and a magnetometer. Its global positioning system (GPS) and Global Navigation Satellite System (GLONASS) digital unit are instrumental in location tracking, motion detection and shock monitoring.. It also has four 1GHz ARM® Cortex™ A9 cores, a 2D co-processor, a powerful Vivante™ GPU, video decoding acceleration, 4 GB of RAM, dual band MIMO WI-FI® for up to 866Mbps transfers, Bluetooth® 4.1 EDR, 4G/3G cellular modem, high quality analog audio, three USB ports, dual uSD card slots, several GPIO and expansion options and can take power from a battery or A/C power source.

Oracle IoT Asset Monitoring Cloud Service manages enterprise assets, track their real-time location, health and utilization. You can view your asset metrics on the dashboard and automate actions based on predictive insights.

The following image displays the integration of a PixieBoard PRO Plus device with Oracle IoT Asset Monitoring Cloud Service.

Description of pixieboard_integration.png follows
Description of the illustration pixieboard_integration

What Do You Need?

section 1Configure the PixieBoard

After you've completed the one-time setup of the PixieBoard and its mobile broadband connection, configure the PixieBoard for location related measurements and Java installation.

  1. To access the integrated 9-axis IMU comprising a gyroscope, an accelerometer, and a magnetometer, install the i2c-tools package on the PixieBoard.
    sudo pacman -S i2c-tools
  2. Before you can access the GPS location of the device, you need to set the ModemManager service to run in debug mode. Edit the /etc/systemd/system/dbus-org.freedesktop.ModemManager1.service unit file to add --debug option to ExecStart and then reload the services' unit:
    sudo systemctl daemon-reload
  3. Transfer the JDK 8 archive that you downloaded to the PixieBoard at the /home/pixiepro directory.
  4. Extract the archive, create a directory for the installations and change to that directory:
    tar -xvzf jdk-8u211-linux-arm32-vfp-hflt.tar.gz
    #create directory
    sudo mkdir -p /usr/lib/jvm
  5. Copy the extracted directory to the new folder location and then install java-runtime-common and java-environment-common packages: 
    sudo cp -r jdk1.8.0_202 /usr/lib/jvm/java-8-oracle #install
    sudo pacman -S  java-runtime-common java-environment-common
  6. Run the archlinux-java script to select the default Java version and then reboot your PixieBoard:
  7. #set default version
    sudo archlinux-java set java-8-oracle/jdk1.8.0_211 #reboot
    sudo reboot

section 2Initialize Broadband Connection

Enable the modem, wait until the mobile broadband connection gets started, and record the modem identifier.

  1. Enable the modem and monitor the modem status:
    sudo enablePixieModem # monitor status
    sudo mmcli -L

    Verify if the status displayed is as follows and note the modem identifier

    that appears after the term Modem. In this example the modem identifier is 0.

    /org/freedesktop/ModemManager1/Modem/0 [QUALCOMM INCORPORATED]
     QUECTEL Mobile Broadband Module 

  2. Monitor the status of the mobile broadband connection by providing the connection name that you entered while setting up your PixieBoard:
    sudo nmcli -f GENERAL.STATE c show <connection name>

    Verify if the result of the previous command contains the following:

      GENERAL.STATE: activated

section 3Obtain Readings from Sensors

Enable the 9-axis IMU on your PixieBoard and obtain readings from its accelerometer, magnetometer and gyroscope.

  1. Enable the gyroscope, accelerometer, and the magnetometer:
    #enable gyroscope
    sudo sh -c 'echo 1 > /sys/devices/virtual/misc/FreescaleGyroscope/enable'

    #enable accelerometer
    sudo sh -c 'echo 1 > /sys/devices/virtual/misc/FreescaleAccelerometer/enable'

    #enable magnetometer sudo sh -c 'echo 1 > /sys/devices/virtual/misc/FreescaleMagnetometer/enable'
  2. Review and note the addresses of the three sensors from this address file, before you read their values from the I2C bus registers.
  3. For each sensor, use the i2cget utility to obtain the raw values of each axis, which is a two byte big-endian value. Review the following example of reading raw values of accelerometer's in the X axis.:
    # 1.Read first value byte : sudo i2cget -f -y 1 <chip address> <data address>
    sudo i2cget -f -y 1 0x1e 0x01 # 2.parse the hexadecimal value from the output
    # value after parsing the output: 0xfa 
    #### # 3.Read second value byte : sudo i2cget -f -y 1 <chip address> <data address+1> sudo i2cget -f -y 1 0x1e 0x02 # 4.parse the hexadecimal value from the output
    # value after parsing the output: 0xf0  #### # 5.Shift first value byte to the left by 8 bits and add the second value byte # The result will be: (0xfa << 8) + 0xf0 = 0xfaf0
  4. Use the multipliers data to convert the raw values into unit based values for each sensor.
    Sensor Target Unit Multiplier
    Gyroscope degrees/s 0.0078125 * 180.0 / π
    Accelerometer m/s2 9.80665 * 0.000244
    Magnetometer μTesla 0.01

section 4Access GPS Measurements

Initialize the GPS module of your PixieBoard and access GPS location of the device by using AT commands.

  1. Enter the following command to check the status of the GPS module and repeat until you get the desired response:
    # modem identifier is 0
    sudo mmcli -m 0 --command=AT+QGPS? 

    Verify if you receive a result that displays: response: AT+QGPS?: 0

  2. If the result displays a status of 1, then stop the ongoing GPS session:
    sudo mmcli -m 0 --command=AT+QGPSEND

    Repeat Step 1 until you get the status as 0.

  3. Initialize the GPS module :
    sudo mmcli -m 0 --command= AT+QGPS=1,30,50,0,1
  4. Check the status of the GPS module by performing Step 1 and repeat until you get a response with a status as 1, response: AT+QGPS?: 1.
  5. Query the current GPS location of the PixieBoard:
    sudo mmcli -m 0 --command= AT+QGPSLOC=2

    If the command fails then an error message is displayed. If the command is successful then the following message is displayed:

    response:+QGPSLOC:  <UTC>,<latitude>,<longitude>,<hdop>,<altitude>,<fix>,<cog>,

    Note: You need to parse the response string to extract the current latitude and longitude values. In the response, the latitude and longitude are string representation of Double values with dot as the decimal separator.

section 5Register the PixieBoard in Oracle IoT Cloud Service

Register the PixieBoard device and add it to your Oracle IoT Asset Monitoring Cloud Service instance.

  1. Identify the attributes for the GPS module and 9-axis IMU sensors of the PixieBoard.
  2. Sign in to your Oracle IoT Asset Monitoring Cloud Service instance and navigate to the Oracle IoT Cloud Service URL.
  3. Click Menu menu icon, on the left navigation bar, click Devices, and then click Model.
  4. On the Device Model page, click Add add icon.
  5. On the Create New Device Model page, enter or select the following and then click Save.
    • Name: PixieBoardDeviceModel
    • Description: Device model for the PixieBoard
    • URN: urn:com:oracle:iot:device:pixieboard
    • System Attributes: select ora_latitude and ora_longitude
    • Custom Attributes: Click Add add icon and create 9 custom attributes of type Number with the following names: accelerometer_X, accelerometer_Y, accelerometer_Z, gyroscope_X, gyroscope_Y, gyroscope_Z, magnetometer_X,magnetometer_X, magnetometer_X
  6. On the Device Model page, click Menu menu icon, and then on the left navigation bar, click Registration, and then click Register Single Device.
  7. On the Single Device Registration page, enter the details and click Register.
  8. On the Registration Successful page, enter the File Protection Password and click Download Provisioning File. Save the provisioning file into your system and copy it to your PixieBoard device.
  9. Click Menu menu icon, on the left navigation bar, click Devices, and click Applications. Click Oracle IoT Asset Monitoring Cloud Service and then click Device Model.
  10. On the Device Model page, click Choose Device Model choose icon and from the list, search your PixieBoard device model. Select it and click Done.
    choose device model
    Description of the illustration select_device_model.png

section 6Run the Java Application on PixieBoard

Run the sample Java application that uses the Java Client Library to connect the PixieBoard device to Oracle IoT Asset Monitoring Cloud Service and sends GPS location and readings from the 9-x IMU sensors. The Java applicaton registers the required device model and the PixieBoard device in Oracle IoT Cloud Service

  1. To build the sample application, go to the folder where you extracted the Java application archive, and enter the following command:
    ./gradlew build

    The output is stored in ./dist/

  2. On your PixieBoard, create a folder and name it sampleApp. Copy the file to your PixieBoard device and extract it to the sampleApp folder.
  3. Open and edit the sampleApp/config/config.json file to provide information about the Oracle IoT Cloud Service instance, messaging interval, and mobile broadband connection name. Optionally you can provide VPN configuration information.

    Note: To enable a VPN connection perform the following:

    # Enable systemd-resolved service:
    sudo systemctl enable systemd-resolved.service
    sudo reboot
    # Install openconnect package: sudo pacman -S openconnect

  4. Install the sample application service:
    chmod +x sampleApp/install/
    sudo /install/
  5. Reboot the PixieBoard:
    sudo reboot

section 7Verify the Connectivity

  1. Navigate to your Oracle IoT Cloud Service instance. Click Menu menu icon, Applications and then click Oracle IoT Asset Monitoring Cloud Service.
  2. Click Data and Explorations.
  3. On the Data tab, for the Filter field, select Device, and then click Select Device.
    select device
    Description of the illustration select_device.png
  4. From the list, select the PixieBoard Device that you had registered in Section 5, and then click Done.
  5. Verify that the GPS location values and messages from the gyroscope, accelerometer, and the magnetometer (9-axis IMU sensors) are displayed.

more informationWant to Learn More?