Arduino Projects

Drone Based Data Logger Using NRF24L01 Arduino

In today’s data-driven world, drones are revolutionizing how we gather and analyze information. Imagine a system where data is logged mid-flight and transferred seamlessly between modules, saving it for later analysis. Sounds complex? Not at all! Using Arduino boards and NRF24L01 wireless modules, you can build your very own drone-based data logger. This innovative project combines wireless communication, SD card storage, and drone technology, offering a hands-on experience in engineering and coding.

The project would take the readings of digital temperature, humidity, atmospheric pressure and Carbon monoxide percentage level from the transmitter side and save it first on an SD card then transfer it wirelessly through the NRF24L transceiver to send it to the payload carried on by drone once it is in a close proximity. This will fly to the region of the receiver and once it is in range and a handshake is established, it will transfer the data to the receiver. Which will in turn save it on an SD card.

Let’s dive into the nitty-gritty of how to build a drone-based data logger that is as functional as it is fascinating.

What is a Drone-Based Data Logger?

A drone-based data logger is a system designed to collect and log data during a drone’s flight. This data is then transmitted wirelessly and saved for future use. Such systems are ideal for applications like environmental monitoring, search and rescue operations, or agricultural analysis.

Read Also: Which is Safer to Use Between Centralized and Decentralized Exchanges

How Does It Work?

This project involves three distinct modules:

  1. Payload Module: Attached to the drone to collect and log data mid-flight.
  2. Transmitter Module: Fixed at a specific location to receive data from the payload.
  3. Receiver Module: Stores the transmitted data and displays it on an LCD screen.

Each module is equipped with an SD card reader, allowing data storage at every stage.

Why Use NRF24L01 and Arduino?

NRF24L01 Wireless Module

This module is a low-power, high-speed wireless transceiver, perfect for transmitting data over short distances. It’s cost-effective and easy to integrate with Arduino.

Read Also: Coping with Breakups: Effective Strategies for Moving On After a Relationship Ends

Arduino Boards

Data Logger Using NRF24L01: Arduino Uno and Arduino Nano

Arduino offers flexibility, simplicity, and a vast community of support. For this project, we’ll use:

  • Arduino Uno: As the receiver.
  • Arduino Nano: One as the payload controller and another as the transmitter.

Components You’ll Need

Here’s a list of components for this project:

  • 1 x Arduino Uno
  • 2 x Arduino Nano
  • 3 x NRF24L01 wireless transceiver modules
  • 3 x SD card modules
  • 1 x LCD display module (20×4)
  • Push buttons (for initiating data transfer)
  • Jumper wires
  • Breadboards
  • A drone to carry the payload module

DHT22 Sensor

The DHT22 sensor was used to measure both the temperature and humidity. The sensor was needed for a taken the temperature of a Silo system too. Using a 10kilo-ohm resistor, we could measure the temperature and the humidity effectively.

MQ7 Gas Sensor Module for Carbon Monoxide

The Carbon Monoxide gas sensor module was used to measure the concentration of the CO2 in the silo settings. The programming allows us to convert the readings measured into concentration in ppm.

Pressure Sensor Module (BMP180)

The pressure sensor module was used to measure the atmospheric pressure of the Silo system when the transmitter was taken or measure the rest of the parameters needed for this project design.

Building the Drone-Based Data Logger

Step 1: Assembling the Payload Module according to the Schematic Diagram

The schematic diagram of the payload module side of the Data Logger Using NRF24L01 with Arduino

The payload module logs flight data and transfers it to the receiver part when required.

Circuit Connections and Explanation:

  • Connect the NRF24L01 module to the Arduino Nano as shown above in the schematic diagram.
  • An optional SD card module to store the collected data can also be connected to this side of the project design. The payload basically serves as a bridge between the transmitter and the receiver.
  • An optional push button to initiate data transfer to the receiver module can be added. We didn’t do this, because we programmed a unique handshake that is verified for data transmission in the Arduino code and once this is in range and the handshake is success, the data transfer is done.

