7. Transmitting data - naubeeluck/OP-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
table
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:
table
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
Lessons learnt and troubleshooting
- Ensure that the pins of the jumper wires are pushed down fully in the breadboard. They are hard to push in but easily fall off.
- Check that the 3V3 or Vsys pin of pico is connected for power out.
- Ensure that thread antenna is vertically up to transmit better.
- Practise soldering so that BMP280 and pico parts are not damaged by the heat. Heat the metal first and then bring the solder in. Avoid short circuits.