Ligne 25 : |
Ligne 25 : |
| |- | | |- |
| | MOSI | | | MOSI |
− | | GP7 (Miso) | + | | GP7 (Mosi) |
| |- | | |- |
| | MISO | | | MISO |
− | | GP4 (Mosi) | + | | GP4 (Miso) |
| |- | | |- |
| | SCK | | | SCK |
Ligne 40 : |
Ligne 40 : |
| |} | | |} |
| | | |
| + | == Download the code == |
| + | The code is available for download on the [https://github.com/mchobby/cansat-belgium-micropython GitHub associated to this wiki]. |
| | | |
| + | {{download-box|Téléchargez Mission1 Base Station Receiver script (basestation.py)|https://github.com/mchobby/cansat-belgium-micropython/blob/main/mission1/basestation.py}} |
| + | |
| + | == About testing == |
| + | |
| + | Once the script {{fname|basestation.py}} renamed as {{fname|main.py}} and uploaded to the board, just restart the board to make it running. |
| + | |
| + | {{ambox|text=It also possible to start the script from REPL with the instruction {{fname|import basestation}} }} |
| + | |
| + | 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. |
| + | |
| + | [[Fichier:ENG-CANSAT-PICO-MISSION1-RECEIVER-20.png]] |
| + | |
| + | {{ambox-stop|text=The tmp36 values are not consistent because the sensor wasn't attached to the board!}} |
| + | |
| + | Where we could see the received messages with additional information. |
| + | |
| + | <nowiki>[DATA](len=<data_len>,RSSI=<radio_rssi>)<transmitted_data> |
| + | [MSG] <transmitted_message></nowiki> |
| + | |
| + | * 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''.<br />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 [https://en.wikipedia.org/wiki/Received_signal_strength_indication 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 {{fname|cat}} command line utility. |
| + | |
| + | Before using {{fname|cat}}, we do need to identifies the computer device attached to the USB-Serial connection. |
| + | |
| + | The {{fname|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) |
| + | |
| + | [[Fichier:ENG-CANSAT-PICO-MISSION1-RECEIVE-20.png]] |
| + | |
| + | Now, we can use the following command line to capture the message on de device. |
| + | |
| + | <nowiki>cat /dev/ttyACM1</nowiki> |
| + | |
| + | and viewing the Base Station messages appearing on the screen. |
| + | |
| + | [[Fichier: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 {{fname|cat /dev/ttyACM1}}) to a file. |
| + | |
| + | Key-in the following command: |
| + | |
| + | <nowiki>cat /dev/ttyACM1 > log.txt</nowiki> |
| + | |
| + | will instantly redirect everything coming from {{fname|/dev/ttyACM1}} to the file {{fname|log.txt}} . |
| + | |
| + | Press CTRL+C to stop 'cat' and the redirection. The file 'log.txt' is now fully available for data treatment. |
| + | |
| + | A [https://github.com/mchobby/cansat-belgium-micropython/blob/main/mission1/cansat2.py log.txt sample] is available from the GitHub repository. |
| | | |
| {{ENG-CANSAT-PICO-TRAILER}} | | {{ENG-CANSAT-PICO-TRAILER}} |