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.
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
This project involves three distinct modules:
Each module is equipped with an SD card reader, allowing data storage at every stage.
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 offers flexibility, simplicity, and a vast community of support. For this project, we’ll use:
Here’s a list of components for this project:
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.
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.
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.
The payload module logs flight data and transfers it to the receiver part when required.
This fixed module sends data to the payload, which it had saved on the it.
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
The receiver module displays the final data and saves it for analysis.
#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() {
}
#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);
}
#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();
}
Solution: Ensure the NRF24L01 modules are equipped with external antennas for extended range.
Solution: Always close files after writing to prevent data loss.
Solution: Use a lightweight payload to maintain stable flight.
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!
Yes, modules like HC-12 or LoRa are alternatives, but NRF24L01 is cost-effective and efficient for short distances.
You can use a lightweight Li-Po battery to ensure the drone’s flight stability.
You can log sensor readings such as temperature, humidity, pressure, or even GPS coordinates.
Use a module with an external antenna or ensure a clear line of sight between modules.
Absolutely! It can function as a ground-based data transfer and logging system for various applications.
Introduction Effective Time Management Strategies in today’s fast-paced world, managing time efficiently is more crucial…
Introduction Have you ever caught yourself in the relentless cycle of self-criticism? Maybe you’re constantly…
Introduction Ever feel like your mornings are a chaotic rush, setting the tone for an…
Introduction Have you ever felt the warmth of belonging to a community? It’s a feeling…
Introduction Have you ever felt unheard in a conversation, like your words were floating in…
Introduction Imagine walking through a serene forest, the sunlight filtering through the trees, the soft…
This website uses cookies.