//P:实际测试压力值,单位 (Kpa)//Vout: 传感器电压输出值
P = (Vout-0.1)/3.0 x 300.0-100.0
原理图
管脚映射
Unit Tube Pressure
HY2.0-4P
Black
Red
Yellow
White
PORT.B
GND
5V
NC
Analog Input
尺寸图
软件开发
Arduino
#include<Arduino.h>int sensorPin = 32; // 传感器信号引脚voidsetup(){
Serial.begin(115200);
pinMode(sensorPin, INPUT); //Sets the specified pin to input mode. 设置指定引脚为输入模式
}
voidloop(){
float raw = analogRead(sensorPin); // read the value from the sensor. 读取当前传感器的值float Vout = raw/4095 x 3.6;
float P = (Vout-0.1)/3.0 x 300.0-100.0;
Serial.printf("pressure: %f.2 Kparn", P);
delay(100);
}