After much research I decided to deploy the Melexis MLX90371 Rotary Hall Sensor in my designs for the Heritage Flight Simulation Spitfire Mk.IX
The whole idea with this was that they would be easy to use as they give an analog signal right off the bat and they have a through the hole design, so easy to solder.
Well I received 12 of the little suckers off Digi-key the other day and set about to test them. I simply used an Arduino Mega and set the sensor up on a breadboard, connected as per the datasheet. I used the standard ReadAnalogVoltage sketch. It should be pretty simple, there is a 5V input lead, an analog out lead and 2 ground leads, one of which remains floating (not connected). So you should simply be able to use them as a drop-in for a potentiometer right?
Seemingly not. Despite my best efforts with different sizes and strengths of magnets it only gives a constant 2.48V output. I contacted Melexis who referred me to Digi-Key who said it should work. It doesn't...
Anybody else here played with these yet?
Here is the example sketch:
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}