ENG-CANSAT-PICO-MISSION1-RECEIVE

De MCHobby - Wiki
Révision datée du 26 novembre 2022 à 14:23 par Admin (discussion | contributions) (→‎Wiring)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche

Introduction

The following wiring will prepare the Receiver "Base Station" for the mission 1. From the "RFM69HCW Testing" section, we will use a Raspberry-Pico wired to a RFM69HCW module in order to capture the Radio Messages and redirect them the USB-Serial connection.

As such, we will be able to receive (and even store) the data sent by the CanSat emitter.

Wiring

Here how to wire the RFM69 module to the Raspberry-Pi Pico.

ENG-CANSAT-PICO-RFM69HCW-to-Pico.jpg

Here is the description of wiring between the Pico and the RFM69 module.

RFM69HCW PICO
RST
GP3
CS GP5 (Slave Select)
MOSI GP7 (Mosi)
MISO GP4 (Miso)
SCK GP6 (Clock)
GND GND
VIN 3V3

Download the code

The code is available for download on the GitHub associated to this wiki.

Download-icon.pngTéléchargez Mission1 Base Station Receiver script (basestation.py)

About testing

Once the script basestation.py renamed as main.py and uploaded to the board, just restart the board to make it running.

The data can be view onto the REPL/Shell session by using Thonny, Putty, MPRemote, cat (under Linux).

You should see the following messages appearing in the REPL.

Notes:

  • onboard LED flashing when a data packet is received.
  • a point '.' is displayed in the output when receiver get a timeout.

ENG-CANSAT-PICO-MISSION1-RECEIVER-20.png

Where we could see the received messages with additional information.

[DATA](len=<data_len>,RSSI=<radio_rssi>)<transmitted_data>
[MSG] <transmitted_message>
  • Each data received and send over the serial connection are prefixed with [DATA] .
  • The prefix is followed by information enclosed between parenthesis (), this concerns the received data.
    Entries are key=value pairs separated by coma.
  • At the end, we retrieve the transmitted data (under their binary content).
  • The binary data are decoded to utf8 strings and prefixed with [MSG] in the output.

In the informations:

  • data_len: length of the binary data stream received.
  • RSSI: indicated the strength of the signal (-15 at best, -90 at worst).
  • transmitted_data: the data as transmitted by the emitter under the binary format.
  • transmitted_message: the binary data decoded back to a string. As designed in the emitter, it starts with : and ends with ;

In the transmitted_data, we can identify:

  • The packet counter
  • The time counter (seconds)
  • The atmospheric pressure (from bmp280)
  • The temperature (from tmp36, analog)
  • The temperature2 (from bmp280)

Extra

Use 'cat' utility

If by any changes you do have a Linux computer, a Raspberry-Pi or an Apple computer then you can easily capture the serial data with the cat command line utility.

Before using cat, we do need to identifies the computer device attached to the USB-Serial connection.

The dmesg command line tools inspecting kernel messages can greatly helps to identify the device name.

In the following capture, it is possible to identify the newly plugged USB device as ttyACM1 (so /dev/ttyACM1)

ENG-CANSAT-PICO-MISSION1-RECEIVE-20.png

Now, we can use the following command line to capture the message on de device.

cat /dev/ttyACM1

and viewing the Base Station messages appearing on the screen.

ENG-CANSAT-PICO-MISSION1-RECEIVE-21.png

Logging data to file

Linux operating system (and alike) allows the user to easily and quickly redirect output (like output of cat /dev/ttyACM1) to a file.

Key-in the following command:

cat /dev/ttyACM1 > log.txt

will instantly redirect everything coming from /dev/ttyACM1 to the file log.txt .

Press CTRL+C to stop 'cat' and the redirection. The file 'log.txt' is now fully available for data treatment.

A log.txt sample is available from the GitHub repository.


Written by Meurisse D. for MCHobby


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.