Functionality:

  • The payload collects and saves flight data on the SD card.
  • When within range of the receiver, the button triggers data transfer.

Step 2: Set Up the Transmitter Module using the Circuit Diagram Below

The circuit diagram of the transmitter of the Data Logger Using NRF24L01 using Arduino

This fixed module sends data to the payload, which it had saved on the it.

Circuit Connections and Explanation:

The circuit diagram above shows the connection of the Arduino development board to the other sensor modules to it. We connected the digital humidity and temperature sensor DHT

  • Connect another NRF24L01 module to the second Arduino Nano.
  • Attach an SD card module to store incoming data.

Functionality:

  • Waits for data from the payload.
  • Stores the received data on its SD card.

Step 3: Configure the Receiver Module

The circuit diagram of the receiver of the Data Logger Using NRF24L01 using Arduino

The receiver module displays the final data and saves it for analysis.

Circuit Connections:

  • Connect the NRF24L01 module to the Arduino Uno.
  • Attach an LCD display to show the received data.
  • Connect an SD card module for final storage.

Functionality:

  • Receives data wirelessly from the transmitter through the payload side attached on the the flight drone.
  • Saves the data to its SD card and displays it on the LCD.

Writing the Arduino Code

Payload Module Code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
//show the address
const byte addresses[][6] = {"00002", "00003"};

#define pushButton 3

void setup() {
  Serial.begin(9600);

    //begin the nRF24L transmitter
  radio.begin();
  //put the radio addresses
  radio.openWritingPipe(addresses[1]); // 00003
  radio.openReadingPipe(1, addresses[0]); // 00002
  radio.setPALevel(RF24_PA_MIN); 
}

void loop() {
 
}

Transmitter Module Code

#include <SD.h>
#include <SPI.h>
#include "DHT.h"      //lib for dht11 sensor
#include <Wire.h>             // include Wire library, required for I2C devices
#include <SFE_BMP180.h>  // include Sparkfun sensor library
#include <LiquidCrystal.h>    // include LCD library


SFE_BMP180 pressure;
#define ALTITUDE 1655.0 // Altitude of SparkFun's HQ in Boulder, CO. in meters
 
// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(6, 5, 4, A1, A2, A3);

File myFile;

const int chipSelect = 10; // Pin 10 on Arduino Uno

// #define button 
// #define led A2
#define MQ_7 A0 

#define DHTPIN 9
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// int coSensing;
// float h, t, temperature, airQualitySensing, altitude_;
double pressureMeasured;
char status;
double T,P,p0,a;

char charRead;
char runMode;
byte i=0; //counter
char dataStr[100] = "";
char buffer[7];

const int ledPin = 3;  // the number of the LED pin

// Variables will change:
int ledState = LOW;  // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;  // will store last time LED was updated

// constants won't change:
const long interval = 2000; 

