Hall Sensor (magnetic) for motor frequency

I made a error and deleted the topic, to don't post wrong content.

In no particular order...

That is not the code you are actually using. What you have shown does not compile.

arduino-cli compile -b arduino:avr:uno --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/test)
already nofloat
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:1:1: error: 'magnetValue' does not name a type
 magnetValue = A1;
 ^~~~~~~~~~~
/home/me/Documents/sketchbook/Uno_R3/test/test.ino: In function 'void loop()':
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:12:27: error: 'magnetValue' was not declared in this scope
   SensorWert = analogRead(magnetValue);
                           ^~~~~~~~~~~
Used platform Version Path
arduino:avr   1.8.3   /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3
Error during build: exit status 1
Compilation failed.

The A3144 is an open collector output sensor. Do you have a pullup on the analog input? If not, what do you think the analog input is reading why the sensor is not active?

Furthermore, why are you doing an analog read on a digital sensor?

2 Likes

The magnetic field from that magnet is SO STRONG that it radiates all over the area around the moving part. Replace that magnet with a very weak bar magnet and see if the results improve.

1 Like

Hi van_der_decken,
thank you for your feedback with the digital sensor. I will try to change it at the weekend, today it is too late, after a long working week.

For the topic with the compling: For me it works, see picture here:


It seems that I use a newer version then you are using. You have arduino:avr 1.8.3, i have 1.8.19.

That turns out not to be the case.

You might want to look back at what you posted.

magnetValue = A1;
int SensorWert;

void setup() {
  Serial.begin(9600);
  // put your setup code here, to run once:
  while(!Serial);
}

Notice the absence of an int in front of magnetValue = A1; on the very first line? That does not compile, not in any compiler version.

Then look at your screen shot and see if you can spot the difference.

And you're conflating core versions with IDE versions. That is neither a valid nor useful comparison.

1 Like

Hi van der decken,
you are right, it seems to be a copy error, but relax, I'm new to these kinds of topics, it is only a hobby for me. I'm glad that you gave me the information with the digital sensor.

Hello community,
I made several errors here, I want to write this for you to don't make the same errors...
When you check the video for the Hall Effect, for example here:

You get the information, that a defined supply current is necessary for operation of the sensor. In my case I connect it to my arduino with 5V output, so I need to use 1000 Ohm resistor to get the needed 5mA current.

In the datasheet you find the information at page 4.
chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.elecrow.com/download/A3141-2-3-4-Datasheet.pdf

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.