Gadget Renesas

Linking Ideas and Electronics

アイテム

GR-PEACH Special Page

Try ROHM Sensor Evaluation Kits!

Overview:

Let's try ROHM Sensor Evaluation Kits, that enables to use 8 sensors, Accelerometer, Pressure sensor, Magnetometer, Ambient Light Proximity Sensor, Color Sensor, Hall IC, Temperature Sensor and Ultraviolet Sensor.
In this page, introducing how to use with Web compiler.

Preparations

Get ready GR-PEACH, a USB Cable (microB type) and ROHM Sensor Evaluation Kits.

login login

login

 

Importing library


Downloading

Download below zip which include libraries for accelerometer, pressure sensor, ambient light proximity sensor, color sensor, temperature sensor and ultraviolet sensor. The libraries are on the Rohm web site.

Click the below link, then started to download

rohm-lib.zip


Uploading to Web compiler

At the first, create a project for GR-PEACH on Web compiler. Then upload the zip into the root of your project. If it is the first time to use Web compiler, refer to "Sketch on Web Compiler" .

login


The folder "rohm-lib" is generated including library files.

login

 


Connecting a hardware

Connect 5 sensor modules to evaluation kits and set J15 jumper to 3V.

login


Connect kits to GR-PEACH. Then connect GR-PEACH to PC with USB. Finished the connection of all hardware.

login


 


Sample program

Below sample outputs the value of 5 sensors. Please monitor using software such as Tera Term or Coolterm. Copy the sample to gr_sketch.cpp on Web compiler and then build the sketch.



#include <Arduino.h>
#include <Wire.h>

#include <KX022.h>
#include <BM1383GLV.h>
#include <RPR-0521RS.h>
#include <BH1745NUC.h>
#include <BD1020.h>
#include <ML8511A.h>

KX022 kx022(KX022_DEVICE_ADDRESS_1E); //Accelerometer
BM1383GLV bm1383; //Pressure Sensor
RPR0521RS rpr0521rs; //PS/ALS Sensor
BH1745NUC bh1745nuc(BH1745NUC_DEVICE_ADDRESS_39); //Color Sensor
BD1020 bd1020; //Temperature Sensor
ML8511A ml8511a; //UV Sensor

int tempout_pin = 14; // A0
int uvout_pin = 16; // A2

void setup() {

  Serial.begin(9600);
  
  Wire.begin();
  kx022.init();
  bm1383.init();
  rpr0521rs.init();
  bh1745nuc.init();
  bd1020.init(tempout_pin);
  ml8511a.init(uvout_pin);
}

void loop() {
  byte rc;
  float acc[3], press, als_val, temp, uv;
  unsigned short ps_val, rgbc[4];
  byte near_far;

  //Accelerometer
  rc = kx022.get_val(acc);
  if (rc == 0) {
    Serial.print(" x= ");
    Serial.print(acc[0]);
    Serial.print(" y= ");
    Serial.print(acc[1]);
    Serial.print(" z= ");
    Serial.print(acc[2]);
  }

  //Pressure Sensor
  rc = bm1383.get_val(&press);
  if (rc == 0) {
    Serial.print(" ");
    Serial.print(press);
    Serial.print("[hPa]");
  }
  
  //PS/ALS Sensor
  rc = rpr0521rs.get_psalsval(&ps_val, &als_val);
  if (rc == 0) {
    Serial.print(" ");
    Serial.print(ps_val);
    Serial.print("[cnt]");
    near_far = rpr0521rs.check_near_far(ps_val);
    Serial.print("->");
    if (near_far == RPR0521RS_NEAR_VAL) {
      Serial.print(F(" Near"));
    } else {
      Serial.print(F(" Far"));
    }
    
    if (als_val != RPR0521RS_ERROR) {
      Serial.print(" ");
      Serial.print(als_val);
      Serial.print(F("[lx]"));
    }
  }
  
  //Color Sensor
  rc = bh1745nuc.get_val(rgbc);
  if (rc == 0) {
    Serial.print(" R:");
    Serial.print(rgbc[0]);
    Serial.print(" G:");
    Serial.print(rgbc[1]);
    Serial.print(" G:");
    Serial.print(rgbc[2]);
    Serial.print(" C:");
    Serial.print(rgbc[3]);
  }
  
  //Temperature Sensor
  bd1020.get_val(&temp);
  Serial.print(" ");
  Serial.print(temp);
  Serial.print("[C]");
  
  Serial.println();

  delay(100);

}
                                

Displayed the value of sensors in the serial monitor as below when the sample operates successfly.

login

 


share