void setup(){
  //begin serial comm.
  Serial.begin(9600);
  //begin the lcd module
  lcd.begin(20, 4);
  pinMode(ledPin, OUTPUT);  
  //begin dht sensor
  dht.begin();
  
    if (SD.begin(chipSelect)){
    Serial.println("SD card is present & ready");
    lcd.setCursor(2,0);
    lcd.print(" CHECKING SD CARD...");
    lcd.setCursor(2, 1);
    lcd.print("SD CARD READY");
    delay(2000);
  } 
  
  if(!SD.begin(chipSelect)){
    Serial.println("SD card initialization failed");
    lcd.setCursor(2,0);
  lcd.print(" CHECKING SD CARD...");
  lcd.setCursor(0, 1);
  lcd.print("SD CARD INITIALIZATN");
  lcd.setCursor(5, 2);
  lcd.print("  FAILED" );
   return;
  }
//clear out old data file
  if (SD.exists("csv.txt")) {
    Serial.println("Removing simple.txt");
    SD.remove("csv.txt");
    Serial.println("Done");
  } 

  //write csv headers to file:
   myFile = SD.open("csv.txt", FILE_WRITE);  
   if (myFile){    // it opened OK
    Serial.println("Writing headers to csv.txt");
    myFile.println("Time,Pressure,Temperature,Altitude");
    myFile.close(); 
    Serial.println("Headers written");
    }
  else 
    Serial.println("Error opening csv.txt");  
  Serial.println("Enter w for write, r for read or s for split csv");  
    
  if (pressure.begin()){
    Serial.println("BMP180 init success");
    lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("P. SENSOR CHECK...");
    lcd.setCursor(2, 1);
    lcd.print("PRESSURE SENSOR");
    lcd.setCursor(6, 2);
    lcd.print(" READY");
    delay(2000);
        }    
        
  else{
    Serial.println("BMP180 init fail\n\n");
    lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("   HELLO TEAM");
    lcd.setCursor(2, 1);
    lcd.print("PRESSURE SENSOR ");
    lcd.setCursor(5, 2);
    lcd.print("INIT FAILED" );     
    while(1); // Pause forever.
  }
 
   
  // Print a message to the LCD.
  lcd.setCursor(2,0);
  lcd.print("   HELLO TEAM");
  lcd.setCursor(2, 1);
  lcd.print("DRONE SILO RADIO");
  delay(3000);
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("BASED PROJECT");
  lcd.setCursor(1, 1);
  lcd.print(" TRANSMITTER SIDE");
  delay(3000);
  lcd.clear();
  Serial.println("exiting setup()");
}


