In the last part of this Mbed series, we saw how to get started with the Mbed online compiler for creating firmwares for the awesome iTracker board. If you missed it, please go through and setup your dev environment before proceeding with this part 2:
https://www.hackster.io/naresh-krish/getting-started-with-mbed-development-on-rak-itracker-be47d7
Itracker Sensors:
There is a whole whack-load of sensors on the iTracker board. from IMUs to environment sensors, it is really armed to the teeth in this cause. Lets look at each of them:
- Opt 3001 light sensor
- LIS3dh Triple axis accelerometer
- Lis2mdl Triple axis magnetic field sensor
- Bme280 Barometric pressure and temperature sensor
And there is provision for a few more GPIOs and a GPIO for tilt sensor exposed via the female header on the board.
Phew !! That is a lot of connectivity and a lot of sensors for such a small module. Some of the use cases for this module are:
- Vehicle Tracker and fleet management
- Personnel positioning
- Home security
- Safety monitoring for children/elders
- Animal husbandry and protection
According to Bosch which manufactures the sensor:
"The BME280 is an integrated environmental sensor developed specifically for mobile applications where size and low power consumption are key design constraints. The unit combines individual high linearity, high accuracy sensors for pressure, humidity and temperature in an 8-pin metal-lid 2.5 x 2.5 x 0.93 mm³ LGA package, designed for low current consumption (3.6 μA @1Hz), long term stability and high EMC robustness.
The humidity sensor features an extremely fast response time which supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range. The pressure sensor is an absolute barometric pressure sensor with features exceptionally high accuracy and resolution at very low noise. The integrated temperature sensor has been optimized for very low noise and high resolution. It is primarily used for temperature compensation of the pressure and humidity sensors, and can also be used for estimating ambient temperature."
According to ST Microelectronics:
The LIS2MDL is an ultra-low-power, high-performance 3-axis digital magnetic sensor. The LIS2MDL has a magnetic field dynamic range of ±50 gauss. The LIS2MDL includes an I2C serial bus interface that supports standard, fast mode, fast mode plus, and high-speed (100 kHz, 400 kHz, 1 MHz, and 3.4 MHz) and an SPI serial standard interface. The device can be configured to generate an interrupt signal for magnetic field detection.
The LIS2MDL is available in a plastic land grid array package (LGA) and is guaranteed to operate over an extended temperature range from -40 °C to +85 °C.
Key Features
- 3 magnetic field channels
- ±50 gauss magnetic dynamic range
- 16-bit data output
- SPI/I2 C serial interfaces
- Analog supply voltage 1.71 V to 3.6 V
- Selectable power mode/resolution
- Single measurement mode
- Programmable interrupt generator
- Embedded self-test
- Embedded temperature sensor
- ECOPACK® , RoHS and “Green” compliant
The LIS3DH is an ultra-low-power high-performance three-axis linear accelerometer belonging to the “nano” family, with digital I2C/SPI serial interface standard output. The device features ultra-low-power operational modes that allow advanced power saving and smart embedded functions.
The LIS3DH has dynamically user-selectable full scales of ±2g/±4g/±8g/±16g and is capable of measuring accelerations with output data rates from 1 Hz to 5.3 kHz. The self-test capability allows the user to check the functioning of the sensor in the final application. The device may be configured to generate interrupt signals using two independent inertial wake-up/free-fall events as well as by the position of the device itself. Thresholds and timing of interrupt generators are programmable by the end user on the fly. The LIS3DH has an integrated 32-level first-in, first-out (FIFO) buffer allowing the user to store data in order to limit intervention by the host processor. The LIS3DH is available in small thin plastic land grid array package (LGA) and is guaranteed to operate over an extended temperature range from -40 °C to +85 °C.
Key Features
- Wide supply voltage, 1.71 V to 3.6 V
- Independent IO supply (1.8 V) and supply voltage compatible
- Ultra-low-power mode consumption down to 2 μA
- ±2g/±4g/±8g/±16g dynamically selectable full scale
- I2 C/SPI digital output interface
- 16-bit data output
- 2 independent programmable interrupt generators for free-fall and motion detection
- 6D/4D orientation detection
- Free-fall detection
- Motion detection
- Embedded temperature sensor
- Embedded self-test
- Embedded 32 levels of 16-bit data output FIFO
- 10000 g high shock survivability
- ECOPACK® , RoHS and “Green” compliant
The OPT3001 is a sensor that measures the intensity of visible light. The spectral response of the sensor tightly matches the photopic response of the human eye and includes significant infrared rejection.The OPT3001 is a single-chip lux meter, measuring the intensity of light as visible by the human eye. The precision spectral response and strong IR rejection of the device enables the OPT3001 to accurately meterthe intensity of light as seen by the human eye regardless of light source. The strong IR rejection also aids in maintaining high accuracy when industrial design calls for mounting the sensor under dark glass for aesthetics. The OPT3001 is designed for systems that create light-based experiences for humans, and an ideal preferred replacement for photodiodes, photoresistors, or other ambient light sensors with less human eye matching and IR rejection.
Key Features
- Precision Optical Filtering to Match Human Eye
- Rejects > 99% (typ) of IR
- Automatic Full-Scale Setting Feature Simplifies Software and Ensures Proper Configuration
- Measurements: 0.01 lux to 83k lux
- Max Quiescent Current: 2.5µA
- 23-Bit Effective Dynamic Range with Automatic Gain Ranging
- 12 Binary-Weighted Full-Scale Range Settings
- < 0.2% (typ) Matching Between Ranges
- Low Operating Current: 1.8µA (typ)
- Operating Temperature Range: -40°C to +85°C
- Wide Power-Supply Range: 1.6V to 3.6V
- 5.5V Tolerant I/O
- Flexible Interrupt System
- Small-Form Factor: 2.0mm×2.0mm×0.65mm
The Mbed APIs let you interface ever so easily with these modules and lets see some code in action:
Setting up your Mbed sample appI have created sample apps for each of the sensor and for interfacing the sensor values via BLE GATT as well:
Here are the links to the Sensor sample apps
BME 280:
https://os.mbed.com/users/knaresh89/code/itracker-mbed-os-example-bme280/
LIS3DH:
https://os.mbed.com/users/knaresh89/code/itracker-mbed-os-example-lis3dh/
LIS2MDL:
https://os.mbed.com/users/knaresh89/code/itracker-mbed-os-example-lis2mdl/
OPT3001:
https://os.mbed.com/users/knaresh89/code/itracker-mbed-os-example-opt3001/
Wireless radios SamplesBLE GATT:
https://os.mbed.com/users/knaresh89/code/itracker-mbed-os-example-blegatt/
Ill be posting the code for the GSM and GPS modules as a separate part 3 of this series as they demand some explanation as to how they function.
Now go over to any one of the Projects above and on the right hand side panel, you will see the following button:
Click on the "import into Compiler option"
The project will open up in the mbed compiler. If you haven't logged in yet, now will be a good time to login with your mbed ID. Build the program using the Compile option on the top menu bar. It should provide a .hex file that you can program onto you board
Flashing the firmware:Once you have the board connected to USB via the Jlink module (if not follow part 1, link above) follow the steps below:
The firmware is always a hex file. Our firmware wouldnt have the bootloader also in built which we will get to in the upcoming tutorials in much more detail. For now we will just flash the hex directly.
Open a commandline prompt. I will consider Ubuntu OS for this.
Run the following commands:
cd to the folder containing the firmware you just downloaded
nrfjprog -e -f nrf52
nrfjprog --program xxx.hex -f nrf52 --verify
nrfjprog -f nrf52 --reset
Flashing firmware using nrfGo:This firmware upgrade scenario involves uploading the application onto the board using a cable connection.
You will require nRFgo Studio to run this procedure. Alternatively, you can use a J-Link programmer.
Follow these steps to update Thingy using your own compiled application:
- Start nRFgo Studio.
- Connect your board to the host.
- Select nRF52 development boards.
- Click Erase all.
- In the Program SoftDevice tab, browse for the S132 v4.0.2 HEX file and click Program.
- In the Program Application tab, browse for your application HEX file and click Program.
Follow these steps to flash the factory image:
- Start nRFgo Studio.
- Connect your board to the host.
- Select nRF52 development boards.
- Click Erase all.
- In the Program Application tab, browse for the factory HEX file and click Program.
RTT Viewer can be used stand-alone, opening an own connection to J-Link and target or in parallel to a running debug session, attaching to it and using this existing J-Link connection. RTT Viewer supports all major features of RTT:
- Terminal output on Channel 0
- Sending text input to Channel 0
- Up to 16 virtual Terminals with only one target channel
- Controlling text output: Colored text, erasing the console
- Logging data on Channel 1
In Ubuntu, Open a terminal and Type
$ JLinkExe
This will open a Jlink commanline utility. Now type
J-Link> connect
It was ask three things:
1)Device name/type: enter NRF52
2) TIF or connection interface: type SWD
3) target interface clock speed: leave default and hence press enter
It should show up like so:
Now lets launch the RTT viewer, in another console, Type
> JLinkRTTClient
It will connect to the JlinkExe at a localhost port and wait for RTT messages like so:
Now once you firmware if flashed and printf statements you type by using the function SEGGER_RTT_printf would end up in the terminal which has the RTTclient utility running.
This is great for debugging purposes. Please tinker with the code and never hesitate to ping me for doubts. I have provided sufficient documentation in the all the mbed sample apps to ensure that the most common doubts that i had have a note or an answer in the code :)
One great example of using the RTT CLient would be to see the output of the IMU sensors when you twist and turn the module. Its great fun. Keep tinkering and let me know if the tutorial helped you in your projects
Comments
Please log in or sign up to comment.