Interfacing of Tap sensor to Bharat Pi board
INTERFACING TAP SENSOR USING BHARATHPI
Introduction of BHARATPI:
A single board architecture with compute, network and storage designed to build any IoT idea into a product. The board comes with a ESP32 Wroom 4MB memory + WiFi + Bluetooth + SD card slot. You can program the board using Arduino IDE or microPython. All ESP programs are compatible with Bharat Pi boards.
Introduction of Tap Sensor:
A Knock Sensor or a Vibration Sensor or tap module sensor is a simple device that detects vibrations or shocks from knocking or tapping it. It is basically an electronic switch which normally open. When it detects any shock or vibrations, it closes (for that moment and returns back to its default open position.
STEP 1: How Tap Sensor Works?
If the vibrations are sufficient enough for the sensor to detect, the OUT of the sensor becomes low for that moment. This is detected by Arduino and it turns ON the LED for a second.
STEP 2:Tap Sensor Pinout
· Vcc
- Connected to the 3.3v or 5v
· Gnd
- Connected to the gnd of board
· Out
- Any GPIO pin ( pin 34)
STEP 3:Requirements
· Tap Sensor
· Connecting
wires
· Arduino IDE
STEP 4:Interfacing Tap Sensor with Bharathpi
- Connect Tap Sensor to Arduino
- Connect the tap sensor to the Arduino as follows:
- Connect one terminal of the tap sensor to Arduino's 5V (VCC) pin.
- Connect the other terminal of the tap sensor to one of the Arduino's analog input pins
- Connect a 10k ohm resistor from the same analog input pin to ground (GND) to create a voltage divider
- Upload Arduino Code
- Connect Arduino to Bharat Pi
- Connect the Arduino to the Bharat Pi board using USB cables. One cable is for power (usually connected to a USB power source), and the other is for programming and data transfer (connected to a USB port on the Bharat Pi board).
STEP 5:Source Code and Programming:
#include <Arduino.h>
const int sensorPin = 34; // Define the GPIO pin connected to the sensor
bool tapped = false;
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(115200);
}
void loop() {
int sensorValue = digitalRead(sensorPin);
if (sensorValue == HIGH &&
tapped) {
Serial.println("Tap detected!");
// Your code to react to the tap goes here
tapped = true;
}
if (sensorValue == LOW) {
tapped = false;
}
delay(10); // Add a small delay to
debounce the sensor (adjust as needed)
}
GitHub link: https://github.com/PuneeethG/Sensor-Interfacing/blob/main/tapmodule/Tapmodule.ino
STEP 6:Application
Engine Control: To adjust ignition timing and fuel
injection to prevent engine knocking, optimize performance, improve fuel
efficiency, and reduce emissions.
Performance Tuning: In high-performance and racing
contexts, to fine-tune engine performance without causing engine damage.
Comments
Post a Comment