The Idealist philosopher George Berkeley maintained that physical objects exist only so long as they are observed – and vanish when you stop looking at them. His mantra was: “to be is to be perceived”. Microcontrollers, whether fully embedded or in an IoT application, find themselves subject to a similar solipsistic outlook without high quality sensors to inform their decisions about their surroundings.
In what almost certainly isn’t a nod to George Berkeley, the need for MCUs to perceive their surroundings is why so many development boards are designed with defacto 'standardised' I/O pins in Arduino or Raspberry Pi format: so that developers can quickly make use of existing sensor and comms modules, without needing to redesign the wheel. It saves time and mistakes when you're starting out.
Rohm Semiconductor started making resistors in the early 1960’s – indeed, the company’s original name was R.ohm – ‘R’ for resistance, as you would find in a circuit diagram and ‘ohm’ as its unit of measure. In the years since then, they have branched out into a wide variety of semiconductor parts – including a broad spectrum of sensors, which is the subject of our article today.
In particular, we will be looking at a couple of add-on modules that Rohm produce for one of my favourite dev boards at the moment – the Sony Spresense.
ROHM Add On Boards
As you may remember, the Sony Spresense includes high resolution audio support and an advance GNSS receiver. However there are a number of GPIO pins where we can add functionality:
To experiment with this, I ordered a SPRESENSE-SENSOR-EVK-701which comes out of the box like this:
The little bubble that the board is packaged inside give it a huge amount of crush protection, which is great.
Even though it is a pretty tiny board, we get access to 3 sensors: a KX122 (KX126 in rev B boards) accelerometer, a BM1422magnetometer and a BM1383 barometric pressure sensor. As if that were not enough, there is also a sensor expansion connector that can support another 7 types of sensor, including brightness, proximity, colour, magnetism, temperature, UV light and pulse wave (heart) sensors.
I really like that they include a sheet with the pins labelled, the sensor specs and the Github repository address. It is a little thing, but it makes getting started so much easier when you don’t have to go looking for this information.
I decided that, while I was ordering the sensor module, I would go the whole hog and order the SPRESENSE-BLE-EVK-701Bluetooth LE Add-On board at the same time. Here is what we get out of that box:
This module includes a MK71251 BLE module with a built-in antenna and worldwide wireless certifications. Again, I like that they have included the information sheet with the pinout. It makes it easy to fit the modules to the Sony board:
Firing Up Our Senses
The quickest way to test that our sensors arrived in working order is to try out an Arduino example sketch for the sensor board. If you have already set up the Arduino IDE to support the Sony Spresense, you will see that there are a number of examples included in the support package:
In this case, I downloaded a zip file of the Arduino Github repository mentioned on the sheet included with the board. After extracting this file into my Arduino directory, I picked a sensor sketch (for the KX126 accelerometer on my rev B board) and uploaded it to the Spresense:
OK, great! When we open the serial monitor we can see some data coming through. Give the board a little shake and yes, we are getting varying accelerations recorded for each axis:
We can quickly check the BLE module too. Download the Lapis BLE Tool to your iPhone or Android phone and run it up. You will see a list of currently visible Bluetooth GATT broadcasts. Going down the list, we can find our Lapis BLE module. Clicking on this connection reveals device information about the module:
Great, so we can see our BLE module is there too. Now that we know our gear is sound, we can start experimenting.
I am now experimenting with the examples in the Nuttx SDK that I have installed on a Linux virtual machine. The latest SDK version has added a number of example application over what we had before:
We will upload a video of setting up the Nuttx SDK and our adventures with a few of these examples in the near future.