element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Summer of Green Tech Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Summer of Green Tech Design Challenge
  • More
  • Cancel
Summer of Green Tech Design Challenge
Blog Home monitoring system #3
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Summer of Green Tech Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: redcharly
  • Date Created: 12 Oct 2023 3:21 PM Date Created
  • Views 968 views
  • Likes 6 likes
  • Comments 6 comments
  • summer of green tech design challenge
  • seeedstudio
  • green tech
  • Xiao
  • arduino
Related
Recommended

Home monitoring system #3

redcharly
redcharly
12 Oct 2023

Introduction

Hi, in this blog I want to test the other sensor boards that I've received as part of the kit, I'll start with the temperature sensor board 

Infrared Temperature Sensor

I used the information on the page:  Grove - Infrared Temperature Sensor | Seeed Studio Wiki 

This Infrared temperature sensor is a non-contact temperature measure model. It is composed of 116 elements of thermocouple in series on a floating micro-membrane, the black surface of the sensor is good to absorb the incident thermal infrared radiation, which might trigger a voltage response at output. This sensor outputs an analog voltage (0~1.1V) according to target temperature.

It's measuring range is: -10~100°C.

image

The application we will try simply reads the ambient temperature and that of the object placed approximately 9 cm away and displays the value on the terminal via a serial connection.
This sensor is very different from the DHT20 and is used to measure the temperature of objects placed in an environment, while the DHT20 measures the temperature and humidity of the environment.

#include <math.h>

#define SUR_TEMP_PIN A0 // Analog input pin connect to temperature sensor SUR pin
#define OBJ_TEMP_PIN A1 // Analog input pin connect to temperature sensor OBJ pin
float temp_calibration=-25;       //this parameter was used to calibrate the temperature
//float objt_calibration=0.000; //this parameter was used to calibrate the object temperature
float temperature_range=10;    //we make a map of temperature-voltage according to sensor datasheet. 10 is the temperature step when sensor and 
                               //object distance is 9CM.
float offset_vol=-0.334;        //this parameter was used to set the mid level voltage,when put the sensor in normal environment after 10 min,
                               //the sensor output 0.For example,the surrounding temperature is 29℃,but the result is 27℃ via the sensor,
                               //you should set the reerence to 0.520 or more,according to your sensor to change.
                               //the unit is V
float tempValue = 0; 
float objtValue= 0;  
float current_temp=0;
float temp=0;
float temp1=0;
float temp2=0;
unsigned int temp3=0;
const float reference_vol=0.500;
unsigned char clear_num=0;//when use lcd to display
float R=0;
float voltage=0;


long res[100]={
                 318300,302903,288329,274533,261471,249100,237381,226276,215750,205768,
                 196300,187316,178788,170691,163002,155700,148766,142183,135936,130012,
                 124400,119038,113928,109059,104420,100000,95788,91775,87950,84305,
                 80830,77517,74357,71342,68466,65720,63098,60595,58202,55916,
                 53730,51645,49652,47746,45924,44180,42511,40912,39380,37910,
                 36500,35155,33866,32631,31446,30311,29222,28177,27175,26213,
                 25290,24403,23554,22738,21955,21202,20479,19783,19115,18472,
                 17260,16688,16138,15608,15098,14608,14135,13680,13242,12819,
                 12412,12020,11642,11278,10926,10587,10260,9945,9641,9347,
                 9063,8789,8525,8270,8023,7785,7555,7333,7118,6911};
                 
