Devices & Components
SparkFun FTDI Basic Breakout - 5V
18650 Lithium cell
HC-05 Bluetooth Module
Arduino Pro Mini 328 - 5V/16MHz
TP4056 Lithium battery module
3V to 5V DC-DC Boost Converter with USB output
Headers (male and female)
Hall Effect Sensor
SparkFun Snappable Protoboard
Hardware & Tools
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
Code snippet #1
arduino
1/*Arduino Code for measuring speed of the Vechile using Hall Sensor 2 3 * Coded by Circuitdigest.com 4 * On 14-04-2017 5 */ 6 /*CONNECTION DETIALS 7 8 * Arduino D11 -> RX of BT Module 9 * Arduino D12 -> Tx of BT 10 * Arduino 11 D2 -> Hall sensor 3rd pin 12 */ 13#include <SoftwareSerial.h>// import the 14 serial library 15SoftwareSerial Cycle_BT(11, 12); // RX, TX 16 int ledpin=13; 17 // led on D13 will show blink on / off 18 int BluetoothData; // the data given 19 from Computer 20float radius_of_wheel = 0.33; //Measure the radius of your wheel 21 and enter it here 22 volatile byte rotation; // variale for interrupt fun must 23 be volatile 24 float timetaken,rpm,dtime; 25 int v; 26 unsigned long pevtime; 27void 28 setup() 29 { 30 Cycle_BT.begin(9600); //start the Bluetooth communication 31 at 9600 baudrate 32 //pinMode(ledpin,OUTPUT); //LED pin aoutput for debugging 33 34 attachInterrupt(0, magnet_detect, RISING); //secound pin of arduino used as 35 interrupt and magnet_detect will be called for each interrupt 36 rotation = 37 rpm = pevtime = 0; //Initialize all variable to zero 38 } 39 40 void loop() 41 42 { 43 /*To drop to zero if vehicle stopped*/ 44 if(millis()-dtime>1500) //no 45 magnet found for 1500ms 46 { 47 rpm= v = 0; // make rpm and velocity as zero 48 49 Cycle_BT.write(v); 50 dtime=millis(); 51 } 52 v = radius_of_wheel * rpm 53 * 0.37699; //0.33 is the radius of the wheel in meter 54 } 55 56 void magnet_detect() 57 //Called whenever a magnet is detected 58 { 59 rotation++; 60 dtime=millis(); 61 62 if(rotation>=2) 63 { 64 timetaken = millis()-pevtime; //time in millisec 65 for two rotations 66 rpm=(1000/timetaken)*60; //formulae to calculate rpm 67 68 pevtime = millis(); 69 rotation=0; 70 Cycle_BT.write(v); 71 //Cycle_BT.println("Magnet 72 detected...."); //enable while testing the hardware 73 } 74 }
Code snippet #1
arduino
1/*Arduino Code for measuring speed of the Vechile using Hall Sensor 2 * Coded by Circuitdigest.com 3 * On 14-04-2017 4 */ 5 /*CONNECTION DETIALS 6 * Arduino D11 -> RX of BT Module 7 * Arduino D12 -> Tx of BT 8 * Arduino D2 -> Hall sensor 3rd pin 9 */ 10#include <SoftwareSerial.h>// import the serial library 11SoftwareSerial Cycle_BT(11, 12); // RX, TX 12 int ledpin=13; // led on D13 will show blink on / off 13 int BluetoothData; // the data given from Computer 14float radius_of_wheel = 0.33; //Measure the radius of your wheel and enter it here 15 volatile byte rotation; // variale for interrupt fun must be volatile 16 float timetaken,rpm,dtime; 17 int v; 18 unsigned long pevtime; 19void setup() 20 { 21 Cycle_BT.begin(9600); //start the Bluetooth communication at 9600 baudrate 22 //pinMode(ledpin,OUTPUT); //LED pin aoutput for debugging 23 attachInterrupt(0, magnet_detect, RISING); //secound pin of arduino used as interrupt and magnet_detect will be called for each interrupt 24 rotation = rpm = pevtime = 0; //Initialize all variable to zero 25 } 26 27 void loop() 28 { 29 /*To drop to zero if vehicle stopped*/ 30 if(millis()-dtime>1500) //no magnet found for 1500ms 31 { 32 rpm= v = 0; // make rpm and velocity as zero 33 Cycle_BT.write(v); 34 dtime=millis(); 35 } 36 v = radius_of_wheel * rpm * 0.37699; //0.33 is the radius of the wheel in meter 37 } 38 39 void magnet_detect() //Called whenever a magnet is detected 40 { 41 rotation++; 42 dtime=millis(); 43 if(rotation>=2) 44 { 45 timetaken = millis()-pevtime; //time in millisec for two rotations 46 rpm=(1000/timetaken)*60; //formulae to calculate rpm 47 pevtime = millis(); 48 rotation=0; 49 Cycle_BT.write(v); 50 //Cycle_BT.println("Magnet detected...."); //enable while testing the hardware 51 } 52 }
Downloadable files
Schematic 1
Schematic 1

Comments
Only logged in users can leave comments