Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO with GPS and NRF24L01 for Ambulance Detection and Traffic Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO with GPS and NRF24L01 for Ambulance Detection and Traffic Control

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

GPS NEO-6M V2

NRF24L01

Wiring Details

Arduino UNO

GPS NEO-6M V2

NRF24L01

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.