Arduino Forum

Using Arduino => Sensors => Topic started by: suddendebt on Jan 23, 2021, 05:50 pm

Title: Taiss NJK-5002C Hall Sensor Interfacing
Post by: suddendebt on Jan 23, 2021, 05:50 pm
Hi all.

Starting a few weeks ago I felt spry and decided that I, having minimal experience with Arduinos, wanted to design and fabricate a completely automated can crusher controled by an Elegoo Arduino Uno. To my surprise, it has been fairly smooth sailing! Resources such as this forum and Tinkercad have got me much further, much faster than I thought I would have. Now the project is nearly complete save one aspect: automated triggering.

I purchased a 4.5-30VDC Taiss NJK-5002C NPN NO Hall Sensor to trigger the crushing sequence when a can is present. For the life of me I cannot seem to get this sensor to cooperate. I have set up a very bare bones circuit in an attempt to even get a response out of the sensor and so far nothing. Below is my code and attached is my circuit and sensor info:

Code: [Select]
#define sensorPin 2 // Defining the sensor trigger


const int wait = 1000; // Wait 1 second after activation

void setup() {
pinMode(sensorPin, INPUT_PULLUP); // Defining sensor input
pinMode(13, OUTPUT); //Built in LED as Output
Serial.begin(9600); // Initialize serial monitor

}

void loop() {
int sensed = digitalRead(sensorPin); //Read pin 2 and creat 'on/off' binary
if(sensed == HIGH){
  Serial.println("Sensed");
  digitalWrite(13, HIGH); // Turn on LED if sensed
  delay(wait); //Keep on for the value defined above
}else{
  digitalWrite(13, LOW); // LED off if not sensed
  Serial.println("=====");
}
delay(300); // Delay for reads
}


I have seen setups on YouTube nearly identical to this function, but am at a loss. I have a few PC817 optocouplers on the way to try the sensor with 12 volt and a relay.

Any help would be greatly appreciated. Thanks!

(https://forum.arduino.cc/index.php?action=dlattach;topic=724350.0;attach=400347)

(https://forum.arduino.cc/index.php?action=dlattach;topic=724350.0;attach=400349)
Title: Re: Taiss NJK-5002C Hall Sensor Interfacing
Post by: gilshultz on Jan 23, 2021, 06:30 pm
A few things to try. First I read that The sensor will only detect one pole of the magnet the NORTH pole. I always use pull up resistors when there are wires on the pins. Try something in the 2K range to +5. Before adding the resistor you might Connect your voltmeter to the input pin and verify it is switching, less then 1V and greater than 4V, that gives you a good signal.   
Title: Re: Taiss NJK-5002C Hall Sensor Interfacing
Post by: suddendebt on Jan 23, 2021, 06:41 pm
Thanks for the input! I will get back to tinkering with it after work.

Question... you mention the sensor will only pick up the north pole of a magnet... does this mean the sensor is not suitable for picking up something such as an aluminum can? I am the furthest thing from literate in terms of magnetic fields.
Title: Re: Taiss NJK-5002C Hall Sensor Interfacing
Post by: suddendebt on Jan 24, 2021, 03:08 am
Still no dice. Sensor is not switching. Added a 2k resistor on the hot lead and no difference. Grounding the signal wire does trigger the desired effect though. 
Title: Re: Taiss NJK-5002C Hall Sensor Interfacing
Post by: suddendebt on Jan 24, 2021, 03:34 am
Well, my problem is solved. Turns out the I simply misunderstood the difference between Hall Effect sensors and inductive proximity sensors, and what I am after is an inductive proximity sensor and NOT a Hall Effect sensor.