double pressureSensor(){
  status = pressure.startTemperature();
  if (status != 0){
    // Wait for the measurement to complete:
    delay(status);

       status = pressure.getTemperature(T);
    if (status != 0){
      // Print out the measurement:
      Serial.print("temperature: ");
      Serial.print(T,2);
      Serial.print(" deg C, ");
      Serial.print((9.0/5.0)*T+32.0,2);
      Serial.println(" deg F");
      
      status = pressure.startPressure(3);
      if (status != 0){
        // Wait for the measurement to complete:
        delay(status);

        status = pressure.getPressure(P,T);
        if (status != 0){
          // Print out the measurement:
          Serial.print("absolute pressure: ");
          Serial.print(P,2);
          Serial.print(" mb, ");
          Serial.print(P*0.0295333727,2);
          Serial.println(" inHg");

             p0 = pressure.sealevel(P,ALTITUDE); // we're at 1655 meters (Boulder, CO)
            pressureMeasured = p0*0.0295333727;          
          Serial.print("relative (sea-level) pressure: ");
          Serial.print(p0,2);
          Serial.print(" mb, ");
          Serial.print(p0*0.0295333727,2);
          Serial.println(" inHg");
          Serial.println("measure P: " + String(pressureMeasured));
          return pressureMeasured;

          a = pressure.altitude(P,p0);
          Serial.print("computed altitude: ");
          Serial.print(a,0);
          Serial.print(" meters, ");
          Serial.print(a*3.28084,0);
          Serial.println(" feet");

           
        }
        else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
    }
    else Serial.println("error retrieving temperature measurement\n");
  }
  else Serial.println("error starting temperature measurement\n");

  //delay(5000);  // Pause for 5 seconds.
   
}    

// float dhtSensor(){
//     // Reading temperature or humidity takes about 250 milliseconds!
//   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
//    h = dht.readHumidity();
//   // Read temperature as Celsius (the default)
//    t = dht.readTemperature();
//   // Read temperature as Fahrenheit (isFahrenheit = true)
//   float f = dht.readTemperature(true);
  
//   // Check if any reads failed and exit early (to try again).
//   if (isnan(h) || isnan(t) || isnan(f)) {
//     Serial.println(F("Failed to read from DHT sensor!"));
//     return;
//   }

//   // Compute heat index in Fahrenheit (the default)
//   float hif = dht.computeHeatIndex(f, h);
//   // Compute heat index in Celsius (isFahreheit = false)
//   float hic = dht.computeHeatIndex(t, h, false);
// return h, t;
// }


void loop(){    
 dataStr[0] = 0;
 
 int airQualitySensing = analogRead(MQ_7);
 airQualitySensing = map(airQualitySensing, 80.00, 1023.00, 0.00, 100.00);
 airQualitySensing = constrain(airQualitySensing, 0.00, 100.00);

  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);
 
  //pressureSensor();
  
 //----------------------- using c-type ---------------------------
//convert floats to string and assemble c-type char string for writing:
 ltoa(airQualitySensing,buffer,10); //conver long to charStr
 strcat(dataStr, buffer);//add it onto the end
 strcat( dataStr, ", "); //append the delimeter 

 //dtostrf(floatVal, minimum width, precision, character array);
 dtostrf(h, 5, 1, buffer);  //5 is mininum width, 1 is precision; float value is copied onto buff
 strcat( dataStr, buffer); //append the coverted float
 strcat( dataStr, ", "); //append the delimeter

 dtostrf(t, 5, 1, buffer);  //5 is mininum width, 1 is precision; float value is copied onto buff
 strcat( dataStr, buffer); //append the coverted float
 strcat( dataStr, ", "); //append the delimeter

 dtostrf(pressureMeasured, 5, 1, buffer);  //5 is mininum width, 1 is precision; float value is copied onto buff
 strcat( dataStr, buffer); //append the coverted float
 strcat( dataStr, ", "); //append the delimeter 
 
  //String my_data = "AIR QUALITY Percentage: " + String(airQualitySensing) + "%" + " Humidity: " + String(h) + "% Temperature: " + String(t) + "'C Pressure: " + String(pressureMeasured) + "Pa";

  //----- display on local Serial monitor: ------------
  Serial.print("AIR QUALITY: ");
  Serial.print(airQualitySensing);
  Serial.print(" Humidity: ");
  Serial.print(h);
  Serial.print(" Temperature: ");
  Serial.print(t);
  Serial.write(0xC2);  //send degree symbol
  Serial.write(0xB0);  //send degree symbol
  Serial.print("C");
  // 2: print pressure
  Serial.print(" Pressure: ");
  Serial.print(pressureMeasured);
  Serial.println(" hPa");
  // 3: print CO
  Serial.print(" CO Rate");
  Serial.print(airQualitySensing);
  Serial.println("%");
  Serial.println();  // start a new line
   
  // print data on the LCD screen 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Humidity: " + String(h) + "%");
  lcd.setCursor(0, 1);
  lcd.print("Temperature: " + String(t) + "'C");
  lcd.setCursor(0, 2);
  lcd.print("Pressure: " + String(pressureMeasured) + "Pa");    //, altitude_
  lcd.setCursor(0, 3);
  lcd.print("CO Rate: " + String(airQualitySensing) + "%");  
 
   // open the file. note that only one file can be open at a time,
    myFile = SD.open("csv.txt", FILE_WRITE);     
    // if the file opened okay, write to it:
    if (myFile) {
      Serial.println("Writing to csv.txt");
      myFile.println(dataStr); 
      myFile.println(dataStr); 
      myFile.close();
    } 
    
    else {
      Serial.println("error opening csv.txt");
    }
    delay(5000); 
  }

Receiver Module Code

 #include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // nRF24L01 (CE,CSN)
const byte addresses[][6] = {"00001", "00002", "00003"};

String startCommand = "start";
int coSensing;
int airQualitySensing;
float h, t, pressureMeasured, CO_Rate;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_MIN);
  }