float obj [13][12]={
/*0*/             { 0,-0.274,-0.58,-0.922,-1.301,-1.721,-2.183,-2.691,-3.247,-3.854,-4.516,-5.236}, //
/*1*/             { 0.271,0,-0.303,-0.642,-1.018,-1.434,-1.894,-2.398,-2.951,-3.556,-4.215,-4.931},  //→surrounding temperature,from -10,0,10,...100
/*2*/             { 0.567,0.3,0,-0.335,-0.708,-1.121,-1.577,-2.078,-2.628,-3.229,-3.884,-4.597},   //↓object temperature,from -10,0,10,...110
/*3*/             { 0.891,0.628,0.331,0,-0.369,-0.778,-1.23,-1.728,-2.274,-2.871,-3.523,-4.232},
/*4*/             { 1.244,0.985,0.692,0.365,0,-0.405,-0.853,-1.347,-1.889,-2.482,-3.13,-3.835},
/*5*/             { 1.628,1.372,1.084,0.761,0.401,0,-0.444,-0.933,-1.47,-2.059,-2.702,-3.403},
/*6*/             { 2.043,1.792,1.509,1.191,0.835,0.439,0,-0.484,-1.017,-1.601,-2.24,-2.936},
/*7*/             { 2.491,2.246,1.968,1.655,1.304,0.913,0.479,0,-0.528,-1.107,-1.74,-2.431},
/*8*/             { 2.975,2.735,2.462,2.155,1.809,1.424,0.996,0.522,0,-0.573,-1.201,-1.887},
/*9*/             { 3.495,3.261,2.994,2.692,2.353,1.974,1.552,1.084,0.568,0,-0.622,-1.301},
/*10*/            { 4.053,3.825,3.565,3.27,2.937,2.564,2.148,1.687,1.177,0.616,0,-0.673},
/*11*/            { 4.651,4.43,4.177,3.888,3.562,3.196,2.787,2.332,1.829,1.275,0.666,0},
/*12*/            { 5.29,5.076,4.83,4.549,4.231,3.872,3.47,3.023,2.527,1.98,1.379,0.72}
};

void setup() 
{
	Serial.begin(9600); // initialize serial communications at 9600 bps
	analogReference(AR_DEFAULT);//set the refenrence voltage 1.1V,the distinguishability can up to 1mV.
	//analogReference(INTERNAL1V1);//(mega only)set the refenrence voltage 1.1V,the distinguishability can up to 1mV.
}
void loop()
{
	measureSurTemp();//measure the Surrounding temperature around the sensor
	measureObjectTemp();
}

float binSearch(long x)// this function used for measure the surrounding temperature
{
	int low,mid,high;
	low=0;
	//mid=0;
	high=100;
	while (low<=high)
	{
		mid=(low+high)/2;
		if(x<res[mid])
			low= mid+1;
		else//(x>res[mid])
			high=mid-1;
	}
	return mid;
}

float arraysearch(float x,float y)//x is the surrounding temperature,y is the object temperature
{
	int i=0;
	float tem_coefficient=100;//Magnification of 100 times	
	i=(x/10)+1;//Ambient temperature			
	voltage=(float)y/tem_coefficient;//the original voltage		
	//Serial.print("sensor voltage:\t");		
	//Serial.print(voltage,5);	
	//Serial.print("V");			
	for(temp3=0;temp3<13;temp3++)		
	{			
		if((voltage>obj[temp3][i])&&(voltage<obj[temp3+1][i]))				
		{			
			return temp3;					
		}			
	}
}
float measureSurTemp()
{  
	unsigned char i=0;
	float current_temp1=0;	  
	int signal=0;	  
	tempValue=0;

	for(i=0;i<10;i++)       //	  
	{		  
		tempValue+= analogRead(SUR_TEMP_PIN); 		  
		delay(10); 	  
	}	  
	tempValue=tempValue/10;	  
	temp = tempValue*1.1/1023;	  
	R=2000000*temp/(2.50-temp);	  
	signal=binSearch(R);	  
	current_temp=signal-1+temp_calibration+(res[signal-1]-R)/(res[signal-1]-res[signal]);
	Serial.print("Surrounding temperature:");
	Serial.print(current_temp);
	return current_temp;
}

float measureObjectTemp()
{
	unsigned char i=0;  
	unsigned char j=0;  
	float sur_temp=0;  
	unsigned int array_temp=0;  
	float temp1,temp2; 
	float final_temp=0;
	objtValue=0;	
	for(i=0;i<10;i++)
	{
		objtValue+= analogRead(OBJ_TEMP_PIN); 
		delay(10); 
    }       
	objtValue=objtValue/10;//Averaging processing     
	temp1=objtValue*1.1/1023;//+objt_calibration; 
	sur_temp=temp1-(reference_vol+offset_vol);             
	Serial.print("\t Sensor voltage:");		
	Serial.print(sur_temp,3);	
	Serial.print("V");	
	array_temp=arraysearch(current_temp,sur_temp*1000);        
	temp2=current_temp;        
	temp1=(temperature_range*voltage)/(obj[array_temp+1][(int)(temp2/10)+1]-obj[array_temp][(int)(temp2/10)+1]);        
	final_temp=temp2+temp1;        
	if((final_temp>100)||(final_temp<=-10))
		{
		Serial.println ("\t out of range!");
		}
	else
		{
			Serial.print("\t object temperature:");		
			Serial.println(final_temp,2); 
			}
}

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


