_SKU_SEN0175_UV_Sensor_V1.0 ML8511紫外线传感器 - jimaobian/DFRobotWikiCn GitHub Wiki
该模块采用了通用的ML8511 UV传感器原件,可以用来检测室内或室外的紫外线密度。通过将光电流转化成电压的原理来检测UV强度,同时非常适合被被外部电路所采用。该模块还具备省电模式可达0.1uA,适合在智能可穿戴和手机等设备上使用。
- 紫外线等级监视器
- 环境监测仪、气象站
- DIY紫外线互动装置
- 工作电压:3.3V - 5V
- 通信接口:Gravity Analog(PH2.0-3P,模拟电压输出1V ~ 2.8VDC)
- 敏感波长:UV-A(320-400nm),UV-B(280-320nm)
- 工作温度:-20~70°C
- 模块尺寸:30 x 22mm
| | | | -------------------------------------------------------- | | | : | |
颜色 | 名称 | 功能描述 |
蓝色 | A0 | 模拟信号输入引脚 |
黑色 | GND | 电源负 |
红色 | VCC | DC 5V |
紫外线传感器管脚定义
从图表上可以看到紫外线输出电压映射到等级是一条直线,从1.0V开始,最大是2.8V(15mW/cm2)。Arduino虽然有一个内置的函数map() function,但是map()是不能工作在浮点型的。这里要感谢Arduino社区开源奉献者才有了下面的一个简单的mapfloat()函数,方便我们使用。
//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
下面是将传感器读到的电压值转换成mW/cm2等级:
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0); //Convert the voltage to a UV intensity level
/***************************************************
* UV Sensor v1.0-ML8511
* <....>
***************************************************
* This example reads UV intensity from UV Sensor v1.0-ML8511.
*
* Created 2014-9-23
* By Phoebe <[email protected]>
* Modified 2014-9-23
* By Phoebe [email protected]>
*
* GNU Lesser General Public License.
* See <http://www.gnu.org/licenses/> for details.
* All above must be included in any redistribution
****************************************************/
/***********Notice and Trouble shooting***************
* 1.Connect ML8511 UV Sensor to Arduino A0
<http://wiki.dfrobot.com.cn/index.php/%E6%96%87%E4%BB%B6:SEN0175_Diagram.png>
* 2.This code is tested on Arduino Uno, Leonardo, Mega boards.
****************************************************/
int ReadUVintensityPin = A0; //Output from the sensor
void setup()
{
pinMode(ReadUVintensityPin, INPUT);
Serial.begin(9600); //open serial port, set the baud rate to 9600 bps
Serial.println("Starting up...");
}
void loop()
{
int uvLevel = averageAnalogRead(ReadUVintensityPin);
float outputVoltage = 5.0 * uvLevel/1024;
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);
Serial.print("UVAnalogOutput: ");
Serial.print(uvLevel);
Serial.print(" OutputVoltage: ");
Serial.print(outputVoltage);
Serial.print(" UV Intensity: ");
Serial.print(uvIntensity);
Serial.print(" mW/cm^2");
Serial.println();
delay(100);
}
//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
byte numberOfReadings = 8;
unsigned int runningValue = 0;
for(int x = 0 ; x < numberOfReadings ; x++)
runningValue += analogRead(pinToRead);
runningValue /= numberOfReadings;
return(runningValue);
}
//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
你可以用一个紫外LED灯或者在阳光下测试你的传感器,赶紧来测试看看你的周围的紫外线等级吧~
购买 UV Sensor V1.0-ML8511紫外线传感器
category: Product_Manual category: SEN_Series category: Sensors category:source category:Diagram