void receiveData(){
//  delay(5);
//radio.stopListening();
//radio.write(&startCommand, sizeof(startCommand));

delay(5);
radio.startListening();
if(radio.available()) {
 while (radio.available()) {
 radio.read(&h, sizeof(h));
 Serial.print("Hum: ");
 Serial.print(h);
 radio.read(&t, sizeof(t));
 Serial.print(" Temp: ");
 Serial.print(t);
 radio.read(&pressureMeasured, sizeof(pressureMeasured));
 Serial.print(" Pressure: ");
 Serial.print(pressureMeasured);
 radio.read(&CO_Rate, sizeof(CO_Rate));
 Serial.print(" CO Rate: ");
 Serial.print(CO_Rate);
 
// radio.read(&airQualitySensing, sizeof(airQualitySensing));
// Serial.print(" CO LEVEL ");
// Serial.print(airQualitySensing);
 Serial.println();
 delay(5000);
 
    }
  }
}

void loop() {
receiveData();
}

Testing the System

  1. Payload Module: Attach it to the drone and initiate data logging.
  2. Transmitter Module: Keep it stationary. Ensure it receives data when the payload is in proximity.
  3. Receiver Module: Test for data reception and display functionality.

Applications of Drone-Based Data Loggers

  • Environmental monitoring: Collect data on temperature, humidity, and air quality.
  • Agriculture: Analyze soil and crop health.
  • Search and rescue: Track locations and gather data in inaccessible areas.

Challenges and Solutions

Challenge 1: Weak Signal Strength

Solution: Ensure the NRF24L01 modules are equipped with external antennas for extended range.

Challenge 2: Data Corruption on SD Cards

Solution: Always close files after writing to prevent data loss.

Challenge 3: Drone Stability

Solution: Use a lightweight payload to maintain stable flight.

Future Enhancements

  1. Increase Range: Use long-range NRF24L01 modules.
  2. Add Sensors: Collect additional data like GPS location or barometric pressure.
  3. Real-Time Monitoring: Integrate with a mobile app for live updates.

Conclusion

Building a drone-based data logger using NRF24L01 and Arduino is an exciting project that merges the worlds of electronics, programming, and drone technology. From environmental data collection to creative applications, the possibilities are endless. With detailed planning and coding, you can create a reliable system that captures and transfers data seamlessly.

So, what are you waiting for? Gather your components, and let your imagination take flight!

FAQs

1. Can I use a different wireless module?

Yes, modules like HC-12 or LoRa are alternatives, but NRF24L01 is cost-effective and efficient for short distances.

2. How do I power the payload module?

You can use a lightweight Li-Po battery to ensure the drone’s flight stability.

3. What types of data can I log?

You can log sensor readings such as temperature, humidity, pressure, or even GPS coordinates.

4. How do I increase the range of the NRF24L01 module?

Use a module with an external antenna or ensure a clear line of sight between modules.

5. Can I use this system without a drone?

Absolutely! It can function as a ground-based data transfer and logging system for various applications.

smartechlabs

Recent Posts

Effective Time Management for Busy Lives: Prioritization Techniques and Productivity Hacks

Introduction Effective Time Management Strategies in today’s fast-paced world, managing time efficiently is more crucial…

55 minutes ago

The Power of Self-Compassion: Strategies for Overcoming Self-Criticism and Embracing Self-Love

Introduction Have you ever caught yourself in the relentless cycle of self-criticism? Maybe you’re constantly…

2 hours ago

Mindful Morning Routines: 5 Science-Backed Habits to Boost Productivity

Introduction Ever feel like your mornings are a chaotic rush, setting the tone for an…

2 hours ago

The Power of Community: Building Meaningful Connections for a Happier Life

Introduction Have you ever felt the warmth of belonging to a community? It’s a feeling…

3 hours ago

The Art of Active Listening: Enhancing Communication in Personal and Professional Relationships

Introduction Have you ever felt unheard in a conversation, like your words were floating in…

4 hours ago

The Benefits of Forest Bathing: How Nature Therapy Can Improve Your Well-being

Introduction Imagine walking through a serene forest, the sunlight filtering through the trees, the soft…

23 hours ago

This website uses cookies.