Interfacing the Mini Reed sensor with Bharat PI board
INTERFACING MINI REED SENSOR USING BHARATHPI
Introduction of BHARATPI:
Introduction of Mini Reed Sensor:
The KY-021 Magnetic Reed Switch module is a switch
that is normally open and gets closed when exposed to a magnetic field, sending
a digital signal. Commonly used in mechanical systems as proximity sensors.
Compatible with Barathpi,Arduino, Raspberry Pi, ESP32
and other microcontrollers.
STEP 1:How Mini Reed Sensor Works?
In a presence of a magnetic
field, the two contacts of a reed switch act as opposite magnetic poles.
Therefore they attract each other and join together. When the magnetic field is
not present, the contacts return back to their initial positions. In that
state, a reed switch is said to be open. It does not conduct electricity during
that phase. However, in the presence of a magnetic field, the reed contacts
join together and electricity flows through.
STEP 2: Mini Reed Sensor
Pinout
·
Vcc - Connect to the 3.3v or 5v
·
Gnd - Connect to the gnd
·
Out – Any GPIO pin (pin 33)
STEP
3: Requirements
·
Mini Reed Sensor
·
Connecting wires
Arduino IDE
STEP
4:Interfacing Mini Reed Sensor with Bharathpi
Step-by-Step Guide:
- Connect Mini Reed Sensor:
- The Mini Reed Sensor typically has three pins: VCC (Power), GND (Ground), and OUT (Output).
- Connect the VCC pin of the Mini Reed Sensor to a 5V output on the Arduino.
- Connect the GND pin of the Mini Reed Sensor to the GND (Ground) on the Arduino.
- Connect the OUT (Output) pin of the Mini Reed Sensor to one of the digital pins on the Arduino .
- Connect Bharat Pi Board:The Bharat Pi board should be connected to the Arduino through the GPIO pins. Make sure to connect the necessary GPIO pins on the Bharat Pi board to the corresponding pins on the Arduino. This may vary depending on the specific board and pins available. Refer to the Bharat Pi board's documentation for pin mapping information.
- You'll need to write Arduino code to read the state of the Mini Reed Sensor and send the information to the Bharat Pi board.
- Upload the Arduino code to your Arduino board using the Arduino IDE.
- Testing:
- After uploading the code, test the setup by placing a magnet near the Mini Reed Sensor. The sensor's state should change (usually from HIGH to LOW) when a magnet is close, and this change should be reflected on the Bharat Pi board.
STEP
5:Source Code and Programming
const int reedPin = 33; // Define the GPIO pin to which
the Reed sensor is connected
void setup() {
pinMode(reedPin, INPUT_PULLUP); // Set the pin as an input with
a pull-up resistor
Serial.begin(115200);
}
void loop() {
int reedState = digitalRead(reedPin); // Read the state of the Reed
sensor
if (reedState == LOW) {
// Reed sensor is triggered (magnet is near)
Serial.println("Reed sensor
triggered!");
} else {
// Reed sensor is not triggered (magnet is away)
Serial.println("Reed sensor not
triggered.");
}
delay(1000); // Add a delay to avoid rapid
readings
}
GitHub link:https://github.com/PuneeethG/Sensor-Interfacing/blob/main/minireed/minireed.ino
STEP
6:Application
Security Systems: Detecting unauthorized entry by monitoring doors and windows.
Industrial
Automation: Monitoring the position of machinery components in manufacturing
and assembly processes.
Home
Automation: Integrating with smart home systems to monitor doors, windows, and
garage doors.
Liquid
Level Sensing: Measuring liquid levels in tanks or containers.
Comments
Post a Comment