Transmitting Data - g7kse/CanSat GitHub Wiki
Transmitting the data from the CanSat is not as complex as it might seem. Much of the work has already been done with the Adafruit libraries. In the example code we'll be sending the following data to the receiver on the ground
Data | Unit | Note |
---|---|---|
Temperature | Deg C | Primary mission data - taken from the BMP280 |
Pressure | hPa | Primary mission data - taken from the BMP280 |
Mission Time | s | Time from 'Power On' in seconds |
Altitude | m | Inferred from the pressure difference at the time of launch |
Hardware
The Pico needs to interface with 2 devices. The BMP280 (I2C) temperature and pressure sensor (that also can infer altitude from 2 points - we'll go through this below) and the RFM9x LoRa transceiver (SPI) that will send the data. Because we are using both I2C and SPI we need to make use of a few more pins so the Pin allocations are as below. Note the modules I used are both 5v tolerant so you can use the 5V VBus line off the Pico and any of the ground pins. Data pins are:
Board | Pin |
---|---|
BMP280 - SDA | GPIO Pin 14 |
BMP280 - SCL | GPIO Pin 15 |
RFM9x - SCK | GPIO Pin 2 |
RFM9x - MISO | GPIO Pin 3 |
RFM9x - MOSI | GPIO Pin 4 |
RFM9x - CS | GPIO Pin 6 |
RFM9x - RST | GPIO Pin 7 |
Software
The transmit code example is available in the repo and an explanation of the makeup of the code is within the comments.The software reads the BMP280 sensor every second then passes the data to the payload message. The altitude calculation is containing within the library and is based on a relative difference between 2 pressures. So you can either take the sea level pressure on the day of launch (this is sometimes called 'QNH' in aeronautical Q codes) and it will return the height above sea level or an alternative would be to take an accurate measure of pressure at the time of launch and update that line of code to get a height above ground at the launch site.
The data will be sent as a string in the format
CanSat example,mission time,temperature,pressure,altitude