This Tutorial describes how to use the Omron’s various sensor using Omron’s Arduino Evaluation board. You may watch the following video or read the written tutorial below for more details.
Introduction of Omron Evaluation BoardOmron has released three kinds of evaluation boards: raspberry pi, Arduino and Feather boards, which work with evaluation platforms like raspberry pi, Arduino and Adafruit feather respectively. In this article, we are testing various Omron sensors using Arduino Evaluation board. Evaluation board can connect with various sensors as it offers a variety of interfacing options such as I2C, Serial (UART), Analog, Digital, etc. These evaluation boards can connect easily to 14 models of Omron sensors over 5 different sensor categories including thermal sensors, flow sensors, differential pressure sensors, light convergent reflective sensors, and air quality sensor, all with optional cable harness. These sensor evaluation boards are equipped with six sensing function types - Barometric pressure, Temperature, Humidity, Light, Noise and Acceleration.
Step1: Hardware Components/cabling required:The materials that we would need for the evaluation are as follows:
- Omron Thermal Sensor D6T-1A-01
- Omron Differential Pressure Sensor (Flow Type) D6F-PH0505AD3
- Omron Flow Sensor D6F-10A7D-000-0
- Omron Light Convergent Sensor B5W-LB2101-1
- Omron Air Quality Sensor B5W-LD0101-1
- Omron Evaluation Board (Arduino type: 2JCIE-EV01-AR1)
- Arduino (Omron’s evaluation board can be used in the following Arduino: MKR Vidor 4000, MKR WiFi 1010, MKR ZERO)
- Harness: 2JCIE-HARNESS-01
- Harness: 2JCIE-HARNESS-02
- Harness: 2JCIE-HARNESS-03
- Harness: 2JCIE-HARNESS-04
- Harness: 2JCIE-HARNESS-05
- USB Cable (to connect Arduino and PC)
- Windows PC
The hardware setup section basically explains the wiring connections required among sensors, Arduino and Evaluation Board. Ensure correct connections, as it is the necessity while working on any system for the desired output.
The requisite connections are as follows:
- Solder Evaluation Board.
- Connect Arduino to Evaluation Board.
- Connect one end of the harnesses to the corresponding sensors.
- If you want to use D6F-PH Differential Pressure Sensor, you need to solder the sensor with the harness. (Connection of harness to sensor: yellow ->1, black ->2, red ->3, green ->4)
- Connect USB cable to Arduino board and the other end of harnesses to the Evaluation Board
- Keep in mind, connector for D6F Flow sensor and D6F-PH Differential Pressure Sensor on evaluation board is same. So please connect only one of the two harness either 2JCIE-HARNESS-02 or 2JCIE-HARNESS-03.
Steps to download:
1)
2)
3)
4)
5)
6)
7)
- Run the Arduino IDE on your PC.
- The IDE will look like this.
- Connect Arduino board to PC via USB cable.
- Install the package if there is notification in IDE
- Install the driver.
- Search ‘Device Manager’ in Windows Start Menu.
- Check the ‘COM Port’.
Sample source code for evaluation of sensors are available on Github and can be modified and implemented independently according to the users’ unique application. Access to the code.
After opening the page. Click ‘Clone or download’ in the upper right and download the ZIP file.
- Please select Arduino board type. (We use MKR WiFi 101
- Open the Sample Code in Arduino IDE.
- Select the code from the examples.
- Compile the sample code.
- Upload the sample code to Arduino.
- Output window will look like this
Here in the output window, that shows five different outputs and their description is as follows:
- B5W-LB: Light Convergence Sensor
- D6T-01: 1x1 Thermal Sensor
- D6F-PH: Differential Pressure Sensor
- D6F-10: Flow Sensor
- B5W-LD: Air Quality Sensor
B5W-LB: To test this place the finger close to the sensor. You will see the reading to be about 0V. If you start moving the finger away from the sensor the voltage starts to increase. The maximum output voltage is about 2V i.e. 2-4cm. If you move your finger farther than this distance, the voltage starts to decrease.
D6T-01: D6T can detect surface temperature of object. If the sensor detection area does not include any object, the output of sensor would be room temperature as it detects the wall/ceiling. If you bring your hand close to sensor, you will see rise in temperature, the output be about 30 degree C because of human body temperature/heat.
D6F-PH: Default reading of differential pressure sensor is about 0Pa. To test this, blow in the sensor. You will see change in differential pressure reading based on the intensity of blowing. One thing to notice is that the differential pressure reading can be positive or negative.
D6F-10: Default reading of flow sensor is about 0L/m. To test this, blow in the sensor. One thing to keep in mind is to blow in the direction of flow. You will see change in flow reading based on the intensity of the blow.
B5W-LD: Default value from the air quality sensor is about 0. In the output, we are showing particle count in 1s and 20s from the sensor, as the user has an option to reset the counter from system side. To test this, bring a cloth near the sensor, you will see the reading starts to increase which corresponds to the dust particles from the cloth. If you move the cloth away, the reading becomes 0.
Note: Keep in mind, we can only connect either D6F-PH or D6F-10 at one instance. So, during testing if the reading of the other sensor is changed, please discard it as the reading would be incorrect. For ex: In case, D6F-PH is connected and D6F-10 is not connected. If you see change in readings of D6F-10, please ignore it as readings would be incorrect.
References- B5W-LB: Light Convergence Sensor
Web Page; Data Sheet; User Manual; Sample Code
Applications:
- Bottle Detection: Recycling Sorting; Bottle Counting
- Packaging: Shrink-wrapping Machine; Label Machine
-Touchless Environment: Clean Room; Laboratories; Home Appliance Controls
- Cup Detection: Vending Machines; Drink Dispensers
- D6T: Thermal Sensor
Web Page; Data Sheet; User Manual;
Sample Code: D6T-1A-01, D6T-1A-02; D6T-8L-09, D6T-8L-09H;
D6T-44L-06, D6T-44L-06H; D6T-32L-01A
Applications:
-Equipment Usage (Occupancy sensing): Exercise Equipment; Ergonomic desks
-Equipment Monitoring (Abnormal heating detection): Servers; Industrial Equipment; Power Distribution Panels
-Room Air Conditioning (Occupancy sensing): Home Appliance Manufacturing; HVAC
-Working Environment (Occupancy sensing): Corporate Offices; Factories; Distribution Center
- D6F-PH: Differential Pressure Sensor
Web Page; Data Sheet; User Manual;
Sample Code: D6F-PH0505AD3; D6F-PH0025AD1; D6F-PH5050AD3
Applications:
-Flow monitor control / Clogging detection: HVAC (Variable air valve controller (VAV), Vent Control System, Air Conditioner, Fan)
- D6F: Flow Sensor
Web Page; Data Sheet; User Manual;
Sample Code: D6F-10A7D-000-0; D6F-20A7D-000-0; D6F-50A7D-000-0; D6F-70AB71D-000-0
Application:
-Flow Monitor Control: Fuel Cell; Analyzer (Environment Monitoring System, Gas Analyzer, Air Analyzer); HVAC (Variable air valve controller (VAV), Vent Control System, Air Conditioner, Fan); Clear room control
-Clogging Detection: HVAC (Variable air valve controller (VAV), Vent Control System, Air Conditioner, Fan); Server
- B5W-LD: Air Quality Sensor
Web Page; Data Sheet; Sample Code
Applications:
-Sensitive Environment: Clean Room; Laboratory
-HVAC: Heater; Ventilation
/*includes*/
#include <Wire.h>
#include <Arduino.h>
/* defines for D6T-01 */
#define D6T_ADDR 0x0A // for I2C 7bit address
#define D6T_CMD 0x4C // for D6T-44L-06/06H, D6T-8L-09/09H, for D6T-1A-01/02
#define N_ROW 1
#define N_PIXEL 1
#define N_READ ((N_PIXEL + 1) * 2 + 1)
uint8_t rbuf[N_READ];
/* defines for D6F-10 & D6F-PH0505 */
#define D6F_ADDR 0x6C // D6F-PH I2C client address at 7bit expression
/* defines for B5W-LB */
#if defined(ARDUINO_FEATHER_ESP32)
#define PIN_B5WLB_IN 13
#define PIN_B5WLB_OUT 33
#else
#define PIN_B5WLB_IN 19
#define PIN_B5WLB_OUT 17
#endif
/* defines for B5W-LD */
#if defined(ARDUINO_FEATHER_ESP32)
#define PIN_VOUT1 16
#define PIN_VOUT2 17
#define PIN_VTH 26
#define PIN_EN 21
#else
#define PIN_VOUT1 13
#define PIN_VOUT2 14
#define PIN_VTH 15
#define PIN_EN A3
#endif
static uint16_t state = 0;
static int counts_idx = 0;
static int counts20sec_vout1 = 0;
static int counts20sec_vout2 = 0;
/** D6T function ********/
uint8_t calc_crc(uint8_t data) {
int index;
uint8_t temp;
for (index = 0; index < 8; index++) {
temp = data;
data <<= 1;
if (temp & 0x80) {data ^= 0x07;}
}
return data;
}
/** <!-- D6T_checkPEC {{{ 1--> D6T PEC(Packet Error Check) calculation.
* calculate the data sequence,
* from an I2C Read client address (8bit) to thermal data end.
*/
bool D6T_checkPEC(uint8_t buf[], int n) {
int i;
uint8_t crc = calc_crc((D6T_ADDR << 1) | 1); // I2C Read address (8bit)
for (i = 0; i < n; i++) {
crc = calc_crc(buf[i] ^ crc);
}
bool ret = crc != buf[n];
if (ret) {
Serial.print("PEC check failed:");
Serial.print(crc, HEX);
Serial.print("(cal) vs ");
Serial.print(buf[n], HEX);
Serial.println("(get)");
}
return ret;
}
/** D6T function <!-- conv8us_s16_le {{{1 --> convert a 16bit data from the byte stream.*/
int16_t conv8us_s16_le(uint8_t* buf, int n) {
int ret;
ret = buf[n];
ret += buf[n + 1] << 8;
return (int16_t)ret; // and convert negative.
}
/**D6F function ************************/
uint8_t conv16_u8_h(int16_t a) {
return (uint8_t)(a >> 8);
}
uint8_t conv16_u8_l(int16_t a) {
return (uint8_t)(a & 0xFF);
}
uint16_t conv8us_u16_be(uint8_t* buf) {
return (uint16_t)(((uint32_t)buf[0] << 8) | (uint32_t)buf[1]);
}
/** D6F <!-- i2c_write_reg16 {{{1 --> I2C write bytes with a 16bit register.*/
bool i2c_write_reg16(uint8_t slave_addr, uint16_t register_addr,
uint8_t *write_buff, uint8_t len) {
Wire.beginTransmission(slave_addr);
Wire.write(conv16_u8_h(register_addr));
Wire.write(conv16_u8_l(register_addr));
if (len != 0) {
for (uint8_t i = 0; i < len; i++) {
Wire.write(write_buff[i]);
}
}
Wire.endTransmission();
return false;
}
/** D6F <!-- i2c_read_reg8 {{{1 --> I2C read bytes with a 8bit register. */
bool i2c_read_reg8(uint8_t slave_addr, uint8_t register_addr,
uint8_t *read_buff, uint8_t len) {
Wire.beginTransmission(slave_addr);
Wire.write(register_addr);
Wire.endTransmission();
Wire.requestFrom(slave_addr, len);
if (Wire.available() != len) {
return true;
}
for (uint16_t i = 0; i < len; i++) {
read_buff[i] = Wire.read();
}
return false;
}
/** <!-- setup {{{1 -->
* 1. initialize a Serial port for output.
* 2. initialize an I2C peripheral.
*/
void setup() {
Serial.begin(115200); // Serial baudrate = 115200bps
Wire.begin(); // i2c master
delay(32);
// D6F setup: EEPROM Control <= 0x00h
i2c_write_reg16(D6F_ADDR, 0x0B00, NULL, 0);
// B5W-LB setup: turn off LED for safe operation.
pinMode(PIN_B5WLB_IN, OUTPUT);
pinMode(PIN_B5WLB_OUT, INPUT);
digitalWrite(PIN_B5WLB_IN, LOW);
// B5W-LD setup:
pinMode(PIN_VOUT1, INPUT);
pinMode(PIN_VOUT2, INPUT);
// enable level-shifters for OUT1/OUT2 on 2JCIE-EV01
pinMode(PIN_EN, OUTPUT);
digitalWrite(PIN_EN, HIGH);
// setup B5W Threshould Voltage to 0.5[V]
pinMode(PIN_VTH, OUTPUT);
#if defined(ARDUINO_FEATHER_ESP32)
dacWrite(PIN_VTH, 0.5 / (3.3 / 256));
#else
analogWriteResolution(10);
analogWrite(PIN_VTH, 0.5 / (3.3 / 1024));
#endif
}
/** <!-- loop - Thermal sensor {{{1 -->
* 1. read sensor.
* 2. output results, format is: [degC]
*/
void loop() {
int i, j;
/**** B5W-LB *******************************/
int32_t i_low = 0;
float f_low = 0;
int32_t i_high = 0;
float f_high = 0;
float f_diff = 0;
/*****************************************/
/**** D6T *******************************/
int16_t itemp = 0;
/*****************************************/
/**** D6F *******************************/
uint8_t send0[] = {0x40, 0x18, 0x06};
uint8_t send1[] = {0x51, 0x2C};
uint8_t rbuf[2];
uint16_t rd_flow = 0;
float flow_rate = 0;
float pressure = 0;
/*****************************************/
/**** B5W-LD *******************************/
// VOUT1/2 sampling in 1sec.
uint8_t prv_gpio1 = LOW;
uint8_t prv_gpio2 = LOW;
int now = millis(), prev = now;
int counts_vout1 = 0;
int counts_vout2 = 0;
/*****************************************/
while (state < 5000){
switch(state){
/********** B5W-LB ****************************************************/
case 0:
// get Vout(OFF): output voltage when LED is turn off.
digitalWrite(PIN_B5WLB_IN, LOW);
break;
case 1:
case 2:
case 3:
case 4:
break;
case 5: //after 1000us
i_low = analogRead(PIN_B5WLB_OUT);
f_low = (float)i_low * 3.3 / 1024.0;
break;
case 6: //after 200us
// get Vout(ON): output voltage when LED is turn on.
digitalWrite(PIN_B5WLB_IN, HIGH);
break;
case 7:
break;
case 8: //after 400us
i_high = analogRead(PIN_B5WLB_OUT);
#if defined(ARDUINO_FEATHER_ESP32)
f_high = (float)i_high * 3.6 / 4096.0; // for Feather ESP32
#else
f_high = (float)i_high * 3.3 / 1024.0; // for Arduino MKR
#endif
break;
case 9:
break;
case 10: //after 400us should not be exceed 40% ON time of period.
// turn off to next period.
digitalWrite(PIN_B5WLB_IN, LOW);
f_diff = f_high - f_low; // cancellation processing for external disturbing light interference.
f_diff = f_diff < 0.0 ? 0.0: f_diff;
break;
/**********************************************************************/
/********** D6T ****************************************************/
case 900:
memset(rbuf, 0, N_READ);
Wire.beginTransmission(D6T_ADDR); // I2C client address
Wire.write(D6T_CMD); // D6T register
Wire.endTransmission(); // I2C repeated start for read
Wire.requestFrom(D6T_ADDR, N_READ);
i = 0;
while (Wire.available()) {
rbuf[i++] = Wire.read();
}
if (D6T_checkPEC(rbuf, N_READ - 1)) {
return;
}
itemp = conv8us_s16_le(rbuf, 2);
break;
/**********************************************************************/
/********** D6F ****************************************************/
case 12:
i2c_write_reg16(D6F_ADDR, 0x00D0, send0, 3);
break;
case 800:
i2c_write_reg16(D6F_ADDR, 0x00D0, send1, 2);
//if (i2c_read_reg8(D6F_ADDR, 0x07, rbuf, 2)) { // read from [07h]
// return;
//}
i2c_read_reg8(D6F_ADDR, 0x07, rbuf, 2);
rd_flow = conv8us_u16_be(rbuf);
flow_rate = ((float)rd_flow - 1024.0) * 10.0 / 60000.0; // Flow sensor D6F-10 : 0-10[L/min] range
pressure = ((float)rd_flow - 1024.0) * 100.0 / 60000.0 - 50.0; // Differential pressure sensor D6F-PH0505 : +/-50[Pa] range
break;
/**********************************************************************/
default:
break;
}
delayMicroseconds(200);
state ++;
/********** B5W-LD ****************************************************/
uint8_t cur_gpio1 = digitalRead(PIN_VOUT1);
uint8_t cur_gpio2 = digitalRead(PIN_VOUT2);
if (cur_gpio1 == HIGH && prv_gpio1 == LOW) {
counts_vout1++;
}
if (cur_gpio2 == HIGH && prv_gpio2 == LOW) {
counts_vout2++;
}
prv_gpio1 = cur_gpio1;
prv_gpio2 = cur_gpio2;
now = millis();
/**********************************************************************/
}
state = 0;
Serial.print(f_diff, 2);
Serial.println(" [V] (B5W-LB)");
Serial.print(itemp / 10.0, 1);
Serial.println(" [degC] (D6T-01)");
Serial.print(pressure, 2); // print converted flow rate
Serial.println(" [Pa] (D6F-PH)");
Serial.print(flow_rate, 2); // print converted flow rate
Serial.println(" [L/min] (D6F-10)");
// output 2sec counts, just for debug.
Serial.print(counts_vout1 - counts_vout2, 1);
Serial.print( "[count]");
// summarize and output 20sec counts
if (counts_idx < 19) { // summarize, output empty data.
Serial.print(", ----");
counts20sec_vout1 += counts_vout1;
counts20sec_vout2 += counts_vout2;
counts_idx++;
}
else { // output 20sec counts.
Serial.print(", ");
Serial.print(counts20sec_vout1 - counts20sec_vout2, 1);
counts_idx = counts20sec_vout1 = counts20sec_vout2 = 0;
}
Serial.println("[20s count] (B5W-LD)");
Serial.println(" ");
}
Comments
Please log in or sign up to comment.