Sensor Data Fusion
This introductory Instructable is all about the acquisition of various sensor data available on the grove starter kit plus that comes with the intel IoT developer kit.
Here we are going to use the following sensors available-
- Sound sensor
- Rotary angle sensor
- Touch sensor
The data absorbed from here will be displayed on the Grove RGB LCD.
Connecting the Sensors and the LCD
In this step, we will attach all the hardware components to the Edison. In the Grove starter kit plus, we have a Grove base shield. This base shield will be used for the Edison connections. For the above sensors that are to be used, sound sensor and rotary angle sensor have analog values as output. The touch sensor is used with digital pins. The LCD follows the I2C protocol. The values obtained from the sensor are displayed in the LCD. The image shown above shows the completed structure.
Code
#include
#include "rgb_lcd.h"
#define ROTARY_ANGLE_SENSOR A1
#define ADC_REF 5
#define GROVE_VCC 5
#define FULL_ANGLE 300
rgb_lcd lcd;
void setup()
{
//Initialize pin 2 to input for touch sensor
pinMode(2, INPUT);
lcd.begin(16, 2);
lcd.clear();
lcd.setRGB(100, 100, 100);
lcd.setCursor(0, 0);
lcd.print("SETTING UP . . . ");
delay(2000);
}
void loop()
{
//Sound sensor
int SoundLevel = analogRead(A0);
lcd.setCursor(0, 0);
lcd.print(SoundLevel);
//Rotary angle sensor
int degree = getDegree();
lcd.setCursor(8, 0);
lcd.print(degree);
//Touch sensor -->> LCD goes red and everything gets replaced with a warning message
int tState = digitalRead(2);
if (tState != 0)
{
lcd.setRGB(100, 0, 0);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WARNING!!!!");
}
//RESET the LCD
lcd.clear();
delay(200);
}
int getDegree()
{
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
float voltage;
voltage = (float)sensor_value * ADC_REF / 1023;
float degrees = (voltage * FULL_ANGLE) / GROVE_VCC;
return degrees;
}
Test & Results
Burn the code on your Intel Edison kit and observe the values as displayed on the LCD. Experiment with the sensors to get different values. The values are displayed on the LCD.
The image above shows the LCD display during operation.