Rugged Board -A5D2x
Search…
RB Peripherals programming using UPM

LibUPM:

The UPM repository provides software drivers for a wide variety of commonly used sensors and actuators. These software drivers interact with the underlying hardware platform (or microcontroller), as well as with the attached sensors, through calls to [MRAA](https://github.com/intel-iot-devkit/mraa) APIs.
Programmers can access the interfaces for each sensor by including the sensor’s corresponding header file and instantiating the associated sensor class. In the typical use case, a constructor initializes the sensor based on parameters that identify the sensor, the I/O protocol used and the pin location of the sensor.
We endorse additions that implement the generic C and C++ interfaces provided with the libraries. Multiple sensor and actuator types have been defined, for instance:
  • Light controller
  • Light sensor
  • Temperature sensor
  • Humidity sensor
  • Pressure sensor
  • Gas sensor
  • Analog to digital converter
Simple diagram below depicts the use of Lib-UPM to interface various sensor modules.
The developer community is welcome to submit feedback on existing categories or suggest new ones. http://ruggedboard.wixsite.com/rugged-board/forum.

1. 3D Digital accelerometer and 3D Digital gyroscope (lsm6sdl) Testing with upm library

Description

  • To test the Temperature sensor on a5d2x-rugged board.

Required Hardware

  • Sensor Tag
  • a5d2x-rugged board
  • USB cable

Step-by-step guide

  • Connect the sensor tag on M1 connector of the Rugged board.
  • Boot the board with SD card/NOR.
  • Copy the below file to mnt directory of rugged board through tftp protocol.
vi lsm6sdl.py
1
from __future__ import print_function
2
import time, sys, atexit
3
from upm import pyupm_lsm6dsl as sensorObj
4
5
def main():
6
# Instantiate a BMP250E instance using default i2c bus and address
7
sensor = sensorObj.LSM6DSL(0,0x6b,-1)
8
9
# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
10
#LSM6DSL(0, -1, 10);
11
12
13
# now output data every 250 milliseconds
14
while (1):
15
sensor.update()
16
17
data = sensor.getAccelerometer()
18
print("Accelerometer x:", data[0], end=' ')
19
print(" y:", data[1], end=' ')
20
print(" z:", data[2], end=' ')
21
print(" g")
22
23
data = sensor.getGyroscope()
24
print("Gyroscope x:", data[0], end=' ')
25
print(" y:", data[1], end=' ')
26
print(" z:", data[2], end=' ')
27
print(" dps")
28
29
# we show both C and F for temperature
30
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
31
print(sensor.getTemperature(True), "F")
32
33
print()
34
time.sleep(.250)
35
36
if __name__ == '__main__':
37
main()
Copied!
Run the above code with below command in rugged board.
1
$ python3 lsm6sdl.py
Copied!

Expected Output

1
[email protected]-board-a5d2x-sd1:/mnt#python3 lsm6sdl.py
2
Accelerometer x: 0.065086998045444489 y: -0.045079004019498825 z: 1.0196759700775146 g
3
Gyroscope x: 0.25900000333786011 y: -0.29800000786781311 z: -0.34900000691413879 dps
4
Compensation Temperature: 24.995330810546875 C / 76.991592407226562 F
5
6
Accelerometer x: 0.065880000591278076 y: -0.043554000556468964 z: 1.0225430727005005 g
7
Gyroscope x: 0.25299999117851257 y: -0.29300001263618469 z: -0.35199999809265137 dps
8
Compensation Temperature: 24.995513916015625 C / 76.991928100585938 F
9
10
Accelerometer x: 0.065758004784584045 y: -0.043248999863862991 z: 1.0232139825820923 g
11
Gyroscope x: 0.25600001215934753 y: -0.29800000786781311 z: -0.35100001096725464 dps
12
Compensation Temperature: 24.99554443359375 C / 76.991981506347656 F
13
14
Accelerometer x: 0.065026000142097473 y: -0.043615002185106277 z: 1.0236409902572632 g
15
Gyroscope x: 0.25299999117851257 y: -0.29499998688697815 z: -0.3529999852180481 dps
16
Compensation Temperature: 24.9957275390625 C / 76.9923095703125 F
17
18
Accelerometer x: 0.065940998494625092 y: -0.044590998440980911 z: 1.0250440835952759 g
19
Gyroscope x: 0.25499999523162842 y: -0.30300000309944153 z: -0.34999999403953552 dps
20
Compensation Temperature: 24.995635986328125 C / 76.992141723632812 F
21
22
Accelerometer x: 0.063195995986461639 y: -0.044225003570318222 z: 1.0248609781265259 g
23
Gyroscope x: 0.25799998641014099 y: -0.30899998545646667 z: -0.35199999809265137 dps
24
Compensation Temperature: 24.99578857421875 C / 76.992416381835938 F
25
26
Accelerometer x: 0.067344002425670624 y: -0.047091998159885406 z: 1.0254100561141968 g
27
Gyroscope x: 0.24799999594688416 y: -0.28499999642372131 z: -0.35499998927116394 dps
28
Compensation Temperature: 24.995742797851562 C / 76.992340087890625 F
29
30
Accelerometer x: -0.0023789999540895224 y: -0.087779000401496887 z: 0.98210000991821289 g
31
Gyroscope x: 0.12999999523162842 y: 0.71799999475479126 z: -0.26899999380111694 dps
32
Compensation Temperature: 24.995712280273438 C / 76.992279052734375 F
33
34
Accelerometer x: -0.42687800526618958 y: -0.033184003084897995 z: 1.0443810224533081 g
35
Gyroscope x: -2.9779999256134033 y: 4.499000072479248 z: -0.9309999942779541 dps
36
Compensation Temperature: 24.995941162109375 C / 76.992691040039062 F
37
38
Accelerometer x: -0.47592198848724365 y: -0.20794901251792908 z: 0.70461100339889526 g
39
Gyroscope x: 8.3970003128051758 y: 32.763999938964844 z: 1.5110000371932983 dps
40
Compensation Temperature: 24.995880126953125 C / 76.992584228515625 F
41
42
Accelerometer x: 0.012810000218451023 y: -0.19733500480651855 z: 0.67978399991989136 g
43
Gyroscope x: -1.1679999828338623 y: 3.752000093460083 z: -0.17200000584125519 dps
44
Compensation Temperature: 24.995895385742188 C / 76.99261474609375 F
45
46
Accelerometer x: -0.10077200084924698 y: -0.12395200133323669 z: 1.0668900012969971 g
47
Gyroscope x: -0.62699997425079346 y: -18.709999084472656 z: 0.61000001430511475 dps
48
Compensation Temperature: 24.996047973632812 C / 76.992889404296875 F
49
50
Accelerometer x: 0.058681998401880264 y: -0.037758998572826385 z: 1.0333399772644043 g
51
Gyroscope x: 0.10999999940395355 y: 0.25099998712539673 z: -0.31799998879432678 dps
52
Compensation Temperature: 24.995986938476562 C / 76.992774963378906 F
53
54
^CTraceback (most recent call last):
55
File "lsm6dsl.py", line 37, in <module>
56
main()
57
File "lsm6dsl.py", line 34, in main
Copied!

2. Temperature sensor(mcp9808)- Interfacing using UPM library:

Description

  • To test the Temperature sensor on a5d2x-rugged board.

Required Hardware

  • Sensor Tag
  • a5d2x-rugged board
  • USB cable

Step-by-step guide

  • Connect the sensor tag on M1 connector of the Rugged board.
  • Boot the board with SD card/NOR.
  • Copy the below file to mnt directory of rugged board through tftp protocol.
vi mcp9808.py
1
#!/usr/bin/env python
2
3
from __future__ import print_function
4
import time, sys, atexit
5
from upm import pyupm_mcp9808 as MCP9808
6
7
def main():
8
# Instantiate the Infrared-Thermopile Sensor on I2C on bus 1
9
mySensor = MCP9808.MCP9808(0,0x18)
10
11
12
while(1):
13
print("Temperature : "+str(mySensor.getTemp()))
14
15
time.sleep(.5)
16
17
# Print out temperature value and config-reg in hex every 0.5 seconds
18
19
if __name__ == '__main__':
20
main()
Copied!
Run the above code with below command in rugged board.
1
$python3 mcp9808.py
Copied!

Expected Output

1
[email protected]-board-a5d2x-sd1:/mnt/python3 mcp9808.py
2
Temperature : 24.875
3
Temperature : 24.875
4
Temperature : 24.875
5
Temperature : 24.875
6
Temperature : 24.875
7
Temperature : 24.9375
8
Temperature : 24.875
9
^CTraceback (most recent call last):
10
File "mcp9808.py", line 20, in <module>
11
main()
12
File "mcp9808.py", line 15, in main
13
time.sleep(.5)
14
KeyboardInterrupt
15
[email protected]-som1-ek-sd:/mnt/microBus-wrkng-upm#
Copied!

3. Preassure and Humidity (bme280) sensor Interfacing using UPM library

Description

  • To test the Pressure and humidity sensor on a5d2x-rugged board.

Required Hardware

  • Sensor shield
  • a5d2x-rugged board
  • USB cable

Step-by-step guide

  • Connect the sensor shield on M1 connector of the Rugged board.
  • Boot the board with SD card/NOR.
  • Copy the below file to mnt directory of rugged board through tftp protocol.
vi bme280.py
1
from __future__ import print_function
2
import time, sys,atexit
3
from upm import pyupm_bmp280 as sensorObj
4
5
def main():
6
# Instantiate a BME280 instance using default i2c bus and address
7
sensor = sensorObj.BME280(0,0x76,-1)
8
9
# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
10
#BME280(3, -1, 60)
11
12
13
while (1):
14
sensor.update()
15
16
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
17
print(sensor.getTemperature(True), "F")
18
19
print("Pressure: ", sensor.getPressure(), "Pa")
20
21
print("Computed Altitude:", sensor.getAltitude(), "m")
22
23
print("Humidity:", sensor.getHumidity(), "%RH")
24
25
print()
26
time.sleep(1)
27
28
if __name__ == '__main__':
29
main()
Copied!
  • Run the above code with below command in rugged board.
1
$python3 bme280.py
Copied!

Expected Output

1
[email protected]-a5d2x:~# python3 bme280.py
2
random: python3: uninitialized urandom read (24 bytes read)
3
libmraa[125]: libmraa version v2.0.0 initialised by user 'root' with EUID 0
4
libmraa[125]: gpio: platform doesn't support chardev, falling back to sysfs
5
libmraa[125]: libmraa initialised for platform 'Atmel SAMA5' of type 20
6
libmraa[125]: i2c_init: Selected bus 2
7
Compensation Temperature: 21.790000915527344 C / 71.222000122070312 F
8
Pressure: 65306.53515625 Pa
9
Computed Altitude: 3552.7236328125 m
10
Humidity: 23.5859375 %RH
11
12
Compensation Temperature: 28.770000457763672 C / 83.786003112792969 F
13
Pressure: 91468.453125 Pa
14
Computed Altitude: 854.47808837890625 m
15
Humidity: 37.09765625 %RH
16
17
Compensation Temperature: 28.879999160766602 C / 83.984001159667969 F
18
Pressure: 91469.4765625 Pa
19
Computed Altitude: 854.3856201171875 m
20
Humidity: 37.416015625 %RH
21
22
Compensation Temperature: 28.909999847412109 C / 84.038002014160156 F
23
Pressure: 91469.5625 Pa
24
Computed Altitude: 854.3778076171875 m
25
Humidity: 37.388671875 %RH
26
27
Compensation Temperature: 28.920000076293945 C / 84.055999755859375 F
28
Pressure: 91469.34375 Pa
29
Computed Altitude: 854.3975830078125 m
30
Humidity: 37.3603515625 %RH
31
32
Compensation Temperature: 29.0 C / 84.199996948242188 F
33
Pressure: 91468.125 Pa
34
Computed Altitude: 854.50775146484375 m
35
Humidity: 38.0966796875 %RH
36
37
Compensation Temperature: 30.0 C / 86.0 F
38
Pressure: 91467.4375 Pa
39
Computed Altitude: 854.5699462890625 m
40
Humidity: 41.685546875 %RH
41
42
Compensation Temperature: 30.579999923706055 C / 87.043998718261719 F
43
Pressure: 91466.1328125 Pa
44
Computed Altitude: 854.6878662109375 m
45
Humidity: 44.8154296875 %RH
46
47
Compensation Temperature: 30.950000762939453 C / 87.709999084472656 F
48
Pressure: 91472.4140625 Pa
49
Computed Altitude: 854.12005615234375 m
50
Humidity: 47.4365234375 %RH
51
52
Compensation Temperature: 31.309999465942383 C / 88.358001708984375 F
53
Pressure: 91466.9375 Pa
54
Computed Altitude: 854.6151123046875 m
55
Humidity: 49.5576171875 %RH
56
57
Compensation Temperature: 31.590000152587891 C / 88.86199951171875 F
58
Pressure: 91466.296875 Pa
59
Computed Altitude: 854.67303466796875 m
60
Humidity: 51.091796875 %RH
61
62
Compensation Temperature: 31.329999923706055 C / 88.393997192382812 F
63
Pressure: 91469.1640625 Pa
64
Computed Altitude: 854.41387939453125 m
65
Humidity: 50.951171875 %RH
66
67
^CTraceback (most recent call last):
68
File "bme280.py", line 33, in <module>
69
main()
70
File "bme280.py", line 30, in main
71
time.sleep(1)
Copied!