How To Use Upm To Access Sensors And Peripherals - MEDIATEK LinkIt Smart 7688 Developer's Manual

Hide thumbs Also See for LinkIt Smart 7688:
Table of Contents

Advertisement

Now you're ready to run this Node.js application. In the
11)
command to run
node app
The W-Fi LED on LinkIt Smart 7688 should blink every second.
Press <Ctrl> C to terminate the program..
5.2.

How to use UPM to access sensors and peripherals

UPM
is an open source sensor and peripheral driver repository based on libmraa APIs. Among the
popular sensor drivers such as I2C accelerometers and many others are available from this
repository.
LinkIt Smart 7688 system image is pre-installed with UPM and you can start programming on
existing sensors immediately – but if the default implementation is not available, you can use
opkg package manager to update the UPM library.
UPM is similar to libmraa in the way that it comes with bindings in C++, Python and Node.js. Let's
get started with an example where you'll learn how to use UPM and Python to receive values from
an I2C accelerometer – a Grove 3-Axis Digital Accelerometer (±16g).
Connect the Accelerometer to your board. If you have the breakout board, you can attach
1)
it to the I2C grove interface. If not, you can also connect the pins from the accelerometer
to the corresponding pins GND, 3V3, SDA (P20) and SCL (P21) on LinkIt Smart 7688 board.
Import pyupm_adxl345 module from the UPM repository in your program, you'll do this in
2)
the next step. This module is used because the Grove 3-Axis Digital Accelerometer (±16g)
uses the ADXL345 chipset.
Create a Python script adxl.py with following content:
3)
import pyupm_adxl345 as adxl
import time
device = adxl.Adxl345(0)
while True:
device.update()
a = device.getAcceleration()
print "(x,y,z)=%5.1f, %5.1f, %5.1f" % (a[0], a[1], a[2])
time.sleep(0.3)
Execute the Python script in system console by typing the following command:
4)
# python adxl.py
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
MediaTek LinkIt™ Smart 7688 Developer's Guide
app.js
:
© 2015, 2016 MediaTek Inc.
app
directory, type following
Page 66

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents