108个传感器之-类比霍尔磁力模块(28)

108个传感器之-类比霍尔磁力模块(28)

介绍

BIHOR 磁传感器模块使用AH49E霍尔效应传感器,可以检测磁场。如果没有磁场,传感器输出的电压大约是电源电压的一半。

如果磁铁的南极靠近传感器的标记侧,输出电压就会增加。如果北极接近,电压会降低。这些变化是均匀的,能够精确检测磁方向。

该模块非常适合检测和测量磁场,这在速度传感器、位置传感器或各种控制和监测系统等应用中非常有用。它提供了一种对磁场做出反应的简单方法,并且用途广泛。

引脚连接

pin 引脚连接开发板的 gpio 接口即可:

Arduino Sensor
5 V +V
GND GND
Pin A2 Signal

代码示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int sensorPin = A5; // The input pin is declared here

void setup() {
// Serial output in 9600 baud
Serial.begin(9600);
Serial.println("KY-035 Magnetic field detection");
}

// The program measures the current voltage value at the sensor,
// calculates the current resistance value of the sensor from this and the known series resistance
// resistance value of the sensor and outputs the results to the serial output
void loop() {
// Current voltage value is measured...
int rawValue = analogRead(sensorPin);
float voltage = rawValue * (5.0/1023) * 1000;
float resitance = 10000 * (voltage / (5000.0 - voltage));

// ... and printed here to the serial interface
Serial.print("Voltage value: ");
Serial.print(voltage);
Serial.print(" mV, \t Resistance value: ");
Serial.print(resitance);
Serial.println(" Ohm");
Serial.println("---------------------------------------");

delay(1000);
}

小结

待完善…

108个传感器之-类比霍尔磁力模块(28)

http://blog.jzxer.cn/20241230/20241230-Bihor-magnetic-sensor/

作者

dev

发布于

2024-12-30

更新于

2025-01-12

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×