Arduino UNO with GPS and NRF24L01 for Ambulance Detection and Traffic Control
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit integrates an Arduino UNO microcontroller with a GPS NEO-6M V2 module for location tracking and an NRF24L01 module for wireless communication. The purpose of the circuit is to create a sensor-based system capable of detecting and approaching an ambulance, as well as controlling a traffic system. The Arduino UNO serves as the central processing unit, interfacing with the GPS module to receive location data and with the NRF24L01 module to handle wireless communication.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central processing unit for the circuit, interfacing with the GPS module for location data and the NRF24L01 module for wireless communication.
GPS NEO-6M V2
- Description: A GPS module that provides location data.
- Purpose: Supplies the Arduino UNO with real-time location data.
NRF24L01
- Description: A 2.4GHz wireless transceiver module.
- Purpose: Enables wireless communication for transmitting location data and other information.
Wiring Details
Arduino UNO
- 3.3V connected to NRF24L01 VCC (3V) and GPS NEO-6M V2 VCC
- GND connected to NRF24L01 GND and GPS NEO-6M V2 GND
- D13 connected to NRF24L01 SCK
- D12 connected to NRF24L01 MISO
- D11 connected to NRF24L01 MOSI
- D10 connected to GPS NEO-6M V2 TX
- D4 connected to NRF24L01 CSN
- D3 connected to GPS NEO-6M V2 RX
- D2 connected to NRF24L01 CE
GPS NEO-6M V2
- VCC connected to Arduino UNO 3.3V
- GND connected to Arduino UNO GND
- TX connected to Arduino UNO D10
- RX connected to Arduino UNO D3
NRF24L01
- VCC (3V) connected to Arduino UNO 3.3V
- GND connected to Arduino UNO GND
- CE connected to Arduino UNO D2
- CSN connected to Arduino UNO D4
- SCK connected to Arduino UNO D13
- MISO connected to Arduino UNO D12
- MOSI connected to Arduino UNO D11
Documented Code
/*
* This Arduino sketch is for a sensor-based system to detect and approach
* an ambulance and control the traffic system. It uses a GPS module (NEO-6M)
* to get location data and an NRF24L01 module for wireless communication.
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SoftwareSerial.h>
// GPS module pins
#define GPS_RX_PIN 3
#define GPS_TX_PIN 10
// NRF24L01 pins
#define CE_PIN 2
#define CSN_PIN 4
// Create RF24 object
RF24 radio(CE_PIN, CSN_PIN);
// Create SoftwareSerial object for GPS
SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN);
void setup() {
// Initialize serial communication
Serial.begin(9600);
gpsSerial.begin(9600);
// Initialize NRF24L01
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.openWritingPipe(0xF0F0F0F0E1LL);
radio.stopListening();
// Print setup complete message
Serial.println("Setup complete");
}
void loop() {
// Read GPS data
if (gpsSerial.available()) {
String gpsData = gpsSerial.readStringUntil('\n');
Serial.println("GPS Data: " + gpsData);
// Send GPS data via NRF24L01
radio.write(&gpsData, sizeof(gpsData));
}
delay(1000); // Delay for 1 second
}
This code initializes the Arduino UNO for communication with the GPS module and the NRF24L01 module. It sets up serial communication, configures the pins for the GPS and NRF24L01 modules, and enters a loop where it reads GPS data and sends it wirelessly via the NRF24L01.