Hall effect magnetic sensor module(HCSENS0021)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

Hall effect magnetic sensor module(HCSENS0021)

Post by admin » Fri Aug 08, 2014 9:15 am

Image

This sensor accepts a GND and +5V supply, and has a single digital output which goes low (GND) when a magnetic field is detected. An on board LED will also indicate the presence of a magnetic field.


Pinout


Image


PIN 1: GND
PIN 2: +5V
PIN 3: OUT

Code: Select all

/* FILE:    ARD_Vibration_Sensor_Module_Example
   DATE:    05/06/13
   VERSION: 0.1

This is a simple example of how to use the Hobby Components hall effect sensor  
module. 

The sensor accepts a GND and +5V supply, and has a single digital output 
which goes low (GND) when a magnetic field is detected. 

This example sketch will simply output a message to the UART when it
senses this pin going low.

SENSOR PINOUT:
PIN 1: GND
PIN 2: +5V
PIN 3: DATA OUT

You may copy, alter and reuse this code in any way you like, but please leave 
reference to HobbyComponents.com in your comments if you redistribute this code. 
This software may not be used directly for the purpose of selling products that 
directly compete with Hobby Components Ltd's own range of products. 

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER 
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, 
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
REASON WHATSOEVER.

*/   
                                  
/* Select the input pin for the hall effect sensors output. */
#define HALL_SENSOR_DIO 2       
                                  


/* Initialise serial and DIO */
void setup()
{
  /* Setup the serial port for displaying the status of the sensor */
  Serial.begin(9600);
  
  /* Configure the DIO pin which the sensors digital output will be connected to */
  pinMode(HALL_SENSOR_DIO, INPUT); 
}


/* Main program loop */
void loop()
{
  /* Read the status of the sensors digital output and if it is low 
     then send an alert to the serial port */
  if (!digitalRead(HALL_SENSOR_DIO))
  {
    Serial.println("MAGNETIC FIELD DETECTED!");
  }  
}

ferrisb
Posts: 1
Joined: Thu Jun 16, 2016 7:03 pm

Re: Hall effect magnetic sensor module(HCSENS0021)

Post by ferrisb » Thu Jun 16, 2016 8:12 pm

Hi, Having trouble with this sensor - the red LED is lit but no change when magnet (strong) is near by. Please can you confirm pin out on the actual device as the pins are not numbered.. :roll: .:

PIN 1: GND -> G
PIN 2: +5V -> R
PIN 3: DATA OUT -> Y

Many thanks.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Hall effect magnetic sensor module(HCSENS0021)

Post by andrew » Fri Jun 17, 2016 8:06 am

Yes that is correct, however I believe the LED should only illuminate when a magnetic field is placed near the sensor. If it is on all the time then something is wrong.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

advocas
Posts: 3
Joined: Sun Aug 27, 2017 5:05 pm

Re: Hall effect magnetic sensor module(HCSENS0021)

Post by advocas » Thu Nov 02, 2017 12:47 am

Hi, I have just receive one of these from you, the LED was on constantly and running the demo sketch it was showing the !MAGNETIC FIELD DETECTED! message when there is no magnet near it.

It seems the connection details are not clear as the pin with the square pad and the S next to it is Pin 3 and not Pin 1 as expected (square pad normally indicates Pin 1), wired this way it works correctly with the LED coming on when a magnet is near the sensor.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Hall effect magnetic sensor module(HCSENS0021)

Post by andrew » Thu Nov 02, 2017 4:43 pm

Thanks for pointing this out. I've added a diagram to the first post which hopefully should clear up any confusion.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Sensors”