【发布时间】:2020-08-14 03:51:37
【问题描述】:
我在 Arduino 上编写了代码来记录施加到连接到引脚 A0 的 FSR 传感器的压力。这是我的代码
int pressureAnalogPin = 0; //pin where our pressure pad is located.
int pressureReading; //variable for storing our reading
bool active = false; //boolean to check whether arduino should be sending pressure values
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop()
{
if (Serial.available()) //checks if data is coming in
{
char read = Serial.read(); //Set varaiable read to data read from mobile
if (read == 'g') //if read is equal to character 'g' set boolean active to true
{
active = true;
}
if (read == 'x') //if read is equal to character 'x' set boolean active to false
{
active = false;
}
}
if (active == true) //Only send data to phone when boolean active is set to true
{
pressureReading = analogRead(pressureAnalogPin); // Set varaible pressureReading to the pressure value recorded by FSR
Serial.print(pressureReading); //Send pressure value to mobile phone
}
delay(100);// a delay of 100ms in loop
}
我收到从 0 到 1023 的结果。我进行了一项实验,通过增加压力传感器顶部的权重。
上面是一个 Excel 图表,显示了重量的增加和记录的压力。
谁能告诉我这些压力读数的单位是什么?
【问题讨论】:
-
现在你没有压力单位。你只有一个 0 到 1023 之间的无单位量,它代表 0 到 5V 之间的电压。您必须查看传感器的数据表,并了解如何将电压转换为更可用的单位。或者通过测量一些已知的力值并自己计算校准曲线来进行某种校准。
-
将模拟读数转换为电压使用 (analogReading * 5.0 / 1024.0) 假设您有一个 5V 参考。如果您使用的是其他参考电压,请将其替换为 5.0
-
没有人知道,因为只有您拥有该传感器的制造商数据表。你有,对吧?
-
我投票结束这个问题,因为它不是关于编程,而是关于 OP 使用的电子传感器的性能特征。
-
谢谢@Delta_G - 这很有意义!我没有传感器的制造商数据表,这是我购买的传感器coolcomponents.co.uk/products/force-sensitive-resistor-0-5-inch?
标签: arduino sensors units-of-measurement pressure