Arduino Nano Sense R2 Rocket Datalogger With LoRa Communication and GPS for Recovery
by wierzbickimc in Circuits > Arduino
38 Views, 0 Favorites, 0 Comments
Arduino Nano Sense R2 Rocket Datalogger With LoRa Communication and GPS for Recovery
This project hasn't been packaged for flight yet, but that is the next step. I'll update this instructable as the project progresses.
I've wanted to build a model rocket datalogger for a while, and had gone down the GY-86 + Nano route but was never happy with the pressure drift of the MS5611 pressure sensor and for some reason couldn't get TKJElectronics/KalmanFilter to handle going over 180* for both x and y axis (only one or the other). Additionally, Arduino offers a module with all of these built in to make packaging hopefully little bit easier, and is 3.3V logic, making connection to GT-U7 and LoRa modules straight forward.
In this project I built an Arduino Nano 33 Sense R2 with a GPS module and an Adafruit RFM95W LoRa module. The Nano 33 Sense R2 uses its LSM9DS1 IMU accelerometer, gyroscope and manometer to determine pitch, roll, and yaw by way of Kalman filters. It uses the built in LPS22HB pressure sensor to determine air pressure at startup and calculate elevation relative to start by changes in air pressure. To reduce noise but still have a rapid response, the signal is passed through a 1euro filter.
To avoid losing the rocket, I added a GT-U7 GPS module communications through pins D0 and D1.
The Nano takes all of these calculated parameters and beams it through an Adafruit RFM95W LoRa module back to a base station.
The base station is an Arduino Nano 33 BLE unit, also connected to a GT-U7 GPS module and an Adafruit RGM95W LoRa module. The base station receives all of the information from the flight logger and does a few things:
- Serial prints in a CSV format so that you can use a program like CoolTerm to record the flight data and export it for analysis later. Optionally, there is a #if section where you change the 0 to 1, and it will serial print in a format that is easier to visualize but would be tough for trend analysis later.
- It takes the flight logger GPS coordinates, the base station coordinates, and calculates how far the base station is from the flight logger and in which direction. It then estimates how many steps you need to take, and in which direction to retrieve the rocket.
- The base station arduino also transmits the GPS information over BLE for phone integration.
Finally, there is an iOS app that takes the GPS location of the flight logger, the base station, and calculated steps, displays on a map along with the iPhone location to help visualize where to go. Admittedly, the app was written with Claude AI Sonnet 4.6 extended and debugged with Xcode GPT 5.0 integration.
Supplies
Arduino Nano 33 Sense Rev 2 (rev 1 has different modules and would require different libraries).
Arduino Nano 33 BLE
2x GT-U7 GPS modules
2x Adafruit RFM95W
1x 3.7v LIPO battery
Flight Logger
The flight logger uses the built-in IMU for roll, pitch, and yaw calculations by way of kalman filter. The altitude by was of pressure though a 1euro filter.
GPS by way of GT-U7 module and communicating through the nano33 TX/RX points at D0 and D1.
For LoRa communication I choose the RFM95W because it is compatible with both 5v and 3.3v logic (SX12xx tend to be 3.3v only and I wasn't sure which way I was going to go with this project) and it is the more powerful option from Adafruit. LoRa modules have a setting called Spreading Factor which for practical purposes can be interpreted as range. The larger the SF, the further it communicated. However, it is inversely proportional to communication rate. I wanted information sent twice per second for good resolution during ascent, which left me with a SF of 9. In a future state, I could envision a conditional where once the flight logger "lands" it will switch to SF 12 to improve range when line-of-sight is less likely. Fortunately, you will still get GPS coordinates right up to the point of signal loss, so you'll have a relatively small search area. The TX gain is set at 20dBm, rather than the default 13dBm, to help improve range. The power requirements (mA) for the LoRa module likely exceed what the nano can consistently support, so you will likely need to power it directly from the battery, rather than by the arduino. (this is still to be tested, I'm still powering off of USB and have not had issues). The range is expected to be on the order of kilometers, I will be doing some testing in the near future. Don't forget to solder on an antenna, hot glue the base so that it doesn't break off (as easily).
Note - the Radiohead library seems to be the most popular LoRa library, but the nano33 does not support a command that is built into the library and I have no clue how to fix that. Instead I'm using the Sandeepmistry "LoRa" library. It does everything this project needs.
Note - the code below was pieced together from a ton of other projects. After completion I fed it through Claude for commenting and creating documentation for all of the decisions made and a troubleshooting guide. It feels a bit weird to hand this work off to AI but its the part I least enjoy so why not.
Downloads
Base Station
The base station serves the purpose of LoRa signal receiver and takes that information to do something useful things.
I choose a Arduino Nano33 BLE because I already had it, and the Nano33 series run on 3.3v which make integration of modules that much easier.
I used the same GT-U7 GPS module as above and the same Adafruit RFM95W LoRa module. The LoRa module settings (SF, etc.) must match the flight logger otherwise there would be communication errors.
The sketch takes the flight logger GPS coordinate and base station GPS coordinates, calculates the distance and direction and serial prints them to help the user retrieve the rocket.
Note - Haversine Distance calculations assume the earth is round, my apologies flat earthers.
The base station sketch has two serial output options. The default serial prints in something that could be exported as a CSV and used for data processing later. You can do this using CoolTerm rather than Arduino IDE, as CoolTerm can save what the basestation transmits over serial. The other option is to display the information in a way that is easier for people to read, but would be a struggle for trending later. I could see a scenario where you record the launch in the CSV format, and once things have finished changing the #if in section ---USB Serial Full Telemetry Print--- from 1 to 0, reuploading the sketch and switching to the easier to read version.
Note - if you use CoolTerm you will need to change the text encoding otherwise some characters come through weird. Options -> Data Handling -> Text Encoding -> change from SystemDefault to UTF8.
Don't forget to turn on File capture! Connection -> File Capture -> Start.
Same as above, the code was written by combining a ton of other peoples stuff and then fed through Claude for commenting and creating documentation. I took things one step further by having Claude write the BLE code as it's not something I have experience with. The attached documentation combines both
Downloads
IOS App
The iOS app was written completely by Claude over something like 7 revisions. The idea was to use the Nano 33 BLE functionality to transmit to an iOS app. The information would contain the flight logger GPS location, base station GPS location, and the iOS device location on a map along with estimated step between each. The current revision does not contain functionality to use the last known flight logger location in case communication is lost, but I'll get around to adding that functionality.
I don't have a paid App Store account, so I can't upload the built app (at least I don't think I can) so you'll have to do it yourself in Xcode.
The documentation above lists the Info.plist that need to be added for location and BLE usage of the iOS device. If you don't add them, it'll crash.
You will also need to assign it to a team in Signing & Capabilities -> automatically manage signing and Team. If you've made stuff in Xcode before, this will be nothing new for you.
Below are the three sections of code you'll need. Just open a new project and add the below.