Mind
Published © GPL3+

Magic Sensor Test Box

This comprehensive test box uses the Grove Sensor Starter Kit to complete some interesting experiments.

EasyWork in progress2 hours254
Magic Sensor Test Box

Things used in this project

Hardware components

Seeed Grove Starter Kit for Arduino
Well selected Grove modules with different functions including sensing, input, display etc, very suitable for beginners.
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Wood Box
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic diagram of circuit connection

Sch gfcvix7bra

Code

Software code

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

rgb_lcd lcd;

#define pinTempSensor A0     // Grove - Temperature Sensor connect to A0
#define pinLightSensor A2

int B = 4275;               // B value of the thermistor
int R0 = 100000;            // R0 = 100k

byte Red;
byte Green;
byte Blue;

void setup()
{
  Serial.begin(9600);  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}

void loop()
{
  int Luminance = analogRead(pinLightSensor);
  lcd.setCursor(0, 0);
  lcd.print("Luminance:");
  lcd.print(Luminance);
  
  int value = analogRead(pinTempSensor);  
  float R = 1023.0 / value - 1.0;
  R = R0 * R;
  float temperature = 1.0 / (log(R / R0) / B + 1 / 298.15) - 273.15; // convert to temperature via datasheet
  lcd.setCursor(0, 1);
  lcd.print("Temperature:");
  lcd.println(temperature);

  if (temperature >= 0) {
    Red = map(temperature, 0, 60, 0, 255);
    Green = map(Luminance, 0, 800, 0, 255);
    Blue = 0;
  }
  else {
    Red = 0;
    Green = map(Luminance, 0, 800, 0, 255);
    Blue = map(temperature, -40, 0, 255, 0);
  }
  
  lcd.setRGB(Red, Green, Blue); 
  delay(100);
}

Credits

Mind

Mind

0 projects • 0 followers

Comments

Add projectSign up / Login