The Wiki page carefully explains how to carry out the sensor calibration phase to optimize precision. I was just curious to see one hundred tiny thermocouples in action and I only tested their operation in a qualitative manner, without carrying out any calibration.
This time too everything worked as expected.

Hall Sensor

Hall sensors are capable of measuring a wide range of magnetic fields and are sensitive to both the magnitude and orientation of the field. When used as electronic switches, they are less prone to mechanical failure.

Grove - Hall Sensor | Seeed Studio Wiki

image

Features

  • Outstanding endurancee: Non-contact, wear-free operation, low maintenance, and immunity to vibration, dust, and water, so no need to worry about mechanical failures.
  • Rapid response: Hall-effect magnetic switch, only 400ns transition period for rise and fall.

#define HALL_SENSOR 2

void setup()
{
 	pinsInit();
}
 
void loop() 
{
	if(isNearMagnet())//if the hall sensor is near the magnet?
	{
		turnOnLED();
	}
	else
	{
		turnOffLED();
	}
}
void pinsInit()
{
	pinMode(HALL_SENSOR, INPUT);
	pinMode(LED_BUILTIN,OUTPUT);
}

/*If the hall sensor is near the magnet whose south pole is facing up, */
/*it will return ture, otherwise it will return false.				*/
boolean isNearMagnet()
{
	int sensorValue = digitalRead(HALL_SENSOR);
	if(sensorValue == LOW)//if the sensor value is LOW?
	{
		return true;//yes,return ture
	}
	else
	{
		return false;//no,return false
	}
}
void turnOnLED()
{
	digitalWrite(LED_BUILTIN,LOW);
}
void turnOffLED()
{
	digitalWrite(LED_BUILTIN,HIGH);
}

Using this sensor was very simple. It's output signals when there is a magnet near the sensor. The sensor board has also a red LED that signals when a magnetic field is found.

I used the example code on the Wiki page making only a small modification to use the internal LED of Seeed XIAO SAMD21

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Flame Sensor

Flame Sensor can be used to detect fire source or other light sources of the wavelength in the range of 760nm - 1100 nm. Due to its black epoxy, the sensor is sensitive to infrared radiation and it's sensitivity is adjustable. In fire fighting robot game, the sensor plays a very important role, it can be used as a robot eyes to find the fire source.

image

Information for this sensor can be found on the Wiki page dedicated to it: Grove - Flame Sensor | Seeed Studio Wiki.

This sensor is very simple to use and has a tiny trimmer that allows you to adjust the sensitivity of the sensor, so you can calibrate it for specific occasions. It is really very sensitive to flame and can work outside without too many false alarms.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Again we used the code from the example on the sensor Wiki page with minimal changes. Everything worked right away.

#define FLAME_SENSOR 3 //connect FLAME_SENSOR to digital pin3

void setup() 
{                
	pinsInit();
}
void loop() 
{
  if(isFlameDetected())
  	turnOnLED();
  else turnOffLED();
}
/********************************/
void pinsInit()
{
	pinMode(FLAME_SENSOR, INPUT);
	pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, LOW);
}
void turnOnLED()
{
	digitalWrite(LED_BUILTIN, LOW);
}
void turnOffLED()
{
	digitalWrite(LED_BUILTIN, HIGH);
}
boolean isFlameDetected()
{
	if(digitalRead(FLAME_SENSOR))
		return false;
	else return true;
}

In this blog we saw applications of the last three sensor boards from the Seeed kit using XIAO SAMD2. All worked very well without any great configuration problems.

  • Sign in to reply
  • redcharly
    redcharly over 2 years ago in reply to beacon_dave

    Thank you and DAB for the feedback!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 2 years ago in reply to redcharly

    I'm seeing them here now. Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to DAB

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to beacon_dave

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 2 years ago

    Nice update, but three of your images did not display.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube