ENG-CANSAT-PICO-MISSION1-CAPTURE
Introduction
Before starting this point, we recommend to follow all the sensors testing steps (BMP280 sensor, TMP36 Sensor, RFM69HCW radio, RFM69HCW Testing). It contains all the details about the wiring, install needed libraries and conduct basic testing. |
The following Wiring is used to capture
- Air temperature
- Air pressure
and transmitting the information via the RFM69HCW radio module.
Wiring on a Pico
Wire the barometric sensor
The BMP280 is wired on the I2C bus of the Pico.
Wire the temperature sensor
Then connect the TMP36 sensor as follows:
- The pin 1 (on the left) to a power source (3.3V),
- The pin 3 (the the right) to the ground/GND.
- The pin 2 (middle one) to the ADC0 (GP26) analog input.
Wire the radio module
Finally wire the RFM69HCW radio as follows:
Here is the description of wiring between the Pico and the RFM69 module.
RFM69HCW | PICO |
---|---|
RST |
GP3 |
CS | GP5 (Slave Select) |
MOSI | GP7 (Miso) |
MISO | GP4 (Mosi) |
SCK | GP6 (Clock) |
GND | GND |
VIN | 3V3 |
Wiring on Kit Cansat for Pico
Wire the barometric sensor
The Kit Cansat avec Pico does already fire a StemmaQt/Qwiic connector. Just connect the Qwiic/StemmaQt wires between the board and the sensor. The Qwiic connector is wired to the I2C(0) bus.
The BMP280 is wired to the Pico via the Qwiic connector.
Wire the temperature sensor
Then connect the TMP36 sensor as follows:
- The pin 1 (on the left) to a power source (3.3V),
- The pin 3 (the the right) to the ground/GND.
- The pin 2 (middle one) to the ADC0 (GP26) analog input.
The Pico pad on the board are large enough to quickly solder the TMP36 on the board. The TMP36 can also bee soldered under the board.
Wire the radio module
The RFM69HCW radio module can be soldered above or below the base board (depending on your needs). |
Finally wire the RFM69HCW radio as follows
RFM69HCW | UEXT pin | PICO | Remark |
---|---|---|---|
RST | GP3 | ||
CS | GP5 | keep the same pin as receiver. Otherwise use UEXT 10 (=gp10) | |
MOSI | 7 | GP4 = MISO | |
MISO | 8 | GP7 = MOSI | |
SCK | 9 | GP6 = SCK | |
GND | 2 | PICO GND | |
VIN | 1 | PICO 3.3V |
Download the code
The code is available for download on the GitHub associated to this wiki.
Without any comments, extra lines and print statement (used to debug), the script makes 33 lines long for the full fledged features.
As showned in the following picture, the intermediate script testing runs for about 80.000 iterations and message sending without an issue.
About testing
Now, we will move forward in several steps.
- Getting data from sensors + send them it over the REPL/Shell connection (to confirm good working) + transmit over radio
- Testing the radio reception
- Going autonomous + add the Lipo
The code proposed here under has been tested up to 80000 iterations without issue, time when we decided to ends the test :-) .
Once the script uploaded to your Pico, open the REPL/Shell over the USB-serial (with Thonny, Putty, MPRemote). The script can be started from REPL with import cansat .
You should see the following messages appears on the Serial Monitor.
Where we could see the transmitted messages with the iteration counter, timing and data.
The ACKnowledgement feature is disabled to avoids unnecessary latency when waiting back for ACK response (which may never comes back in the case of a CanSat in high altitude). |
Structuring the data
The radio module only sends buffer of binary data to the receiver. This is a bit rough but efficient.
So to transport the data to the receiver, we need to transform the values (float, integer) into their string representation.
When having multiple data in their string representation is not enough, they must also been organized.
The final format must be easy to parse and very compact (smaller is the radio message and higher is the chance for him to get to the ground without error).
We propose the following format:
:data1|data2|data3|data4;/r/n
where:
- : is the begin of data stream
- ; is the end of data stream
- /r/n are optional carriage return + line feed characters.
This will would make the messages user friendly when the the messages are viewed in a console or terminal. - | is the separator between data items.
- datax are the string representation of the various data. The characters ;:| are forbidden in this area.
we would also recommend to use:
- packetnum as data1. packetnum is a simple variable increment of one unit after each transmission. This would allow the receiver to detect lost message (since it would exist holes in the numbering of received messages).
- timing_info as data2. This would help to create timing chart or time base data analysis. We suggest to use the Arduino's millis() function which count the number of milliseconds since the last microcontroler reset.
As explained later in the code the packet_str variable contains the message to be transmitted to the ground. The Arduino's String class would ease the transformation of data to their string representation.
String packet_str = String( ":"+String(packetnum,DEC)+"|" );
packet_str.concat( String( ms,DEC)+"|" );
packet_str.concat( String( temperature, 2 )+"|" );
packet_str.concat( String( bme_hpa, 2 )+"|" );
packet_str.concat( String( bme_temp, 2 )+";\r\n" );
Written by Meurisse D. for MCHobby