The ROHM Sensor Shield is an Arduino-compatible expansion board that allows users to quickly add any of a variety of sensors to their projects. Its straightforward layout and compactness makes it a great prototyping tool for both beginner and advanced Arduino enthusiasts.
The Sensor Evaluation Kit comes with the Sensor Shield and 8 different ROHM sensors: an accelerometer, a barometric pressure sensor, a geomagnetic sensor, an ambient-light/proximity sensor, a color sensor, a hall-effect sensor, a temperature sensor, and an ultraviolet light sensor.
The website, http://www.rohm.com/web/global/sensor-shield-support, provides detailed documentation about the sensor shield and each of the sensors, along with links to downloadable Arduino libraries for the individual sensors. The user-manual for the kit, which comes in the box and can also be found on the website, and it provides instructions on using the sensor shield with the sensors.
In this article, we will provide an overview of setting up and using the sensor shield for the first time and then demonstrate a simple IoT projects using the sensor shield along with some other components.
Figure 1. ROHM Sensor Shield (top right) with 8 different compatible sensors / @CoreStaff
Out of the box, two features stand out in particular. First, the board is designed so that users can work with more than one sensor simultaneously. For a project that involves two separate forms of sensing, users can prototype the whole system at once instead of in multiple separate steps. Convenient, isn’t it?!
Figure 2. More than one sensor can be plugged into the Sensor Shield at the same time (the picture shows both the temperature sensor and the proximity/ambient light sensor connected)
Second, the different sensors can all be plugged into the shield directly. This makes prototyping more compact and makes large projects more manageable. As the Analog, GPIO, and I2C communication connections are all made within the shield PCB itself, this eliminates the need for multiple jumper wires.
Take the I2C protocol for example. A standalone sensor communicating with the Arduino via I2C would require at least four separate connections (SDA, SCL, Power, and Ground) and 2 pull-up resistors on the SDA and SCL lines. Using the sensor shield, a user only has to plug the equivalent ROHM sensor into one of the I2C connections available on the shield.
The sensor shield has a row of male headers that run along one of its long edges. Most of these pins allow the user to configure a variety of hardware interrupts. As beginners, we’ll only focus on the first 3 rows starting from the edge of the board labeled “1.8V,” “3V,” and “5V” respectively. These three pins indicate voltage settings for the connected sensors. Because some of the sensors can only be operated at specific voltage levels, different voltage settings are available to choose from. To make a selection, the user must connect the pair of pins corresponding to that voltage level using a jumper pin. The jumper pin and an example 3V selection are shown here.
Figure 3. 3V power selection with jumper pin mounted
On the body of the board between the two rows of female headers that connect to the Arduino’s pins, there are eight different sets of female headers surrounded by some dotted lines. These are the connections for the different sensors.
It is important to note that to use a sensor, the user must plug it into a set of headers that corresponds to its method of communication. For example, the temperature sensor outputs an analog value, and therefore, it can only be connected to any of the two sets of headers that indicate analog connections. The manual provides a nice diagram of which headers correspond to each of the communication protocols.
Blue: Analog; Red: Digital GPIO; Green: I2C
Testing Temperature Sensor
The two sensors provided that output analog values are the temperature sensor and the ultraviolet light sensor. Choosing the temperature sensor as an example, we’ll first have to download the appropriate Arduino library to use the sensor, titled BD1020HFV (the name of the temperature sensor module).
Open up the example sketch provided with the library. At the top of the program below the library include statement, a variable tempout_pin is set to the value A2. In void setup(), the BD1020 object (the temperature sensor object) is initialized with this value, indicating that the sensor’s output values should be read from analog pin 2. This means that we must connect the temperature sensor module to the Analog_2 header on the sensor shield.
Figure 4.Temperature Sensor Connected to Analog 2 header (lower right of board)
Upload the sample sketch to the Arduino and open up the Serial Monitor. You should see a constant feed of messages indicating the current temperature being measured. To test if the sensor is working as expected, pinch your finger on the metal contact on the sensor. The messages should now indicate that the temperature has risen!
Figure 5. The metal contact of the temperature sensor is labeled “PAD1”
Here is a sample line of output: “BD1020HFV Temp=23.59 [degrees Celsius], ADC=277”
The “ADC” value indicates the integer conversion of the analog value (voltage) output by the sensor.
Next we’ll look at the sensors that communicate via the I2C protocol. These sensors are the accelerometer, the pressure sensor, the geomagnetic sensor, the ambient-light/proximity sensor, and the color sensor. Choosing the accelerometer as an example, we’ll first have to download the appropriate Arduino library to use the sensor, titled KX022.
Open up the example sketch provided with the library. Connect the accelerometer module to any of the I2C headers on the sensor shield and upload the example sketch. You may need to type in “#define byte uint8_t” as the first line of the program (above the #include statements) because the Arduino compiler may not recognize “byte” as a valid data type.
Figure 6. Accelerometer module connected to the I2C headers
Open up the Serial Monitor. You should see a constant feed of messages indicating the accelerations measured in X, Y, and Z. the axes are indicated on the accelerometer by a small drawing.
Figure 7. Accelerometer Module with directions of 3 axes shown
To test the accelerometer, move it suddenly in one of the axes. You should note a change in the acceleration component for that direction.
Here is a sample block of output:
“KX022 (X) = -0.02 [g]
KX022 (Y) = -0.00 [g]
KX022 (Z) = 1.00 [g]”
This output indicates that at the moment the values were recorded, the object on which the accelerometer is placed is experiencing virtually no acceleration in the X or Y direction and gravitational acceleration (towards the earth) in Z.
Testing Hall-Effect Sensor
Finally, we’ll look at the only sensor that communicates via a GPIO connection, the hall-effect sensor. The hall effect sensor detects only the presence or lack of a magnetic field. Therefore, its output is a digital signal, either a “low” indicating the presence of a magnetic field, or a “high” indicating the lack of a magnetic field.
Digital signal input and output (IO for short) occurs at the 5V level on the Arduino, so we’ll have to move the jumper pin to the 5V setting.
Figure 8. 5V Power Selection
We’ll first have to download the appropriate Arduino library to use the sensor, titled BD7411. Open up the example sketch provided with the library. There is only one slot for digital-output sensors like the hall-effect sensor on the sensor shield, labeled GPIO. Upload the sketch to the Arduino and open up the Serial monitor. In the presence of a magnetic field, the line “BD7411G Magnet field Detect!” will appear on the Serial Monitor.
To implement the sensor shield in your own projects, just download and include the libraries for the sensors that you plan to use, then use the different methods from these libraries to communicate with the sensors. You can refer to the example sketches that come with each library and the libraries’ source .cpp and .h files to see exactly how these methods are used.
Some simple projects that I made using different sensors and their libraries:
1. Light an LED when a magnetic field is present near the hall effect sensor