scieee AI-readable full text Open interactive document viewer

PocketQube InterSatellite Links using LoRa

Tribó Cabré, Júlia

Abstract

This Final Degree Project aims at developing a telecommunications link using LoRa technology to interconnect a PocketQube (pico-satellites with a form factor of 5 x 5 x 5 cm^3) with a ground station from the TinyGS network. This long-range low-bandwidth link can be used to download the telemetry, the payload or the configuration data, and to send telecommands from the ground station to the PocketQube, such as the execution of orders as activate the payload, do a soft reset, perform an ADCS calibration etc. In this Final Degre Project, the communication protocols will be implemented, using COTS LoRa TTGO T-Display ESP32 WiFi module (Arduino based), and a PocketQube developed at the UPC NanoSat Lab, which uses an STM 32 (to be programmed in C-language) as On-Board Computer.

Full text

FINAL DEGREE PROJECT TFG TITLE: Design and Performance Analysis of a LoRa communication system for PocketQubes DEGREE: Double Bachelor’s Degree in Aerospace Systems Engineering and Telematics Engineering AUTHOR: J ´ulia Trib´ o Cabr´ e ADVISORS: Hyuk Park Adriano Jos´ e Camps Carmona SUPERVISOR: S ,tefan Podaru Guillem Gr` acia i Sol` a DATE: 20 de juny de 2023 T´ıtol: Disseny i An` alisi de Rendiment d’un sistema de comunicaci´ o LoRa per a PocketQubes. Autor: J´ ulia Trib´ o Cabr´ e Directors: Hyuk Park Adriano Jos´ e Camps Carmona Supervisor: S ,tefan Podaru Guillem Gr` acia i Sol` a Data: 20 de juny de 2023 Resum Aquest Projecte Final de Grau t´ e com a objectiu desenvolupar un enllac¸ de telecomunicacions utilitzant la tecnologia LoRa per interconnectar un PocketQube (pico-sat` el·lits amb una mida de 5 x 5 x 5 cm3) amb una estaci´ o terrestre de la xarxa TinyGS. Aquest enllac¸ de llarg abast i baix ample de banda es pot usar per descarregar la telemetria, les dades de c` arrega ´ util o de configuraci´ o, i per enviar telecomandes, p.ex. sol·licitar des de l’estaci´ o terrestre al PocketQube l’execuci´ o d’ordres com activar la c` arrega ´ util, fer un soft reset, la calibraci´ o de l’ADCS, entre d’altres. En aquest Projecte Final de Grau, s’implementaran els protocols de comunicaci´ o usant el m` odul COTS WiFi LoRa TTGO T-Display ESP32 (basat en Arduino), juntament amb un PocketQube desenvolupat al NanoSat Lab de la UPC, que utilitza un STM32 (a programar en llenguatge C) com a OBC. Title : Design and Performance Analysis of a LoRa communication system for PocketQubes Author: J´ ulia Trib´ o Cabr´ e Advisors: Hyuk Park Adriano Jos´ e Camps Carmona Supervisor: S ,tefan Podaru Guillem Gr` acia i Sol` a Date: June 20, 2023 Overview This Final Degree Project aims at developing a telecommunications link using LoRa technology to interconnect a PocketQube (pico-satellites with a form factor of 5 x 5 x 5 cm3) with a ground station from the TinyGS network. This long-range low-bandwidth link can be used to download the telemetry, the payload or the configuration data, and to send telecommands from the ground station to the PocketQube, such as the execution of orders as activate the payload, do a soft reset, perform an ADCS calibration etc. In this Final Degre Project, the communication protocols will be implemented, using COTS LoRa TTGO T-Display ESP32 WiFi module (Arduino based), and a PocketQube developed at the UPC NanoSat Lab, which uses an STM 32 (to be programmed in C-language) as On-Board Computer. CONTENTS Acknowledgements ............................... 1 List of abbreviations .............................. 3 Introduction .................................... 5 CHAPTER 1. PocketQubes . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.1. Advantages ................................... 7 1.2. Orbits ...................................... 7 1.3. Launch ...................................... 9 1.4. Swarms ..................................... 9 1.5. Conclusions ................................... 9 CHAPTER 2. Mission .............................. 11 2.1. PoCAT Project .................................. 11 2.2. PocketQube architecture ............................ 11 2.3. Launch ...................................... 12 2.4. Antenna ..................................... 13 2.4.1. Antenna design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4.2. Antenna deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.5. Conclusions ................................... 14 CHAPTER 3. State Of The Art . . . . . . . . . . . . . . . . . . . . . . . . 15 3.1. Communication Technologies for Picosatellites ............... 15 3.1.1. SigFox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.1.2. Narrowband IoT (NB-IoT) . . . . . . . . . . . . . . . . . . . . . . . 15 3.1.3. LoRa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.1.4. Tested Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.2. Challenges of PocketQube communications ................. 18 3.3. Conclusions ................................... 18 CHAPTER 4. PocketQube Communication System . . . . . . . . . . 19 4.1. Technology Selection .............................. 19 4.2. Communication parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.2.1. Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.2.2. LoRa parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.3. Ground Stations ................................ 22 4.3.1. Montsec Ground Station . . . . . . . . . . . . . . . . . . . . . . . . 22 4.3.2. TinyGS ground station . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.4. Link budget ................................... 27 4.4.1. Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.4.2. Losses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.4.3. Noise Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.4.4. Final link budget . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.5. Orbits ...................................... 32 4.6. Data budget ................................... 33 4.7. Conclusions ................................... 37 CHAPTER 5. Error Correction Codes ................... 39 5.1. Reed-Solomon ................................. 39 5.2. Convolutional codes .............................. 40 5.3. Interleaving ................................... 41 5.4. Final encoding scheme ............................. 42 5.5. Conclusion ................................... 42 CHAPTER 6. Ground Station to PocketQube communication . . . 43 6.1. Size of the packets ............................... 43 6.2. Uplink telecommands ............................. 44 6.2.1. RESET2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 6.2.2. EXIT STATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 6.2.3. TLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.2.4. ADCS CALIBRATION . . . . . . . . . . . . . . . . . . . . . . . . . 46 6.2.5. SEND DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 6.2.6. SEND TELEMETRY . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.2.7. STOP SENDING DATA . . . . . . . . . . . . . . . . . . . . . . . . 48 6.2.8. CHANGE TIMEOUT . . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.2.9. ACTIVATE PAYLOAD . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.2.10. SEND CONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 6.2.11. UPLINK CONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 6.3. Downlink packets ................................ 52 6.3.1. Telemetry packet . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 6.3.2. Configuration packet . . . . . . . . . . . . . . . . . . . . . . . . . . 54 6.3.3. Data packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 6.4. Conclusions ................................... 55 CHAPTER 7. Software ............................. 57 7.1. PocketQube Communication Software . . . . . . . . . . . . . . . . . . . . 57 7.1.1. Multithread architecture . . . . . . . . . . . . . . . . . . . . . . . . 57 7.1.2. Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 7.1.3. PocketQube Communications State Machine . . . . . . . . . . . . . 58 7.1.4. Transmission and Reception PocketQube Flowchart . . . . . . . . . 59 7.2. TinyGS Communications Software . . . . . . . . . . . . . . . . . . . . . . 60 7.2.1. Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 7.2.2. TinyGS Transmission and Reception . . . . . . . . . . . . . . . . . 61 7.3. Conclusions ................................... 65 CHAPTER 8. Development Setup . . . . . . . . . . . . . . . . . . . . . . 67 8.1. TinyGS ...................................... 67 8.1.1. Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 8.1.2. Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 8.2. PocketQube ................................... 70 8.2.1. On Board Computer - Transceiver connection . . . . . . . . . . . . 70 8.2.2. Transceiver module . . . . . . . . . . . . . . . . . . . . . . . . . . 71 8.2.3. STM32L476RG and SX1262 setup . . . . . . . . . . . . . . . . . . 73 8.3. Conclusions ................................... 73 CHAPTER 9. Results .............................. 75 LIST OF TABLES 1.1 Different types of satellites depending on their mass. Table from [6]. . . . . . . 7 4.1 Overview of LPWAN technologies: Sigfox, LoRa, and NB-IoT. Table from [16] [21]. 19 4.2 Distance in km, depending on elevation and altitude. . . . . . . . . . . . . . . 27 4.3 Total losses in dB depending on elevation and altitude. . . . . . . . . . . . . . 30 4.4 Received power in dBm depending on elevation and altitude. . . . . . . . . . . 31 4.5 SNR uplink in dB depending on elevation and altitude. . . . . . . . . . . . . . . 32 4.6 SNR downlink in dB depending on elevation and altitude. . . . . . . . . . . . . 32 4.7 Typical LoRa SNR accepted by the demodulator. Table from SX1262 Datasheet [58]......................................... 32 4.8 Chosen orbits for every inclination and altitude combination. . . . . . . . . . . 33 4.9 Capacity and beacon transmitting time depending on the coding rate for SF = 7 and SF = 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4.10Capacity and beacon transmitting time depending on the coding rate for SF = 9 and SF = 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4.11Capacity and beacon transmitting time depending on the coding rate for SF = 11 and SF = 12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4.12Simulated contact times per orbit (min/orbit) for an inclination of 95º. . . . . . . 36 4.13Simulated contact times per orbit (min/orbit) for an inclination of 97º. . . . . . . 36 4.14Simulated contact times per orbit (min/orbit) for an inclination of 99º. . . . . . . 36 4.15Simulated contact times per day (min/day) for an inclination of 95º. . . . . . . . 36 4.16Simulated contact times per day (min/day) for an inclination of 97º. . . . . . . . 36 4.17Simulated contact times per day (min/day) for an inclination of 99º. . . . . . . . 37 6.1 Maximum application payload size depending on data rates. Table from [43]. . . 43 ACKNOWLEDGEMENTS First of all, this endeavour would have not been possible without my advisors Dr Hyuk Park and Dr Adriano Jos´ e Camps Carmona who have guided and oriented me along the whole process and also who made possible my collaboration in the POCAT mission at the NanoSat Lab. Moreover, I would also like to express my deepest gratitude to my supervisors S ,tefan Podaru and Guillem Gr` acia i Sol` a who have been by my side mentoring me. Additionally, I am grateful to all the dedicated students at the NanoSat Lab who have worked alongside me, with a special mention to Nil Rius, who played a crucial role in the development of the On-Board Computer (OBC). I would also like to acknowledge the previous students at the Lab whose contributions have laid the foundation for the success of this project which has evolved over four generations of the Engineering Advanced Project (PAE which is a subject of the Bachelor’s Degree in Telecommunication Technologies and Services Engineering at UPC). It is important to acknowledge the contribution of Daniel Herencia, the predecessor of the communications subsystem, in which I have been actively involved. Lastly, I would like to extend a special acknowledgement to my family and my couple for their unwavering support throughout this double degree. 1 LIST OF ABBREVIATIONS 3GPP - 3rd Generation Partnership Project ACKs - Acknowledgments ADCS - Attitude Determination and Control System API - Application Programming Interface BCH - Bose–Chaudhuri–Hocquenghem BSK - Binary Phase Shift Keying BW - Bandwidth CCSDS - Consultative Committee for Space Data Systems COMMS - Communications CPU - Central Processing Unit CRC - Cyclic Redundancy Checkv CR - Coding Rate CSS - Chirp Spread Spectrum C/R - Coding Rate ECC - Error Correction Codes EPS - Electrical Power Supply FEC - Forward Error Correction FS - Frequency Synthesis FSPL - Free Space Path Loss GRSS - Geoscience and Remote Sensing Society GS - Ground Station HTTP - Hypertext Transfer Protocol IOT - Internet of Things IP - Internet Protocol ISL - Inter-Satellite Links ISM - Industrial, Scientific, and Medical Radio ITU - International Telecommunication Union LEO - Low Earth Orbits LP - Linear Polarization LPWAN - Low Power Wide Area Networks LTE - Long-Term Evolution M2M - Machine to Machine MNO - Mobile Network Operators 3 4 Design and Performance Analysis of a LoRa communication system for PocketQubes MQTT - Message Queuing Telemetry Transport MSc. - Masters of Sciences NASA - National Aeronautics and Space Administration NACKs - Negative Acknowledgments NB-IoT - Narrowband IoT OAdM - Observatori Astronomic del Montsec OBC - On-Board Computer OLED - Organic Light-emitting Diode PAE - Engineering Advanced Project PCB - Printed Circuit Board POR - Power On or Reset QPSK - Quadrature Phase-Shift Keying RF - Radio Frequency RFI - Radio Frequency Interference RHCP - Right-hand Circular Polarization SF - Spreading Factor SNR - Signal-to-Noise Ratios SoC - System-on-chip SSO - Sun-synchronous STDBY - Standby TLE - Two-Line Element TLS - Transport Layer Security UHF - Ultra High Frequency VHF - Very High Frequency INTRODUCTION In technology, there is a trend of miniaturizing components which has been evident in many devices such as computers and telephones. Conversely, the very first satellites, including Sputnik I launched by the Soviet Union in 1957, Explorer 1 launched by the United States in 1958 and Oscar 1 the first amateur radio satellite launched in 1961 were already what are now considered small satellites. These satellites had relatively limited power and quite simple antennas. Moreover, the first operational satellites, like Intelsat 1 also known as Early Bird, the first commercial communications satellite launched in 1965, and ANIK-1 launched by Telesat Canada in 1972, the world’s first domestic communications satellite, are also seen as small satellites by modern standards. Instead of following the miniaturization trend, in the following 5 decades (from 1960-2010), a tendency to build bigger and higher throughput satellite antennas was developed. This behaviour is illustrated in Figure 1this trend was called the technology inversion. While satellites increased in size and capacity, the ground antenna systems became simpler and smaller. Figure 1: The technology inversion. Image from [1]. Nevertheless, in the mid-1980s and 1990s, a new model of satellites was born. Both CTA and Orbital ATK, designed GEOSTAR-1, a smaller geosynchronous satellite platform. This milestone impulsed the design of smaller LEO satellites along with the deployment of constellations such as the Iridium satellite system, Globalstar satellite system, ICO system, Teledesic and so on. In 1999, Bob Twiggs, a professor at Stanford University’s Space Systems Development Laboratory (SSDL) in collaboration with Jordi Puig-Suari, a professor at California Polytechnic State University (Cal Poly), conceived the concept of the CubeSat which consisted on a satellite of 10 x 10 x 10 cm3dimensions [4]. It was created in an attempt to provide an easier and affordable access to space for universities while also reducing the development 5 6 Design and Performance Analysis of a LoRa communication system for PocketQubes time so that it could fit in a Bachelor of Science degree (less than 4 years). Consequently, many universities started their own space programs based on CubeSats. Apart from universities, Government agencies and commercial groups also joined the development of CubeSats. Nowadays, thousands of CubeSats have been launched into orbit as seen in Figure 2. Finally, in 2009, Bob Twiggs at Morehead State University, created the PocketQube satellite which had 5 x 5 x 5 cm3dimensions and a mass of 250g. Figure 2: Launch history of small satellites. Image from [3]. In this project, the communications system of a UPC NanoSat Lab PocketQube will be developed. Consequently, during the execution of this project, the design of a LoRa communication link from a ground station based on an ESP32 chip [55] and the PocketQube based on a NUCLEO-L476RG - STM32 [57] connected to an SX1262 transceiver[58] has been implemented and tested. CHAPTER 1. POCKETQUBES Satellites can be classified into multiple categories depending on their mass. The table below illustrates the categorization scheme based on this variable. Satellite type Mass (kg) Mini satellite 201 to 600 Micro satellite 11 to 200 Nano satellite 1.1 to 10 Pico satellite 0.1 to 1 Femto satellite <0.1 Table 1.1: Different types of satellites depending on their mass. Table from [6]. PQs are picosatellites, as can be inferred from Table 1.1. At the moment there is not yet a universally accepted PocketQube standard. However, the Delft University of Technology, Alba Orbital and Gauss Srl designed a first approach in 2018 [7]. In this first issue, some requirements for the PocketQube were established such as outer dimensions, mass or materials. While other topics such as electrical requirements, operational requirements and testing requirements were incomplete and meant to be fulfilled in the next issues. 1.1. Advantages PocketQubes have become a widely adopted option for various applications due to their affordability, compact size, and low weight. Therefore, these small satellites have emerged as a promising technology for boosting low-cost access to the space sector in the educational, and in some scientific, and commercial fields as well [12],[13]. Regarding their design philosophy, they are built using as many state-of-the-art COTS technologies as possible in order to avoid dependence on complex mechanisms but also achieve complex functionalities. By integrating different instruments like communication systems, magnetometers, gyroscopes, cameras, etc., it is possible for them to perform functions such as simple earth observation, weather monitoring, space exploration, and so on. 1.2. Orbits These satellites usually orbit in sun-synchronous Low Earth Orbits (LEO). The popularity of LEO orbits comes from the fact that they are relatively close to the Earth’s Surface. This proximity provides the following benefits. Firstly, results in a higher resolution of the images taken and in more accurate measurements of the Earth’s environment, which is crucial for Earth observation missions, while secondly, allowing for cheaper launches. 7 14 Design and Performance Analysis of a LoRa communication system for PocketQubes 2.5. Conclusions In summary, the PoCAT Project is an educational initiative aiming to standardize an opensource PocketQube satellite kit for Earth Observation purposes. The project consists of three PocketQubes, each with a specific payload for its personalised mission. Moreover, each PocketQube operation is based on five subsystems: OBC, COMMS, ADCS, EPS, and PAYLOAD. All three of the PoCATs will be fitted inside the 3CAT-8 deployer and launched together. Finally, the antenna consists of a quarter-wave monopole made out of measuring tape which will be tied to the satellite’s surface till the launch is finished and then, it will be deployed. CHAPTER 3. STATE OF THE ART 3.1. Communication Technologies for Picosatellites Regarding the range scope of satellite communications, which must cover around 450-600 km (from satellite to ground), Low Power Wide Area Networks (LPWAN) are a very used wireless communication type. LPWAN include different technologies such as Narrowband IoT (NB- IoT), SigFox or LoRa[16] which will be discussed. 3.1.1. SigFox SigFox is an LPWAN operator which intends to provide end-to-end IoT connectivity [10]. Its main characteristics are stated below: •Uses Binary Phase Shift Keying (BSK) modulation. •Operates within the unlicensed Industrial, Scientific, and Medical radio (ISM) frequency bands (specifically 868 MHz in Europe, 915 MHz in North America, and 433 MHz in Asia). Therefore, anyone is allowed to use these frequencies since no license fee is required, but then lower data rates and more interferences are given, since anyone can transmit. •Operates within a bandwidth of 100 Hz. •The maximum data rate allowed can be 100 bps or 600 bps. •The transmitted power can reach 22 dBm. •The received power can be up to -126 dBm. •Provides a very high interference immunity. •Does not support authentication and encryption methods •The MAC layer protocol allows delays characteristics of LEO satellite communications. •The deployment and management of its infrastructures (base stations and gateways) is entitled solely to Sigfox, thus other parties can not integrate their own gateways in SigFox satellites. 3.1.2. Narrowband IoT (NB-IoT) Narrowband IoT is an LPWAN technology based on the Release 13 of the 3rd Generation Partnership Project (3GPP) in June 2016 [17]. Moreover, it is included in the 4G and 5G networks. Its main features are the following: •Uses a narrow-band Quadrature Phase-Shift Keying (QPSK) modulation. 15 16 Design and Performance Analysis of a LoRa communication system for PocketQubes •Operates within the frequency bands designated and licensed for LTE (Long-Term Evolution) networks. •Operates within a bandwidth of 200 kHz. •The data rate is 26 kbps for the uplink (from the base station to the devices) and 66 kbps when it is for the downlink (from the devices to the base station). However, it may experience peaks that can reach 250 kbps. It provides higher rates than the other technologies because a licence fee is needed to transmit, therefore the frequency bands are less crowded, thus higher data rates and lower interferences are given. •The transmitted power can reach 23 dBm. •The received power can be up to -125 dBm. •Has a low interference immunity. •Supports authentication and encryption thanks to the LTE Encryption. •The PHY/MAC layer protocol is not compatible with the delays and the Doppler effect attached to LEO satellite communications, hence it must be adjusted to work with satellites. •The Mobile Network Operators (MNO) are in charge of the deployment and management of the base stations. 3.1.3. LoRa This last one is a physical layer technology developed by Cycleo and subsequently acquired by Semtech [11]. The name LoRa comes from the fact that is a ”Long Range” technology, however, the price to pay is a smaller data rate. Its main characteristics are listed below: •Uses a proprietary Chirp Spread Spectrum (CSS) modulation. This type of modulation is more resilient to interference and jamming than the others. Additional details can be found in Annex A. •Operates within the unlicensed Industrial, Scientific, and Medical radio (ISM) frequency bands (specifically 868 MHz in Europe, 915 MHz in North America, and 433 MHz in Asia). •Operates within different bandwidths (125 kHz, 250 kHz and 500 kHz), thus in the transceiver, the chosen value must be configured. Moreover, other variable parameters such as transmitted power, Spreading Factor (SF) and Coding Rate (CR) also need to be specified in the transceiver. •The maximum data rate allowed is 27 kbps. •The transmitted power can reach 22 dBm. State Of The Art 17 •The received power can be up to -125 dBm. •Provides a very high interference immunity. •Supports authentication and encryption since it uses the AES 128b algorithm. •There are different options concerning the MAC layer, but the most common is Lo- RaWAN, because it is open-source and optimizes the power consumption which is a critical aspect for satellites. Moreover, it can compensate for the Doppler effect. •Several manufacturers provide COTS components for LoRa modules and Gateways. 3.1.4. Tested Technologies Every day the small satellites industry becomes more and more popular, however, the PocketQubes field is still relatively unexplored. Hence, in this section, companies operating nanosatellites will also be analysed since their technology can somehow be extrapolated to picosatellites. Note that no small satellites in orbit have been found for the SigFox technology. 3.1.4.1. Fossa Systems Fossa Systems is an organization dedicated to boosting the development of open-source small satellites while promoting equitable access to space. Their first launched PocketQube was the FossaSat-1, which also was the first Spanish LEO picosatellite (nowadays it is already inactive). This satellite was built using inexpensive LoRa modules, thus it proved the feasibility of LoRa communications for PocketQubes in LEO orbits [18]. This company has already launched many other PocketQubes aiming at an 80-satellite constellation expected for 2024. These satellites include a GNSS receiver, GFSK, LoRa and S-Band communications, and are implemented with an ARM STM32 Processor like the POCATs. 3.1.4.2. Lacuna Space Lacuna Space operates with 6U (Units) CubeSat nanosatellites, but the used technology is also LoRa [19]. This company is deploying a constellation of 32 nanosatellites in a Low Earth Orbit (LEO), which will be called Lacuna Network and aims at providing widespread coverage in areas without reliable wireless connectivity. These satellites are LoRa-based Space Gateways and use the LoRaWAN protocol at the MAC layer. 3.1.4.3. Sateliot Sateliot also operates with nanosatellites and this year launched the first LEO 5G nanosatellite for IoT [20]. This satellite is called ”The GroundBreaker” and has an onboard module allowing direct NB-IoT communication with any 5G device using the 3GPP Release 17 NB-NTN. 18 Design and Performance Analysis of a LoRa communication system for PocketQubes 3.2. Challenges of PocketQube communications One of the challenges associated with PocketQubes communications is the reduced available power concerning the downlink, given the small size of the solar panels and the modest battery unit. Thus, optimizing communications will be critical to avoid power waste and at the same time, maximize the mission lifespan. Furthermore, given the fact that they operate in LEO orbits and therefore, the contact pass times are limited, the information to be sent needs to be clear and concise. Hence, the packet structures must to carefully designed. Moreover, the large distances to cover imply considerable losses which is the reason why error correction codes need to be implemented in order to ensure a more reliable and accurate data communication. 3.3. Conclusions The communication technologies, such as SigFox, Narrowband IoT (NB-IoT), and LoRa, provide potential solutions for PocketQube communications. These low-power, wide-area network (LPWAN) technologies offer different characteristics in terms of modulation, frequency bands, bandwidth, data rate, transmitted power, received power, interference immunity, and encryption and authentication capabilities. The feasibility of LoRa communications in picosatellites has been demonstrated in the FossaSat-1 PocketQube mission and Lacuna Space missions (with nanosatellites), while Sateliot has proved the NB-IoT communication (also in nanosatellites). Overall, optimizing communication protocols, addressing power limitations, ensuring efficient data transmission within limited contact time passes, and mitigating signal losses are the main challenges in PocketQube communications. CHAPTER 4. POCKETQUBE COMMUNICATION SYSTEM 4.1. Technology Selection Among all the LPWAN technologies, the chosen one has been LoRa, since it is more resilient in front of interferences, it can tolerate delay and it is able to compensate the Doppler effect [22]. Moreover, it operates within the ISM band, thus no license fee is required. Furthermore, it has already been tested in space-to-Earth communications over a long period by other companies such as Fossa Systems or Lacuna Space. In table 4.1 a comparison of all LPWAN technologies can be observed. Sigfox LoRa NB-IoT Modulation BPSK CSS QPSK Frequency bands ISM ISM LTE Bandwidth 100 Hz 125/250/500 kHz 200 kHz Maximum data rate 100 bps - 600 bps 27 kbps 250 kbps Transmitted power 22 dBm 22 dBm 23 dBm Sensibility -126 dBm -125 dBm -125 dBm Interference immunity Very high Very high Low Delay tolerant Yes Yes No Authentication encryption Not supported Yes (AES 128b) Yes (LTE encr.) Table 4.1: Overview of LPWAN technologies: Sigfox, LoRa, and NB-IoT. Table from [16] [21]. 4.2. Communication parameters 4.2.1. Frequency Regarding the ISM European band, the frequency allocated is 868 MHz. Moreover, concerning the ground station, each country has assigned a frequency plan which is based on the specifications in the LoRaWAN regional parameters document [23]. In accordance with the regional parameters document, the attributed frequency plan in Spain is EU863-870 in which the designated frequency for use is also 868 MHz. 19 20 Design and Performance Analysis of a LoRa communication system for PocketQubes 4.2.2. LoRa parameters 4.2.2.1. Coding Rate LoRa adds a forward error correction (FEC) by adding from 5 to 8 bits of redundancy for every 4 bits of data. This coding rate is represented by a ratio in which the numerator corresponds to the data bits and the denominator represents the redundant bits. Since capacity is critical in this type of link, the lowest redundancy will be chosen, which corresponds to the coding rate of C/R= 4/5. 4.2.2.2. Spreading Factor The Chirp Spread Spectrum modulation technique employs a spreading factor, which determines the number of bits that can be encoded by each symbol/chirp. Therefore, a higher spreading factor allows more data to be accommodated within a symbol. However, there is a trade-off: while more data can fit in a symbol, the coding process takes longer, resulting in a decrease in the speed of data transmission. The possible values for the SF go from SF7 to SF12. With the aim of choosing an appropriate SF, the results from this paper [21] will be taken into account. Given the uplink and downlink received power and SNR results shown in Figure 4.1, for a monopole antenna which corresponds to the red line in the plots, and a gain of 14.14 dB (this will be justified in the subsequent sections) which must be taken into account by moving up the red line this specified amount, the minimum spreading factor to establish communication for all elevations, corresponds to the SF11. (a) Uplink (b) Downlink Figure 4.1: Received power and SNR for a 868 MHz transceiver. Images from [21]. PocketQube Communication System 21 4.2.2.3. Bandwidth Before choosing the bandwidth, it is essential to check if the Doppler effect will have a great impact. With that in mind, the speed of the satellites has to be computed. This equation 4.1 will be used. vorbit =rGM RE+h,(4.1) where: •Gis the gravitational constant: 6.6743 x 10−11m3kg−1s−2, •Mis the Earth’s mass: 5.972 x 1024kg, •REis the Earth’s radius: 6371 km, and •his the orbit’s height. For an altitude of 450 km, the velocity of the satellites is 7,64 km/s, and for an altitude of 600 km, it is 7,56 km/s. These values are significantly high, therefore the Doppler effect needs to be taken into account. The equation used to compute the change in frequency due to the Doppler effect is 4.2. △f=v cf0,(4.2) where: •vis the relative velocity between the satellite and the ground station (positive when moving towards, negative when moving away), •cis the speed of light in a vacuum: 3 x 108m/s, and •f0is the frequency of the signal. Given the fact that the satellite is moving towards the ground station, vwill be positive. Thus, with a frequency of 868 MHz and the velocities of the satellite computed previously, the impact of the Doppler effect in the frequency for the altitude of 450 km will be 22,1 kHz, and for the altitude of 600 km, it will be 21,87 kHz. From the Experimental Study of LoRa Modulation Immunity to Doppler Effect in CubeSat Radio Communications [21], it has been concluded that when using LoRa modulation, the BW defines the maximum frequency shift able to compensate by the modules. The maximum Doppler frequency shift that can be compensated is up to 25% of the BW, and if the Doppler effect is below this value, it compensates by itself. Therefore, the Doppler effect can be neglected if the right BW chosen meets the equation 4.3. BW ≥ △f 0.25 (4.3) Hence, the possible BW values need to be higher than 88.4 kHz to be compensated. The different choices are 125 kHz, 250 kHz, and 500 kHz. In order to reduce the noise power and transmission time, the optimal BW is the lowest one, 125 kHz (which can compensate for a frequency shift of ±31.25 kHz). 22 Design and Performance Analysis of a LoRa communication system for PocketQubes 4.3. Ground Stations More than one ground station will be operated. The first one is the UPC NanoSat Lab Montsec Ground Station and the rest will be the ones provided by the TinyGS network, in particular the UPC NanoSatLab GS. 4.3.1. Montsec Ground Station The UPC NanoSat Lab is working with its own ground station located in the Observatori Astron` omic del Montsec (OAdM) owned and operated by IEEC. This ground station has been developed by UPC NanoSat Lab students, and operates with two types of antennas. The first type are transmission and reception Yagi antennas at Very High Frequency (VHF) and Ultra High Frequency (UHF) bands, particularly at 144-145 MHz for VHF and 435-438 MHz for UHF. These antennas have full SDR capabilities. The second type is a reception antenna with a 3-meter dish for the S-Band commercial band of 2200-2290 MHz. These antennas are managed by automated software in charge of scheduling and retrieving data via an optical fiber connection to the Barcelona Operations Center. In order to request passes or download retrieved data from the Operation Center, a REST API is utilised. [30]. As mentioned earlier, the satellite link operates at the EU863-870 designated frequency of 868 MHz. However, as it can be noted, the Montsec Ground Station does not yet have an antenna working at that frequency. It has an antenna working in the UHF band but only working at 435-438 MHz frequencies (the one shown in Figure 4.2). Figure 4.2: VHF/UHF Montsec ground station. Image from [32]. The UHF antenna is equipped with both vertical and horizontal polarization components and it has a gain of 12.8 dBi. An azimuth/elevation Yaesu rotor is being used, which is controlled in the ground station computer through Ethernet. This controller is designed by students from the UPC NanoSat Lab. This station was already used in 3CAT-1 missions, and it will also be utilised in the soon- to-be-launched 3CAT-4 missions. [32]. PocketQube Communication System 23 4.3.2. TinyGS ground station The TinyGS project was developed by a group of space enthusiasts who wanted to be able to track and use satellites to learn and experiment with radio. TinyGS network provides an almost global coverage as seen in figure 4.3. These distributed stations use cheap and versatile modules and aim to receive and operate LoRa satellites such as the FossaSat-2E collection, Norby, Gossamer, etc. They can also receive from weather probes and other flying objects with compatible radio modulation such as FSK, GFSK, MSK, GMSK, LoRa and OOK. Figure 4.3: TinyGS global network. Image from [27]. They provide the source code of the ground stations so people from all around the world only need to purchase a cheap module, flash the code in it and start receiving from satellites, weather probes and other flying objects right away. The messages received by any ground station are stored in a common database. Apart from all the ground stations spread around the globe, the one that will be studied for the link and data budget is the UPC NanoSatLab GS TinyGS. This ground station will be working at the EU863-870 designated frequency of 868 MHz, with an SF = 11 and a CR = 4/5, matching the PocketQube communication parameters commented on earlier. The flashed code will be the TinyGS source code with some modifications in order to transform it also into a transmitter, unlike the rest of the TinyGS ground stations which are only able to receive telemetry from the satellites. The reason why the ground station also needs to work as a transmitter is to control the POCAT PocketQubes. As it will be explained in detail in the next chapter, in order to receive data, change some configuration or activate the payload from the PocketQube, first a telecommand specifying what needs to be done must be sent. Regarding the hardware of the antenna, it has been developed within the 3CAT-NXT project, as part of the PAE subject taught as a mandatory course in UPC [33]. From the simulations, a gain equal to 14.14 dB was extracted. The main antenna characteristics are presented below. 30 Design and Performance Analysis of a LoRa communication system for PocketQubes Altitude Elevation 40º50º60º70º80º90º 450 Km 154,7 153,4 152,4 151,8 151,4 151,3 500 Km 155,6 154,3 153,3 152,7 152,3 152,2 550 Km 156,4 155,1 154,2 153,5 153,1 153,0 600 Km 157,1 155,8 154,9 154,3 153,9 153,8 Table 4.3: Total losses in dB depending on elevation and altitude. 4.4.3. Noise Power Before computing the noise power, the noise temperature needs to be defined. This temperature is not the same for the ground station as for the satellite, thus two different noise powers will be computed. On the one hand, the noise temperature from the ground station to the satellite (the uplink noise temperature) considered is 290K since it is a typical value used for the Earth noise temperature. Even though it is said to be over-conservative, it is better to study the worse case [41]. On the other hand, the noise temperature from the picosatellite to the ground station (the downlink noise temperature) needs a more in-depth study 4.9. TA=TSKY +TGROUND,(4.9) where: •TSKY is the sky temperature, and •TGROUND is the ground temperature. The value taken for TGROUND is once again 290 K and for the sky temperature, a common value to take into account is 20 K. Thus, the downlink noise temperature TAis equal to 310 K. Once both uplink and downlink temperatures are defined, power noise for both cases can be calculated with the equation 4.10. PN=KBTNBW,(4.10) where: •KBis the Boltzmann constant equivalent to 1.38·10−23 J/K, and •TNis the noise temperature which differs between the uplink and downlink scenarios. Finally, the results for both the uplink and downlink power noises are presented below in 4.11. PNuplink =−123.01dBm PNdownlink =−122.72dBm (4.11) PocketQube Communication System 31 4.4.4. Final link budget The last step before computing the signal-to-noise ratio (SNR) is to compute the sensibility of the antennas. The formula to get this value is the one shown in equation 4.12. PR=PT+GT+GR−LTotal,(4.12) where: •PTis the transmitted power, •GTis the gain of the transmitting antenna, and •GRis the gain of the receiving antenna. Given the fact that different values for Ltotal have been computed evaluating different elevations and altitudes, there will also be multiple results for PR, all gathered in Table 4.4. The received power remains the same for both the uplink and downlink cases since the equation 4.12 takes into account the gains of both antennas. As previously defined, the satellite’s antenna gain is 0 dB, while the UPC NanoSat Lab TinyGS ground station antenna gain is 14.14 dB, and the transmitted power is 22 dBm. However, in the uplink case, more power could be used to get a better SNR, but for the sake of simplicity, the same amount of power will be used. With these values, Table 4.4 has been filled. Altitude Elevation 40º50º60º70º80º90º 450 Km -118,6 -117,3 -116,3 -115,6 -115,3 -115,1 500 Km -119,5 -118,2 -117,2 -116,6 -116,2 -116,1 550 Km -120,3 -119,0 -118,0 -117,4 -117,0 -116,9 600 Km -121,0 -119,7 -118,8 -118,1 -117,8 -117,6 Table 4.4: Received power in dBm depending on elevation and altitude. Finally, with all the previous steps, the final link SNR can be computed by means of the equation 4.13. The SNR is influenced by elevation, altitude, (due to the received power) and whether it is an uplink or downlink case (because of the noise power). SNR =PR−PN,(4.13) where PNwill be different for the uplink and downlink. Tables 4.5 and 4.6 present the calculated SNR values for different scenarios in the link budget analysis. By examining these tables, one can determine the SNR values corresponding to specific elevation and altitude conditions for both the uplink 4.5 (even though, these values could be better with higher transmitted power) and downlink 4.6 cases. 32 Design and Performance Analysis of a LoRa communication system for PocketQubes Altitude Elevation 40º50º60º70º80º90º 450 Km 4,4 5,8 6,7 7,4 7,8 7,9 500 Km 3,5 4,9 5,8 6,5 6,8 7,0 550 Km 2,7 4,1 5,0 5,6 6,0 6,1 600 Km 2,0 3,3 4,3 4,9 5,3 5,4 Table 4.5: SNR uplink in dB depending on elevation and altitude. Altitude Elevation 40º50º60º70º80º90º 450 Km 4,1 5,5 6,4 7,1 7,5 7,6 500 Km 3,3 4,6 5,5 6,2 6,5 6,7 550 Km 2,5 3,8 4,7 5,3 5,7 5,8 600 Km 1,7 3,0 4,0 4,6 5,0 5,1 Table 4.6: SNR downlink in dB depending on elevation and altitude. These values are actually quite good since the SX1262 LoRa transceiver has even the capability to receive signals with negative SNR as shown in Table 4.7. The typical value for the spreading factor SF11 is -17.5 dB, consequently the obtained SNRs are more than enough. Spreading Factor (SF) 5 6 7 8 9 10 11 12 SNR (dB) -2.5 -5 -7.5 -10 -12.5 -15 -17.5 -20 Table 4.7: Typical LoRa SNR accepted by the demodulator. Table from SX1262 Datasheet [58]. 4.5. Orbits As it has already been mentioned, the orbits used by PoquetQubes are LEO and near SSO orbits thanks to their multiple benefits for the applications of these satellites. The orbit of POCAT suite is still to be determined. Therefore, a range of possible options has been taken into account. The range is defined by two variables, inclination, and altitude. On the one hand, the inclination will be studied for three cases: 95º, 97º, and 99º, since the most common inclination for SSO LEO orbits, is around 98-99 degrees. These inclinations are suggested because as commented, SSO orbits are near-polar orbits which allow the satellite to pass over both poles, therefore a whole coverage of the Earth’s surface is PocketQube Communication System 33 provided over time. And given the fact that the mission goal is Earth Observation, this is a great advantage. Meanwhile, for the altitude, the range will vary from 450 Km to 600 Km with increments of 50 Km. To allow satellites to complete a whole orbit in an estimated time of 94.5 minutes. This way the satellite will be able to do 15 whole orbits in a day. In order to do some simulations, already existing orbits meeting the above requirements will be used. The TLEs (two line element) of different orbits have been extracted [15] . Some of the TLEs used are modifications of the ones found in order to get more accurate altitude and inclination parameters. The following table 4.8, shows all the orbits used for the study contemplating each combination of inclination and altitude. Altitude Inclination 95º97º99º 450 km IPEX LS3C OBJECT A 500 km BLUEWALKER 3 BLUEWALKER 3 LILACSAT 2 550 km QUBESCOUT-S1 QUBESCOUT-S1 FLOCK 1C 3 600 km UWE-3 YAOGAN-30 E DTUSAT-2 Table 4.8: Chosen orbits for every inclination and altitude combination. The TLEs of these orbits are attached in Annex B. 4.6. Data budget A data budget is essential for the design of a communication system to optimize data usage and improve overall performance. The bit rates for all LoRa spreading factors and coding rates have been calculated along with the contact times for each orbit. With these values, the amount of data transmitted in a pass or in a day will be estimated. The capacity of the channel in bps (C) can be computed by means of the following formula 4.14. C=SF CR 2SF BW .(4.14) In addition to capacity, the time needed to transmit a packet has also been computed using the formula 4.15. The results for all spreading factors and coding rates are all shown in Tables 4.9,4.10,4.11. ttx =Packet size C.(4.15) To do this calculation, the type of packet taken into account is the beacon packet which is sent once every minute. In this packet, it is sent the same information as in the telemetry packet which has a length of 48 Bytes (this is deeply explained later in chapter ”Telecommands for PocketQubes”). 34 Design and Performance Analysis of a LoRa communication system for PocketQubes SF 7 8 Capacity (bits/s) Beacon time (ms) Capacity (bits/s) Beacon time (ms) Theoretical 6835,9 56,2 3906,3 98,3 CR = 4/5 5468,8 70,2 3125,0 140,8 CR = 4/6 4557,3 84,3 2604,2 169,0 CR = 4/7 3906,3 98,3 2232,1 197,1 CR = 4/8 3418,0 112,4 1953,1 225,3 Table 4.9: Capacity and beacon transmitting time depending on the coding rate for SF = 7 and SF = 8. SF 7 8 Capacity (bits/s) Beacon time (ms) Capacity (bits/s) Beacon time (ms) Theoretical 2197,3 174,8 1220,7 314,6 CR = 4/5 1757,8 218,5 976,6 393,2 CR = 4/6 1464,8 262,1 813,8 471,9 CR = 4/7 1255,6 305,8 697,5 550,5 CR = 4/8 1098,6 349,5 610,4 629,2 Table 4.10: Capacity and beacon transmitting time depending on the coding rate for SF = 9 and SF = 10. SF 7 8 Capacity (bits/s) Beacon time (ms) Capacity (bits/s) Beacon time (ms) Theoretical 671,4 572,0 366,2 1048,6 CR = 4/5 537,1 714,9 293,0 1310,7 CR = 4/6 447,6 857,9 244,1 1572,9 CR = 4/7 383,7 1000,9 209,3 1835,0 CR = 4/8 335,7 1143,9 183,1 2097,2 Table 4.11: Capacity and beacon transmitting time depending on the coding rate for SF = 11 and SF = 12. PocketQube Communication System 35 The conclusion extracted from these results is that the higher the spreading factor the lower the capacity. Hence, for higher spreading factors less data will be sent in an orbit pass. Once the capacity and transmission times have been computed, the orbits presented in the Orbits section have been analyzed using the application Orbitron [44]4.9. The simulations have been carried out during a period equal to the actual estimated time of the mission, which is 2.7 years. Figure 4.9: Orbitron application [44] . The simulations have configured the location as Barcelona, and the ephemerides parameters shown in the following Figure 4.10. Figure 4.10: Orbitron ephemerides configuration parameters. With all the contact times acquired from the orbit simulations, a Matlab code has been developed to compute the best, worse, and average contact times per orbit and also per day. Both codes ara attached in Annex G. These values are presented in the following tables, 4.12,4.13,4.14,4.15,4.16,4.16. 36 Design and Performance Analysis of a LoRa communication system for PocketQubes Orbit IPEX BLUEWALKER 3 QUBESCOUT -S1 UWE-3 Best 10,3 7,5 8,0 9,3 Worse 1,0 1,0 1,0 1,0 Average 6,8 5,6 6,0 6,8 Table 4.12: Simulated contact times per orbit (min/orbit) for an inclination of 95º. Orbit LS3C BLUEWALKER 3 QUBESCOUT-S1 YAOGAN-30 E Best 7,2 7,4 8,0 8,4 Worse 1,0 1,0 1,0 1,0 Average 4,9 5,6 6 6,6 Table 4.13: Simulated contact times per orbit (min/orbit) for an inclination of 97º. Orbit OBJECT-A LILACSAT 2 FLOCK 1C 3 DTUSAT-2 Best 7,15 7,5 8,2 8,4 Worse 1,0 1,0 1,0 1,0 Average 5,2 5,7 6,2 6,5 Table 4.14: Simulated contact times per orbit (min/orbit) for an inclination of 99º. Orbit IPEX BLUEWALKER 3 QUBESCOUT -S1 UWE-3 Best 34,2 24,8 28,9 30,0 Worse 6,6 7,5 3,1 14,5 Average 24,2 17,8 19,9 25,0 Table 4.15: Simulated contact times per day (min/day) for an inclination of 95º. Orbit LS3C BLUEWALKER 3 QUBESCOUT-S1 YAOGAN-30 E Best 22,2 26,3 26,6 28,2 Worse 7,0 6,9 13,1 2,1 Average 13,7 17,9 20,1 23,6 Table 4.16: Simulated contact times per day (min/day) for an inclination of 97º. PocketQube Communication System 37 Orbit OBJECT-A LILACSAT 2 FLOCK 1C 3 DTUSAT-2 Best 24,6 27,6 29,8 28,2 Worse 7,8 6,9 15,3 12,7 Average 15,5 18,4 22,0 23,5 Table 4.17: Simulated contact times per day (min/day) for an inclination of 99º. In order to compute the maximum amount of data able to be downloaded in a pass, the following formula will be employed 4.16. Maxdata =Ctpass,(4.16) where tpass corresponds to the contact pass time per orbit in seconds. The capacity corresponding to an SF = 11 and a CR = 4/5has been used, which is 537,11 bps (since these are the selected values as previously commented in the subsection ”LoRa parameters chosen”). Regarding the contact pass time, the mean of the average times from all the simulated contact times per orbit has been chosen, which is 5,99 min/orbit. With these values, the estimated maximum of downloaded data in a pass is 23,56 Kbytes. This final value is acceptable for small pictures or for when the maximum compression available is configured since a picture with a resolution of 640x480 and minimum compression occupies around 27 KB. However, for smaller pictures, in particular, for a resolution of 320x240 with maximum compression, the image occupies about 7 Kbytes which then is more than enough. 4.7. Conclusions In conclusion, the PocketQube Communication System chapter highlights the selection of LoRa as the preferred LPWAN technology due to its resilience against interferences, ability to tolerate delay, and capability to compensate for the Doppler effect. Moreover, due to the fact that it operates within the ISM band, eliminating the need for a license fee, and that it has already been proven in picosatellite space-to-Earth communications. The chosen frequency for the system is 868 MHz, aligning with the designated frequency plan in Spain and the European ISM. A C/R = 4/5 and an SF = 11 have been determined to optimize capacity and ensure successful communication. To reduce the noise power and transmission time, a bandwidth of 125 kHz has been selected, which is able to compensate for frequency shifts up to ±31.25 kHz. Regarding the ground segment, multiple ground stations will be used. Among them, the UPC NanoSat Lab Montsec Ground Station and the TinyGS network’s ground stations, specifically the UPC NanoSatLab GS. Considering a transmitted power of 22 dBm, satellite altitudes ranging from 450 km to 600 km, a frequency of 868 MHz, and a ground station antenna gain of 14.14, the link budget analysis demonstrates favourable results. Owing to the fact that the SX1262 LoRa transceiver proves capable of receiving signals with a negative SNR while the obtained results are all positive. 38 Design and Performance Analysis of a LoRa communication system for PocketQubes Lastly, the data budget analysis for orbits at 95º, 97º, and 99º, with altitudes between 450 km and 600 km, reveals an approximate value of 23.56 Kbytes able to be downloaded in one pass. This data budget is suitable for transmitting small pictures or utilizing the maximum available compression (but not for bigger or less compressed ones). For smaller pictures, such as those with a resolution of 320x240 and maximum compression, which occupy around 7 Kbytes, the available data budget is more than enough. CHAPTER 5. ERROR CORRECTION CODES Given the fact that long distances through environments sensitive to radiation and interferences need to be covered, space communications tend to be noisy. Therefore, data transmitted is likely to get corrupted or even lost. In order to correct or detect corrupted information and ensure reliable communication, error correction codes (ECC) can be used. There are various types of error correction codes, and each one of them brings different benefits. In the following picture 5.1, some of the coding techniques’ performances are shown. Figure 5.1: Probability of bit error as a function of the SNR of the transmission channel for several schemes. Image from [45]. Given the results in Figure 5.1, the initially chosen techniques will be Reed-Solomon combined with Convolutional Codes and Interleaving. 5.1. Reed-Solomon Reed-Solomon codes are one of the most widely used error correction codes. These codes are a subset of the cyclic error-correcting Bose–Chaudhuri–Hocquenghem (BCH) codes which use polynomials over a finite field which is also known as the Galois field, in order to correct errors. In these types of codes, the encoder takes k data symbols each formed by s bits, then adds 2t parity symbols and the outcome is an n symbol codeword. The t value corresponds to the number of symbols which can be corrected, hence 2 parity symbols will be needed to correct one from the codeword. All these values are related by the following formula 5.1 and shown in Figure 5.2. 39 46 Design and Performance Analysis of a LoRa communication system for PocketQubes Figure 6.3: TLE packet structure. 6.2.4. ADCS CALIBRATION This packet sends the whole ADCS parameters needed to calibrate and then, when the PocketQube receives it, the calibration is carried out. ADCS calibration is divided into 4 blocks. First of all, the 3x3 calibration matrix which has a total size of 36 bytes. Followed by the magnetometer offsets of the 3 magnetometer measurements which have a length of 4 bytes each. Then, the coefficients of the gyroscope polynomials used to calibrate the offsets of the 6 gyroscopes, which result in a total of 24 bytes. Finally, the six photodiodes measurement offsets which also have a total size of 24 bytes. As commented, ADCS calibration has a size of 96 bytes, thus 3 packets will be needed taking into account 34 bytes of data in each packet. With this amount of data in each packet, the last one will need a padding of 6 bytes. Then, 3 bytes from this padding will be used to add a counter in each packet header to inform about which of the 3 packets has been received. This will reduce the padding to half. The global structure 6.4 of the first two packets will be the following: •4 bytes of header formed by 2 bytes of PIN, 1 byte of telecommand ID and 1 last byte for the calibration packet counter, •33 bytes of the ADCS calibration data, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, and •1 end byte equivalent to 0xFF. The last packet will be different, it will only need 30 bytes of configuration data and at the end, 3 bytes of padding will be added. Ground Station to PocketQube communication 47 Regarding the division of the information, the first data packet is reserved for the calibration matrix. The second packet contains the remaining last 3 bytes of the calibration matrix, 12 bytes of the magnetometer offsets, and 18 bytes of the gyroscope polynomials. Finally, the last packet has the last 6 bytes of the gyroscope polynomials, and the photodiodes offset. Each packet will also be interleaved before being sent. Figure 6.4: ADCS CALIBRATION packet structure. 6.2.5. SEND DATA This telecommand orders the PocketQube to send the payload data. As it can be noted from Figure 6.5 the packet is formed by: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •1 byte to inform which picture size is desired (there are two choices: big or small), •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •1 byte of padding in order to reach the next multiple of 16 (in this case 16). Then, this content is interleaved and the output is transmitted. Figure 6.5: SEND DATA packet structure. 48 Design and Performance Analysis of a LoRa communication system for PocketQubes 6.2.6. SEND TELEMETRY This telecommand orders the PocketQube to send the telemetry data so it does not have to wait for the beacon to be transmitted. As it can be noted from Figure 6.6 the packet is formed by: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •2 bytes of padding in order to reach the next multiple of 16 (in this case 16). Then, this content is interleaved and the output is transmitted. Figure 6.6: SEND TELEMETRY packet structure. 6.2.7. STOP SENDING DATA This telecommand orders the PocketQube to stop sending payload data since many packets are sent in a row till all the photo or RFI data is transmitted (the payload data does not fit in a packet). As it can be noted from Figure 6.7 the packet is formed by: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •2 bytes of padding in order to reach the next multiple of 16 (in this case 16). Then, this content is interleaved and the output is transmitted. Figure 6.7: STOP SENDING DATA packet structure. Ground Station to PocketQube communication 49 6.2.8. CHANGE TIMEOUT This telecommand requests a change of receiving timeout of the PocketQube. This might be useful if the spreading factor is increased which implies slower transmissions. As it can be seen from Figure 6.1 the packet is formed by: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •2 bytes to send the new desired timeout in milliseconds, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, and •1 end byte equivalent to 0xFF. As noted, the packet is already 16 bytes long, thus no padding is needed. Then, this content is interleaved and the output is transmitted. Figure 6.8: CHANGE TIMEOUT packetstructure. 6.2.9. ACTIVATE PAYLOAD This telecommand is sent when the payload must be activated either for a photo or for an RFI measurement (depending on the payload of the POCAT). All the characteristics of the photo or measurement along with the payload configuration are specified in the telecommand. The structure of this telecommand is seen in Figure 6.9: •3bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •30 bytes for the payload activation specifications, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •4 bytes of padding in order to reach 48 bytes and do proper interleaving. The payload activation specifications are divided into 3 blocks: •First of all, 6 bytes with information related to the photo (in case the PQ has no camera as payload these bytes are set to 0), which can be broken down into: 50 Design and Performance Analysis of a LoRa communication system for PocketQubes –4 bytes of Unix time to inform when to take the next payload data acquisition, –1 byte to request a specific compression for the photo, and –1 byte to ask for a specific photo resolution. •Followed by 12 bytes for the RFI measurements (in case the PQ has no monitoring receiver as payload these bytes are set to 0) divided into: –4 bytes of Unix time to inform when to start taking the next RF measurement, –4 bytes of Unix time to inform when to finish taking the next RF measurement, –1 byte to set the minimum analysed frequency, –1 byte to set the maximum analysed frequency, –1 byte to specify the resolution, and –1 byte defining the integration time. The integration time corresponds to the period of time during which the receiver samples and accumulates the signal power or other relevant parameters in order to get a more accurate measurement. •Lastly, 12 reserved bytes for payload configuration which still need to be defined. Then, this content is interleaved and the output is transmitted. Figure 6.9: ACTIVATE PAYLOAD packet structure. 6.2.10. SEND CONFIG This telecommand asks the PocketQube to send its configuration packet in order to check if everything is working properly. In case something is not as expected, the UPLINK CONFIG telecommand is sent specifying the desired parameters to modify. As it can be noted from Figure 6.10 the packet is formed by: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, Ground Station to PocketQube communication 51 •1 end byte equivalent to 0xFF, and •2 bytes of padding in order to reach the next multiple of 16 (in this case 16). Then, this content is interleaved and the output is transmitted. Figure 6.10: SEND CONFIG packet structure. 6.2.11. UPLINK CONFIG The UPLINK CONFIG telecommand sends the desired PocketQube configuration to the satellite and once it is received, the parameters are compared to the ones stored in the PocketQube. If the parameters do not match, the values are updated. The structure of the telecommand is seen in Figure 6.11: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •18 bytes of configuration data, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •5 bytes of padding to reach the next multiple of 16, which is 32 bytes. The configuration data can be broken into: •4 bytes of Unix time used for synchronization, •4 bytes of communication parameters such as spreading factor, coding rate, frequency etc., •1 byte for the KP constant (the equilibrium constant), and •3 bytes for the battery thresholds of the nominal, the low and the critical states (one byte each). Then, this content is interleaved and the output is transmitted. 52 Design and Performance Analysis of a LoRa communication system for PocketQubes Figure 6.11: UPLINK CONFIG packet structure. 6.3. Downlink packets 6.3.1. Telemetry packet The telemetry packet is transmitted when the ground station sends the SEND TELEMETRY telecommand. Moreover, the telemetry is also sent in the beacon packet which is transmitted every minute. Inside this packet is gathered information from different PocketQube subsystems. The global structure is shown in Figure 6.12: •3 bytes of header formed by 1 byte of Mission ID, 1 byte for the PocketQube ID and lastly 1 byte for the packet ID (in this case the telemetry ID), •91bytes for the telemetry data, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, •1 end byte equivalent to 0xFF, and •5 bytes of padding in order to reach 48 bytes and do proper interleaving. The telemetry data can also be broken down into the different subsystem’s data: •4 bytes for the EPS. This subsystem has the following distribution of information: –1 byte to store the electrical power system voltage used, –1 byte to store the electrical power system current used, –1 byte for the battery capacity, and –1 byte for the subsystem temperature. •3 bytes for the OBC. This subsystem information is broken into: –3 bits for the PocketQube state (Init, Nominal, Contingency, Sunsafe, Survival and Waiting), –2 bits for the Point of Load, –3 bits for the PocketQube state error flags, Ground Station to PocketQube communication 53 –2 bits for the EPS errors such as CHRG (corresponds to an error during the charging process) or FAULT (this is a generic error), –6 bits for the communication protocols errors such as I2C, SPI, UART errors, and –1 byte to store the onboard computer temperature. •14 bytes for the ADCS. This other subsystem information can also be divided into: –6 bytes for the information on the gyroscope, –2 bytes for the magnetometers information, –3 bytes to store the sun vector, –2 bits for the ADCS mode. There are two possible modes, measuring and actuating, –6 bits for the magnetic torquer level, and –1 byte for the subsystem temperature. •7 bytes for the PQ temperature: This is not a subsystem, but it is a critical topic that needs to be included in the telemetry. It is also subdivided into: –6 bytes for each solar panel (+X, -X, +Y, -Y, +Z, -Z), and –1 byte for the battery temperature. Then, this content is interleaved and the output is transmitted. Figure 6.12: Telemetry packet structure. 54 Design and Performance Analysis of a LoRa communication system for PocketQubes 6.3.2. Configuration packet The configuration packet is transmitted from the PocketQube to the ground station when the SEND CONFIG telecommand is received. This packet has the same structure as the UPLINK CONFIG telecommand 6.11 except for the 2 bytes of PIN ID which are replaced by the mission ID and the PQ ID bytes as seen in Figure 6.13. Figure 6.13: Configuration packet structure. 6.3.3. Data packets The data packets are all sent in a row when the PocketQube receives the SEND DATA telecommand. There will be as many packets as needed in order to transmit the whole payload data. These packets are not encoded with Reed Solomon because it has been empirically proven that when the tinyGS ground station receives as many packets in a row, it has not enough time to decode them while keeping on listening to the rest. As it can be seen in Figure 6.7 the telecommand is formed by: •4 bytes of header formed by 1 byte of Mission ID, 1 byte of PocketQube ID, 1 byte of packet ID (in this case the data ID) and lastly 1 byte for a counter to indicate the number of data packet being transmitted, •30 bytes of payload data for both the photo and the RF measurements, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, and •1 end byte equivalent to 0xFF. Then, this content is interleaved and the output is transmitted. Figure 6.14: Data packet structure. Ground Station to PocketQube communication 55 When all these packets are received by the ground station the ACK DATA packet is sent. The structure of this packet depends on the number of received packets: •3 bytes of header formed by 2 bytes of PIN and 1 byte of telecommand ID, •As many bytes as needed in order to acknowledge each data packet received (one byte per packet). It can go up to 34 bytes, and in case of not enough, 2 ACK DATA packets will be needed, •4 bytes of a Unix time timestamp, •6 bytes corresponding to the Reed Solomon parity bytes for the error correction, and •1 end byte equivalent to 0xFF. Then, this content is interleaved and the output is transmitted. In this packet structure, padding might be added if the number of ACK bytes is not enough to construct a packet with a length multiple of 16. 6.4. Conclusions In this chapter, the communication between the ground segments and the PocketQube was discussed. The satellite sends a beacon every minute, which is received and stored by ground stations globally. Telecommands can be sent from the UPC NanoSatLab GS in Barcelona to request data transmission or perform specific actions. Moreover, to optimize packet transmission, ACKs were eliminated, and only NACKs are sent when errors are detected. Regardless, for payload data, a final packet is sent containing information on received and missed packets to ensure an uninterrupted payload data transmission. Furthermore, the maximum packet size is determined as 48 bytes, considering the LoRa configuration with a spreading factor of 11 and a bandwidth of 125 MHz. Overall, this chapter provided a detailed explanation of the different structures for all types of packets sent between the UPC NanoSat Lab TinyGS ground station and the PQ (uplink telecommands and downlink data packets). 62 Design and Performance Analysis of a LoRa communication system for PocketQubes •Lightweight and binary transport: This protocol is lightweight and uses a binary format, making it straightforward to implement on the client side. It is particularly suitable for connecting small remote devices. •Minimized overhead: With small headers, this protocol minimizes overhead, making it an excellent choice when bandwidth and power consumption are limited. This is the reason why it outperforms HTTP in data transfer efficiency. •Bi-directional communication: This protocol enables bi-directional communication between devices and the cloud, simplifying the broadcasting of messages to subscribers. •Scalability: The protocol is capable of connecting millions of IoT devices, making it highly scalable. •Reliable message delivery: The protocol offers three defined levels of quality of service ensuring reliable message delivery.: –0 (at most once) often called ”fire and forget”, where the publisher only sends a message and the subscriber might or might not receive it. There is no delivery warranty provided, but it guarantees a best-effort delivery. –1 (at least once), the publisher sends a message and if it does not receive an acknowledgement (a PUBACK) in a specified timeout it resends the message. –2 (exactly once), the publisher only sends the message once and the subscriber only receives it once. It is considered the highest level of service but also the slowest one. In order to only send and receive a packet once, it is required a four-part verification between first the publisher and the broker and then between the broker and the subscriber. The four packets involved are published, publish received (PUBREC), publish released (PUBREL) and publish complete (PUBCOMP) •Support for unreliable networks: This protocol can operate effectively in unreliable network environments, maintaining connectivity even in challenging conditions. •Security: The protocol supports TLS encryption and authentication, as well as protocols like OAuth, providing enhanced security measures. Some of the disadvantages are the ones listed below: •Limited native support for data formats and semantics: The protocol does not offer a built-in mechanism for encoding or decoding data. Consequently, there is a need to define and gain approval from clients, and the broker for a data structure and protocol logic on top of MQTT. •Dependency on a centralized architecture: The centralized nature of the architecture creates a reliance on the broker so it becomes a potential bottleneck. Moreover, in the event of a broker failure, clients experience a loss of communication. Software 63 7.2.2.2. TinyGS network architecture The TinyGS network architecture is shown in Figure 7.4 and extracted from [29]. The protocol used is MQTT with QoS 0 to provide straightforward communication between the multiple ground stations and the subscribers interested in the telemetry received. The overall architecture can be characterized by an Eclipse Mosquitto (an open-source MQTT broker) connected to a Node-RED cloud server, which, in turn, establishes connections with various modules. These modules encompass the decoder, the database, the Telegram bot, and the REST API responsible for the programmatic API and the web app. Figure 7.4: TinyGS network architecture. Image from [28]. The ground stations, acting as publisher clients, transmit the packets they receive to the MQTT broker. Upon configuring a new station, it sends a topic to identify itself along with its configuration. Subsequently, it periodically sends keep-alive messages to provide realtime updates on its status to the server. Access to the MQTT server is restricted for ground stations, allowing them to only publish information specific to their station and receive only relevant messages, thus preventing the overloading of the MQTT broker. This approach minimizes traffic, and eliminates the need for a massively scaled cloud server. The MQTT broker (MQTT server in Figure 7.4) is in charge of the communication between the ground stations and the Node-RED cloud server (the subscriber client). Its function is to receive all the telemetry packets and then decide where to send them depending on their topics. In this architecture, there is only one subscriber but topics are still being used 64 Design and Performance Analysis of a LoRa communication system for PocketQubes since they provide organization, flexibility, scalability, and modularity to the communication system. Furthermore, it allows for future expansion, filtering of messages, and easy integration of additional subscribers if needed. Then, the processing is done in the Node-RED cloud server. Node-RED is a platform which presents a visual programming environment for the implementation of event-driven data flows. In this architecture, the server behaves as a central hub receiving MQTT messages, processing their data, and then interacting with the other modules. Upon reception of the MQTT broker messages, the server forwards them to the decoder. This module then decodes the content of the telemetry packets considering the different packet structures from each satellite (e.g., Kaitai). Once the information is transformed into a user-friendly format (as in the example in Figure 7.5 (b)), it is subsequently transmitted back to the server. (a) Encoded data. (b) Decoded data. Figure 7.5: GaoFen-7 telemetry packet. Images from [27]. Software 65 Afterwards, the server sends the decoded data to the database module, to the Telegram bot, and to the REST API. In the database module, meaningful information is stored. Within the Telegram bot module, the decoded information received is shared back with the user of the corresponding ground station (the one which received the packet) in a private chat. Additionally, the information is forwarded to the global Telegram channel known as ”tinyGS telemetry”. And finally, the REST API is in charge of the interaction between the Node- RED and the external systems, in this case, the programmatic API and the web app. This interaction is based on requests such as retrieving data or updating system configurations. Due to the nature of this open and fully educational project, encryption and data security are not issues to be addressed 7.2.2.3. TinyGS transmission and reception logic Regarding the transmission, the TinyGS source code was modified in order to also be capable of transmitting the desired telecommands to the PQ. There is no need for a flowchart for the transmission and reception logic since it is very simple. The ground station is always in RX state and whenever a telecommand needs to be sent, it is written in the TinyGS console (this console is shown in the Results section) and then it is transmitted. Finally, once this telecommand is sent, the module goes back to RX mode. 7.3. Conclusions In conclusion, the PocketQube communication software utilizes a multithread architecture implemented with FreeRTOS, allowing for the integration and coordination of multiple subsystems. The software is programmed in C language using STM32CubeIDE, and the Semtech SX1262 transceiver is managed by the STM32 microcontroller. The SX1262 Library is crucial for seamless integration and control of the transceiver, while the Reed Solomon Coding for glyphs library is used for the Reed-Solomon error correction. The Communication State Machine provides a structured approach to handling different communication states, such as RX, TX, RX ERROR, RX TIMEOUT, TX TIMEOUT, and LOWPOWER. This state machine ensures the proper flow of communication and allows for efficient handling of data packets. The transmission and reception flowchart summarises the process of receiving telecommands, checking their validity, and executing corresponding actions or transmitting the requested data. On the ground station side, the TinyGS communication software is implemented on an ESP32 chip using C++ language. Moreover, the same library for the Reed Solomon as in the PQ software is used at the ground station. The TinyGS network architecture consists of the MQTT broker, Node-RED cloud server, and various modules for decoding telemetry, managing databases, implementing a Telegram bot, and providing a REST API. Regarding the transmission and reception logic, the ground station is always in the RX state transitioning to the TX state only upon manual request and then, after transmitting, it returns to the RX state. In summary, these technologies enable efficient and reliable communication between the PocketQube satellite and the ground station, facilitating data transmission, reception, and execution of telecommands. CHAPTER 8. DEVELOPMENT SETUP In this chapter, the focus will be on the hardware used, providing a detailed description of the testing procedure for the code. The hardware components utilized in the study will be examined, highlighting their main functionalities. Additionally, a step-by-step guide will be presented, offering clear instructions on how to conduct the code testing. 8.1. TinyGS 8.1.1. Module The module used is the LILYGO ®TTGO-ESP32 LoRa32 V2 868/915MHZ [55] which has been selected among the ones supported by the TinyGS software. (a) LILYGO ®TTGO-ESP32 LoRa32 V2 868/915MHZ. (b) Monopole. Figure 8.1: TinyGS hardware. Image from [56]. This board has the following capabilities: •Cores: The ESP32 chip on the board features a dual-core Xtensa LX6 processor. •Type: It is based on the ESP32 system-on-chip (SoC). •Generation: ESP32 series, which is the second generation of Espressif’s IoT-focused microcontrollers. •RAM: 520 KB of SRAM for general use. •Flash: 4 MB for program storage and data. •Peripherals: LoRa Radio, GPIO, UART, SPI, and I2C ADC, WiFi and Bluetooth, OLED Display, SD Card Slot and micro USB. 67 68 Design and Performance Analysis of a LoRa communication system for PocketQubes 8.1.2. Setup In order to test the software in the ground station, this is the setup needed to follow: 1. Purchase an SX1262 [58] 868MHz module compatible with the project. The ones supported at the moment are: (a) Heltec WiFi LoRa 32 V1 (433MHz 863-928MHz versions). (b) Heltec WiFi LoRa 32 V2 (433MHz 863-928MHz versions). (c) TTGO LoRa32 V1 (433MHz 868-915MHz versions). (d) TTGO LoRa32 V2 (433MHz 868-915MHz versions). (e) TTGO LoRa32 V2 (Manually swapped SX1267 to SX1278). (f) T-BEAM + OLED (433MHz 868-915MHz versions). (g) T-BEAM V1.0 + OLED. (h) FOSSA 1W Ground Station (433MHz 868-915MHz versions). (i) ESP32 dev board + SX126X with crystal (Custom build, OLED optional). (j) ESP32 dev board + SX126X with TCXO (Custom build, OLED optional). (k) ESP32 dev board + SX127X (Custom build, OLED optional). The one used in this project is the TTGO LoRa32 V2 868-915MHz. 2. Join the TinyGS Telegram channel at the following link https://t.me/joinchat/ DmYSElZahiJGwHX6jCzB3Q. 3. Once in the Telegram general TinyGS channel, open a private chat with their bot @TinyGS personal bot to ask for the MQTT credentials as in the following figure. Figure 8.2: MQTT credentials. 4. Download the TinyGS uploader from this link https://github.com/G4lile0/ TinyGS/releases , select the port, and then flash the firmware. 5. The first time the board is flashed, it creates an AP called ”My TinyGS”. Connect to that network, then open a web browser, navigate to 192.168.4.1 and the TinyGS menu will show up. 6. Click on the button ”Configure parameters” and enter the following parameters specific to the ground station: Development Setup 69 Figure 8.3: TinyGS uploader. (a) Ground station name. (b) Password for this dashboard. (c) The WiFi SSID at which the TinyGS will be connected. (d) The password for the WiFi. (e) The latitude and longitude of the location where the ground station is placed. (f) The timezone of the location where the ground station is placed. (g) The MQTT user and password given by the TinyGS bot. (h) Select the board type used. (i) OLED Bright of the display on the board, recommended a value below 100. (j) Enable TX function in order to be able to send TC to the PocketQube. (k) Enable automatic tunning (when doing tests this function can be disabled, since it is only needed the communication between the PocketQube and TinyGS). (l) Disable test mode, all packets need to count as actual data. (m) For the board commented before, the template should be the following one: ”name”:”[868-915] TTGO LoRA 32 v2”,”aADDR”:60,”oSDA”:21,”oSCL”:22,”oRST” :16,”pBut”:0,”led”:22,”radio”:1,”lNSS”:18,”lDIO0”:26,”lDIO1”:33,”lBUSSY”:0,”lRST” :14,”lMISO”:19,”lMOSI”:27,”lSCK”:5,”lTCXOV”:0.0 In case of using another board, in this link https://github.com/G4lile0/ TinyGS/wiki/Board-templates there is a detailed explanation on how to create a template. (n) The initial radio configuration for the board should be the following: ”mode”:”LoRa”,”freq”:868,”bw”:125.0,”sf”:11,”cr”:5,”sw”:18,”pwr”:5,”cl”:120,”pl”:8, ”gain”:0,”crc”:true,”fldro”:1,”sat”:”Norbi”,”NORAD”:46494 (o) Leave advanced parameters blank. 7. Clone this repository https://github.com/juliatribo/TinyGS and flash in the board using PlatformIO. 70 Design and Performance Analysis of a LoRa communication system for PocketQubes 8. Connect the PC to the same WiFi configured in the TinyGS and wait for the ground station to start. Once the TinyGS has been configured it will show an IP on the display. Open a web browser and navigate to the given IP. 9. Finally, on the website click on the station dashboard. Introduce the user: admin and the password configured before. Then, the terminal of the ground station will show up and the test can begin. 8.2. PocketQube 8.2.1. On Board Computer - Transceiver connection The MCU used for the OBC-COMMS is STM32L476RG [57]. This MCU family is chosen because STM32 are characterised by being ultra-low power microcontrollers and power saving is crucial for the satellite. The pinout is attached in Annex D. Figure 8.4: STM32L476RG. Image from [57]. This board has the following capabilities: •Core: The STM32L476RG has an ARM Cortex-M4 core. •Type: Microcontroller Development Board. •Generation: STM32L4 Series of ultra-low-power MCUs. •Flash Memory: 1 MB for general use. •RAM: 128 KB for program and data storage. •Peripherals: GPIO, UART, SPI, I2C, USB, ADC, DAC, Timers, DMA, RTC, and more. Development Setup 71 8.2.2. Transceiver module The PoquetQube transceiver module used is the Semtech SX1262 [58]. The pinout is attached in Annex C. (a) Semtech SX1262. (b) Monopole. Figure 8.5: Transceiver hardware. Image from [59]. This module has the following characteristics: •Type: It is a LoRa transceiver chip. •Generation: The SX1262 is part of Semtech’s SX12xx series of LoRa transceivers. •Peripherals: SPI (to communicate to an external microcontroller). •Features: Error correction, packet handling (Cyclic Redundancy Check (CRC)). The state machine of the SX1262 transceiver is shown in Figure 8.6 . The different available states are: •Startup: This state is entered at the power-up and also after a reset. At this point, the sleep state controls the chip and the BUSY pin is set to high. Then, when the digital voltage and RC clock are available, the chip control is given to the CPU and the BUSY pin is set to low which means that commands can be received. •Calibrate: This state is called in case of POR (Power On or Reset) or calling the calibration command. Then it calibrates internal oscillators, with the corresponding reference oscillators, the PLL and the reception pins. •SLEEP mode: In this state, most of the radio internal blocks are powered down or in low power mode. •Standby (STDBY) Mode: This mode works at a reduced power consumption and it is the state in which the chip is configured before going to TX or RX mode. 78 Design and Performance Analysis of a LoRa communication system for PocketQubes 9.1.3. TLE As previously commented in the Telecommands section, this type of telecommand is composed of 5 packets. In Figure 9.6, all five of them are shown first with the Reed Solomon encoding and then with both the Reed Solomon and the interleaving. The common headers of the packets contain the following information: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x0A: This byte is the telecommand ID for the TLE case. Following the header bytes, the TLE data starts. Given the fact that the orbit is still to be assigned, the TLE provided by the packets is the one corresponding to the FLOCK-1C-8 orbit (which is one of the orbits used in the data budget study). And finally, after the 34 bytes of TLE data, the 4 bytes UNIX timestamp is added (but it is not shown in the image). Figure 9.6: TLE telecommand sent. Once again, this packet has no reply from the PocketQube, therefore a breakpoint will be placed in the TLE switch case. As it is seen in Figure 9.7, the breakpoint is reached as a result of the proper decoding and processing of the received packet. Then, the TLE data from the first and second packets will be stored in the TLE line 1 address of PocketQube flash memory, the third packet will be split between both TLE line 1 and 2 addresses and finally packets 4 and 5 will be stored in the TLE line 2 address. Figure 9.7: TLE telecommand processed in the PQ. Results 79 9.1.4. ADCS CALIBRATION As seen in the Telecommands section, the ADCS CALIBRATION telecommand is formed by 3 packets. In Figure 9.8, all of them are shown first with the Reed Solomon encoding and then with both the Reed Solomon and the interleaving. The common headers of the packets contain the following information: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x0B: This byte is the telecommand ID for the ADCS CALIBRATION case. •The last header byte is not the same in each packet since it is the ADCS packet counter which goes from 0x00 to 0x02. Following the header bytes, the ADCS calibration data starts. For the ADCS calibration data, random bytes have been used in order to test it. And finally, after the 34 bytes of TLE data, the 4 bytes UNIX timestamp is added (but it is not shown in the image). Figure 9.8: ADCS CALIBRATION telecommand sent. Once again, this packet has no reply from the PocketQube, therefore a breakpoint will be placed in the ADCS CALIBRATION switch case. As it is seen in Figure 9.9, the breakpoint is reached, thus the packet is properly decoded and processed. Then, all the packets’ data will be stored in the calibration address of PocketQube flash memory. Figure 9.9: ADCS CALIBRATION processed in the PQ. 80 Design and Performance Analysis of a LoRa communication system for PocketQubes 9.1.5. SEND DATA From the first packet shown in Figure 9.10, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x14: This byte is the telecommand ID from the SEND DATA case. •0x00: This byte informs the PocketQube if the picture must be big or small. •0x00 0x03 0x83: These 4 bytes correspond to the timestamp in UNIX time. •0x1E 0x19 0xDC 0x63 0x53 0xC4: These last bytes represent the Reed Solomon parity bytes. The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.10: SEND DATA telecommand sent. Since this packet has a reply from the PocketQube, the test of the PocketQube decoding and processing will be performed by analysing the received data at the ground station console or at the TinyGS web page, which is examined in the following section, ”Downlink packets”. 9.1.6. SEND TELEMETRY From the first packet shown in Figure 9.11, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x15: This byte is the telecommand ID from the SEND TELEMETRY case. •0x00 0x00 0x03 0xB1: These 4 bytes correspond to the timestamp in UNIX time. •0xE7 0x17 0xBA 0xFC 0x1E 0xC4: These last bytes represent the Reed Solomon parity bytes. Results 81 The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.11: SEND TELEMETRY telecommand sent. Since this packet also has a reply from the PocketQube, the test of the PocketQube decoding and processing will be performed by analysing the received data at the ground station console or at the TinyGS web page, which is examined in the following section, ”Downlink packets” as well. 9.1.7. STOP SENDING DATA From the first packet shown in Figure 9.12, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x16: This byte is the telecommand ID from the STOP SENDING DATA case. •0x00 0x00 0x03 0xCC: These 4 bytes correspond to the timestamp in UNIX time. •0xB4 0xE2 0xB5 0x4A 0xE3 0x4A: These last bytes represent the Reed Solomon parity bytes. The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.12: STOP SENDING DATA telecommand sent. 82 Design and Performance Analysis of a LoRa communication system for PocketQubes 9.1.8. CHANGE TIMEOUT From the first packet shown in Figure 9.13, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x17: This byte is the telecommand ID from the CHANGE TIMEOUT case. •0x00 0xC8: These bytes correspond to the receiving timeout in milliseconds. In this case, the timeout is requested to be changed to a value of 200 ms. •0x64 0x74 0x86 0x72: These 4 bytes correspond to the timestamp in UNIX time. •0x6A 0xFC 0x53 0x36 0x12 0x2F: These last bytes represent the Reed Solomon parity bytes. The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.13: CHANGE TIMEOUT telecommand sent. This packet neither has a reply from the PocketQube, so a breakpoint will also be used. In figure 9.14, it is shown how the breakpoint of the CHANGE TIMEOUT switch case has been reached, therefore the receiving and decoding have been successful. Moreover, it is also shown how the timeout is stored in the corresponding PocketQube flash address. Figure 9.14: CHANGE TIMEOUT processed in the PQ. Results 83 9.1.9. ACTIVATE PAYLOAD From the first packet shown in Figure 9.15, the one with the Reed Solomon applied, the following information can be extracted from the header: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x1E: This byte is the telecommand ID for the ACTIVATE PAYLOAD case. After the header, 30 bytes of payload data have been added followed by the 4 bytes UNIX timestamp and the 6 parity bytes from Reed Solomon encoding (which are not appreciated in figure 9.15). For the payload data, random bytes have been used to test it. The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.15: ACTIVATE PAYLOAD telecommand sent. This packet neither has a reply from the PocketQube, so a breakpoint will also be used. In figure 9.16, it is shown how the breakpoint of the ACTIVATE PAYLOAD switch case has been reached, therefore the receiving and decoding have been successful. Moreover, it is also shown how the information related to the payload is stored in the corresponding PocketQube flash addresses. Figure 9.16: ACTIVATE PAYLOAD processed in the PQ. 84 Design and Performance Analysis of a LoRa communication system for PocketQubes 9.1.10. SEND CONFIG From the first packet shown in Figure 9.17, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x28: This byte is the telecommand ID from the CHANGE TIMEOUT case. •0x64 0x74 0x87 0x10: These 4 bytes correspond to the timestamp in UNIX time. •0x10 0xB6 0x5A 0xA8 0xC3 0xC9: These last bytes represent the Reed Solomon parity bytes. The second and the last packet (the one that is actually sent) are the interleaved version of the first packet. Figure 9.17: SEND CONFIG telecommand sent. Since this packet also has a reply from the PocketQube, the test of the PocketQube decoding and processing will be performed by analysing the received data at the ground station console or at the TinyGS web page, which is examined in the following section, ”Downlink packets” as well. 9.1.11. UPLINK CONFIG From the first packet shown in Figure 9.18, the one with the Reed Solomon applied, the following information can be extracted: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •18 random bytes of configuration data. •0x64 0x82 0xFB 0x28: These 4 bytes correspond to the timestamp in UNIX time. •0x7F 0x5A 0xBE 0x53 0xCB 0x92: These last bytes represent the Reed Solomon parity bytes. Results 85 The second and the last packet (the one that is actually sent) shown in Figure 9.18 correspond to the interleaving of the first packet. Figure 9.18: UPLINK CONFIG telecommand sent. As previously explained, this packet neither has a reply from the PocketQube, so a breakpoint will be used again. In figure 9.19, it is shown how the breakpoint of the UPLINK CONFIG switch case has been reached, hence the receiving and decoding have been successful. Furthermore, it is also shown how the information related to the configuration is stored in the corresponding PocketQube flash addresses. Figure 9.19: UPLINK CONFIG processed in the PQ. 86 Design and Performance Analysis of a LoRa communication system for PocketQubes 9.2. Downlink packets The downlink packets are received by the TinyGS ground station and then decoded and presented in its terminal. The TELEMETRY and CONFIG packets follow the same global structure based on adding a 4 bytes UNIX timestamp at the end of the data along with the 6 parity bytes of Reed Solomon, and finally, padding (till it reaches a multiple of 16 Bytes) in order to properly interleave it. However, the DATA packets are not encoded because the ground station was not able to receive as many packets in a row while also decoding them. 9.2.1. Telemetry packet When the SEND TELEMETRY TC is sent by the ground station, the PocketQube receives it, processes it and then sends in a downlink packet the telemetry as in Figure 9.20. Then, the TELEMETRY received packet needs to be decoded by the TinyGS. It has the same encoding as the uplink packets, thus the inverse process needs to be done. As it can be seen in Figure 9.20, the received packet is first deinterleaved and after, the Reed Solomon is decoded. With Reed Solomon, the potential errors are corrected. Considering 6 bytes of Reed Solomon as in this case, up to three bytes can be corrected (since 2 bytes are needed to correct 1 byte) or 6 errors can be detected, but not corrected. In this case, a couple of errors have been forced and properly corrected as seen in in Figure 9.20 (the bytes surrounded by a green circle). From the TELEMETRY packet in Figure 9.20, the following information is extracted: •0x74: This byte corresponds to the mission ID. •0x72: This byte corresponds to the PocketQube ID. •0x15: This last header byte represents the ID of the packet which in this case is the one corresponding to TELEMETRY. After the header, there are 29 bytes of telemetry followed by the 4 bytes UNIX timestamp. The telemetry data in the packet corresponds to random bytes which have been hardcoded in the PocketQube code to test it. Figure 9.20: Telemetry packet asked and received by the tinyGS. Results 87 The received and decoded packet is sent to the MQTT broker to store it in the TinyGS database, then sent to the telegram bot and finally added to the TinyGS web app. In Figure 9.21, the packet received is displayed on the TinyGS web page. Note that this packet is classified as a Norby packet and it is supposedly located below New Zealand which are false statements. This is because the Kaity structure of the NanoSatLab PocketQube has still not been sent to the TinyGS team, so the TinyGS decoder does not know how to interpret the information provided in the packet. Figure 9.21: Telemetry packet decoded on the TinyGS web page. In case of not being able to properly receive the telemetry, a NACK packet is sent to inform the satellite that a retransmission is needed. To test it, a CRC error has been forced. In Figure 9.22, it is shown how when the TinyGS is not able to retrieve the telemetry data, it sends a NACK TELEMETRY packet to inform the PocketQube that a retransmission is required. The NACK TELEMETRY packet in Figure 9.22 follows the following structure: •0xC8 0x9D: These two bytes correspond to the PIN ID. This pin needs to be correct, otherwise, the satellite will not process the telecommand. •0x19: This byte is the telecommand ID from the NACK TELEMETRY case. •0x64 0x74 0xC4 0x95: These 4 bytes correspond to the timestamp in UNIX time. •0x85 0x9C 0x9C 0x47 0xD4 0x4E: These last bytes represent the Reed Solomon parity bytes. 94 Design and Performance Analysis of a LoRa communication system for PocketQubes CONCLUSIONS AND FUTURE WORK 9.4. Conclusions In conclusion, this final degree project has successfully designed and implemented a LoRa communications link between a PocketQube developed at the NanoSat Lab and a TinyGS ground station. The choice of LoRa technology was driven by its compatibility with satellite communications. To optimize the performance of the link, the following parameters were selected, first, a coding rate C/R = 4/5 was chosen to maximize data encoding efficiency, secondly, a spreading factor SF = 11 allowing transmission and reception within all possible inclinations, and finally a bandwidth of 125 kHz has been selected to reduce the noise power and transmission time. Concerning the frequency, given the Spanish frequency plan (EU863-870), 868 MHz was designated. On one hand, the link budget analysis revealed that the SNRs obtained were more than sufficient for an SX1262 receiver. In fact, the receiver has the capability to demodulate signals even with negative SNR values, indicating a robust performance. On the other hand, considering the data budget, it was found that the maximum amount of data that could be downloaded in one pass was suitable for small or highly compressed images. However, when larger or less compressed images were taken into account, the data budget proved to be insufficient. This highlights the need for further exploration and optimization to enable the efficient transfer of larger or less compressed data payloads. Furthermore, one of the significant challenges in PocketQube communications lies in the considerable losses due to the large distances involved. To mitigate this challenge, error correction codes (ECCs) were implemented. After considering various ECC options, it was concluded that convolutional codes, Reed Solomon codes, and interleaving offered the most effective solution. However, convolutional codes were eventually discarded due to the relatively large number of parity bytes they introduced, which was impractical given the limited size of the packets regarding SF11. As for Reed Solomon codes, the recommended values by the CCSDS committee could not be implemented for the same reason. Consequently, a decision was made to stipulate 6 fixed bytes of parity. In terms of interleaving, a 4x4 matrix-based approach was employed, thus packets must have a length multiple of 16 to allow for proper interleaving. Another challenge that emerged was the scarcity of available power, which affected the downlink. To address this obstacle, a more efficient definition of the COMMS state machine was devised. Power consumption was reduced by constantly alternating between the LOWPOWER and RX states, rather than remaining in RX mode continuously, which resulted in significant energy savings. Lastly, the brief duration of the passes presented another challenge for PocketQube communications, limiting the amount of data that could be downloaded. This issue was mitigated by designing more accurate telecommands and optimizing their length to occupy the fewest bytes possible. This optimization facilitated shorter and more concise transmissions, allowing for more data to be transferred within the limited time frame of the passes. Additionally, ACKs (acknowledgements) were discarded, and only NACKs (negative ac- 95 96 Design and Performance Analysis of a LoRa communication system for PocketQubes knowledgements) are being sent in case of errors, to optimize the data transfer process. Once all the parameters for the link were determined, the development and integration of the software into both the PocketQube and the ground station were carried out. A LILYGO®TTGO-ESP32 LoRa32 V2 868/915MHZ module was utilized for the ground station. However, regarding the PocketQube hardware, due to unexpected delays in the arrival of the OBC and COMMS PCB, the tests were conducted using Commercial Off-The-Shelf (COTS) modules. Specifically, the NUCLEO-L476RG STM32 connected via SPI to the Semtech SX1262 transceiver, was employed for testing and evaluation (these modules were chosen since the PCB has the same MCU and transceiver chips). Subsequently, the software implementation was fulfilled, in both the ground station and the PocketQube modules. This temporary arrangement allowed for the verification and validation of the communication protocol, which included the design and structuring of packets. To summarize, the entire process involved the initial design and selection of appropriate technology and parameters, followed by an analysis of the link and data budgets, and lastly the design of the communications protocol which was implemented through the development of software for both the ground station and the PocketQube modules. Finally, a series of successful tests were conducted to verify the functionality of the implemented system. 9.5. Future Work Despite the considerable amount of work accomplished throughout this project, the limited timeframe prevented the testing of the developed system in the authentic environment of the PocketQube. Unfortunately, the delayed arrival of the OBC and COMMS PCB interfered with their integration, resulting in the use of alternative components for testing purposes. To ensure comprehensive evaluation, it is crucial that future investigations involve the implementation of the actual OBC and COMMS PCB, alongside the array patch antenna developed at the NanoSat Lab. Although the obtained results have successfully verified the functionality of the established link, there is scope for further analysis to enhance its robustness and reliability. Additionally, the efficiency of both the TinyGS ground station and the PocketQube codes could be improved. At the moment, the TinyGS ground station is currently experiencing significant RAM memory occupation, with approximately 94.7% already utilized. Similarly, the response time of the PocketQube code could be enhanced to enable faster data transmission and potentially facilitate the downloading of larger photos. Apart from the outcomes and conclusions derived from this project, it is evident that numerous avenues warrant continued exploration and investigation. Such as for example, the implementation of a constellation of picosatellites, enabling the interconnection of multiple PocketQubes. The benefits provided by these long-range, low-bandwidth Inter-Satellite Links (ISLs), are that the interconnected spacecraft could exchange crucial information such as position and attitude, facilitating the alignment of spacecraft and allowing the proper orientation of high-bandwidth optical ISLs. Furthermore, these ISLs could facilitate the exchange and retrieval of scientific data, serving as a mechanism to download valuable information back to the ground even if the satellite has no direct contact with the ground station. BIBLIOGRAPHY [1] Pelton, J. N., Madry, S. (Eds.). (2020). Handbook of Small Satellites. Springer International Publishing. https://doi.org/10.1007/978-3-030-36308-6 xiii,5 [2] Janson, S. W. (2011). 25 Years of Small Satellites. In 25th Annual AIAA/USU Conference of Small Satellites. The Aerospace Corporation. [3] Nanosats database (2014). Available at: https://www.nanosats.eu/ xiii,6 [4] California Polytechnic’s PolySat Program, NASA, NOAA. ( October 2017) Basic Concepts and Processes for First-Time CubeSat Developers. California Polytechnic State University, San Luis Obispo (Cal Poly) CubeSat Systems Engineer Lab 5 [5] PocketQube. (2023, March 6). In Wikipedia. https://en.wikipedia.org/wiki/ PocketQube [6] Small satellite. (2023, May 31). In Wikipedia. https://en.wikipedia.org/wiki/ Small_satellite xvii,7 [7] Alba Orbital TU Delft and Gauss Srl. “The PocketQube Standard”. In: (June 2018) 7, 11 [8] S ,tefan Podaru. ”Design and Implementation of an Educational Open PocketQube Kit”. (June 2022) xiii,11,12,13 [9] Luis J. Contreras. “Mechanical design and analysis of nano- and pico-satellites and deployers”. In: (May 2022). 12,13 [10] SIGFOX 0G TECHNOLOGY BY UNABIZ. Sigfox. Available:https://www.sigfox. com/ 15 [11] LoRa Alliance®. Available: https://lora-alliance.org/ 16 [12] QUBIK. Libre Space Foundation (2023, May 20). Available: https://libre.space/ projects/qubik/ 7 [13] FOSSASat-1. El primer picosat´ elite en ´ orbita de Espa˜ na. (2023, May 20). https: //fossa.systems/es/nuestra-historia/ 7 [14] Sun-synchronous orbit. (2022, November 2). In Wikipedia. https://en. wikipedia.org/wiki/Sun-synchronous_orbit xiii,8 [15] Real Time Satellite Tracking N2YO.com - real time satellite tracking and predictions. Available at: https://www.n2yo.com/ (Accessed: 15 March 2023). 33,105 [16] Mekki, K., Bajic, E., Chaxel, F., Meyer, F. (2019). A comparative study of LPWAN technologies for large-scale IoT deployment. In ICT Express (Vol. 5, Issue 1, pp. 1–7). Elsevier BV. https://doi.org/10.1016/j.icte.2017.12.005 xvii,15,19 [17] 3GPP. Release 13. Accessed: June. 2023. [Online]. Available: https://www.3gpp. org/release-13 15 97 98 Design and Performance Analysis of a LoRa communication system for PocketQubes [18] FOSSASat-1. Spain’s first orbiting picosatellite. Fossa Systems. Available at: https: //fossa.systems/our-history/ (Accessed: 20 March 2023). 17 [19] Lacuna Constellation. eoPortal powered by eesa. Available at: https: //www.eoportal.org/satellite-missions/lacuna-constellation# lora-long-range-technology-in-space (Accessed: 20 March 2023). 17 [20] Sateliot Successfully Launched The GroundBreaker, the first-ever satellite under 5G Standard to Democratize IoT, via SpaceX Falcon 9. Sateliot. Available at: https://sateliot.space/en/news-sateliot-space/ sateliot-successfully-launched-the-groundbreaker-the-first-ever-sat ellite-under-5g-standard-to-democratize-iot-via-spacex-falcon-9/ (Accessed: 20 March 2023). 17 [21] Fernandez, L., Ruiz-de-Azua, J. A., Calveras, A., Camps, A. (2020). Assessing LoRa for Satellite-to-Earth Communications Considering the Impact of Ionospheric Scintillation. Page range. doi: 10.1109/ACCESS.2020.3022433 xiii,xvii,19,20,21 [22] A. A. Doroshkin, A. M. Zadorozhny, O. N. Kus, V. Y. Prokopyev, and Y. M. Prokopyev, “Experimental study of LoRa modulation immunity to Doppler effect in CubeSat radio communications,” IEEE Access, vol. 7, pp. 75721–75731, 2019 19 [23] RP002-1.0.1 LoRaWAN®Regional Parameters. LoRa Alliance. (February 20, 2020) 19 [24] Retreived from: https://www.itu.int/en/publications/ITU-R/pages/ publications.aspx?parent=R-REG-RR-2020&media=electronic [25] The standard for IOT messaging. MQTT. Available at: https://mqtt.org/ (Accessed: 17 March 2023). xiv,61 [26] (2022). Beginners Guide To The MQTT Protocol. Publisher XYZ. [27] Title: TinyGS Website: TinyGS URL: https://tinygs.com/ Accessed: May 23, 2023 xiii,xiv,23,64 [28] Title: tinyGS Publisher: GitHub URL: https://github.com/G4lile0/tinyGS Accessed: May 23, 2023 xiv,63 [29] Programarfacil. (2021, March 2). TinyGS: Software Defined Radio for Satellite Ground Stations [Video File]. Retrieved from https://www.youtube.com/watch? app=desktop&v=vxW2i9vy-O0&ab_channel=Programarfacil 63 [30] NanosatLab UPC. (n.d.). Ground Segment. Retrieved from https://nanosatlab.upc.edu/en/facilities-folder/ground-segment 22 [31] Park, H. (2018, November 21). FSSCat Assembly is Progressing. Retrieved from https://prs.upc.edu/2018/11/21/fsscat-assemble-is-progressing/ [32] Badia, M., Perez-Portero, A., Garcia, A. (2022, April). 4th Symposium on Space Educational Activities. Symposium conducted at Barcelona. xiii,22 BIBLIOGRAPHY 99 [33] PAE students. (2023, January) Final Design Report IEEE GRSS - Open PocketQube Kit 23 [34] Rop. PhD, K.V. Konditi, Dominic. (2012). PERFORMANCE ANALYSIS OF A RECTANGULAR MICROSTRIP PATCH ANTENNA ON DIFFERENT DIELECTRIC SUBSTRATES. International Institute for Science, Technology and Education (IISTE). 3. 7-14. 25 [35] Singh, Jaget Lohar, Fateh Sohi, B.S.. (2021). Design of Circular Polarized Patch Antenna for NaviC Receiver Applications. IOP Conference Series: Materials Science and Engineering. 1033. 012039. 10.1088/1757-899X/1033/1/012039. xiii,24 [36] Woo, Hyounggwan Khan, Arifur Masui, Hirokazu Cho, Mengu Miyakawa, Takehiro Fujita, Tatsuhito. (2014). Discharge Observation on Antenna Surface Radiating High-power Microwaves in Simulated Space Environment. TRANSACTIONS OF THE JAPAN SOCIETY FOR AERONAUTICAL AND SPACE SCIENCES, AEROSPACE TECHNOLOGY JAPAN. 12. 11-19. 10.2322/tastj.12.11. xiii,24 [37] Mr. Navneet Kumar , Dr .Narinder Sharma, ”The Various Feeding Techniques of Microstrip Patch Antenna Using HFSS,” SSRG International Journal of Electronics and Communication Engineering, vol. 6, no. 6, pp. 23-29, 2019. Crossref, https://doi.org/10.14445/23488549/IJECE-V6I6P106 24 [38] FR-4. (2022, September 4). In Wikipedia. https://en.wikipedia.org/wiki/ FR-4 25 [39] (08/2022) Recommendation ITU-R P.676-13 ”Attenuation by atmospheric gases and related effects”, P Series Radiowave propagation xiii,28,29 [40] (08/2022) Recommendation ITU-R P.372-16 ”Radio noise” P Series Radiowave propagation [41] E. G. Njoku and E. K. Smith, “Microwave antenna temperature of the Earth from geostationary orbit,” Radio Sci., vol. 20, no. 3, pp. 591–599, May 1985 30 [42] Semtech Corporation, ”LoRa™Modulation Basics.” AN1200.22. May 2nd, 2023. Retrieved on May 31, 2023 [43] The things network organization. LoRaWAN®Regional Parameters. Retrieved from https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/ xvii,43 [44] Orbitron. Version 3.71. Sebastian Stoffy. 2001-2005 xiii,35 [45] de Baynast, A., Bohge, M., Willkomm, D., Gross, J. (2010). Physical Layer Modeling. In Modeling and Tools for Network Simulation (pp. 135–172). Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-642-12331-3_9 xiii,39 [46] Ab. Karim, I., Mohammed Almawgani, A. K. H., Mohd Salleh, M. F. (2012). Performance Comparison Between Low–Density Parity–Check And Reed–Solomon Codes Using Wireless Image Transmission System. In Jurnal Teknologi. Penerbit UTM Press. https://doi.org/10.11113/jt.v50.167 xiii,40 [47] MIT. ”Convolutional Coding.” MIT 6.02 DRAFT Lecture Notes. Last update: October 4, 2010. xiii,40 [48] Electronics Desk. Interleaving in communication. https://electronicsdesk. com/interleaving.html. Last accessed 1 June 2023 xiii,41,42 [49] Henry Minsky. (1991-2009). Reed Solomon Coding for glyphs. Retrieved from http://rscode.sourceforge.net 57,61 [50] Recommendation for Space Data System Standards: TM Synchronization and Channel Coding, CCSDS 131.0-B-4, Blue Book, April 2022 40 [51] Ahmed, Mahdi. (2009). Negative Acknowledgement-Based ARQ Protocol Efficiency in Unicast Data Networks. The University Researcher Journal, Ibb University. 43 [52] Daniel Herencia Ruiz. ”Design and Implementation of a Communications System for a PocketQube based on LoRa”. (June 2022) xiv,58,73 [53] Title: SX1262 CAD source code Publisher: Semtech URL: https: //semtech.my.salesforce.com/sfc/p/#E0000000JelG/a/2R000000HSjq/ IWB1D0L.WokKlcLJ1BKoTwrt6qq9flIqjkQQdl8574A Accessed: June 1st, 2023 57 [54] Title: libcorrect Publisher: GitHub URL: https://github.com/quiet/libcorrect Accessed: June 1st, 2023 57,61 [55] LilyGO. (n.d.). LilyGO TTGO LoRa32 V2.0 433/868/915Mhz ESP32 LoRa OLED. Retrieved May 30, 2023, from http://www.lilygo.cn/products.aspx?TypeId= 50060&FId=t3:50060:3 6,67 [56] AliExpress (n.d.). LILYGO®TTGO-ESP32-Paxcounter LoRa32 V2.1. Retrieved May 30, 2023, from https://es.aliexpress.com/item/1005003090411881.html? pdp_npi=2 xiv,67 [57] STMicroelectronics. (n.d.). NUCLEO-L476RG - STM32 Nucleo-64 development board. Retrieved from https://www.st.com/en/evaluation-tools/ nucleo-l476rg.html xiv,6,12,70 [58] Semtech. (n.d.). SX1262 - LoRa Connect™Long Range Low Power LoRa®. Retrieved May 30, 2023, from https://www.semtech.com/products/wireless-rf/ lora-connect/sx1262 xiv,xvii,6,32,68,71,72 [59] Semtech Corporation. (n.d.). SX1261MB2BAS. Retrieved May 30, 2023, from https: //www.mouser.es/ProductDetail/Semtech/SX1261MB2BAS?qs=qSfuJ [60] Siegfried W., Janson. “25 Years of Small Satellites”. T´ ıtol de la revista. volum(numero), pagina1–paginaN. (Any publicaci´ o): pagina1–paginaN. xiv,71 APPENDICES APPENDIX A. CHIRP SPREAD SPECTRUM CSS as its own name implies, is a spread spectrum technique which uses wideband linear frequency-modulated chirp pulses in order to encode information. Given that wideband is utilized, resistance in multi-path fading is presented (even in low power). Moreover, it is also immune to the Doppler effect which in satellite communications is a crucial asset. These chirps correspond to sinusoidal signals which increase or decrease in frequency depending on time as seen in Figure A.1. Figure A.1: A linear frequency modulated up-chirp in the time domain. The chirp shown in Figure A.1, is a basic up-chirp which goes from minimum to maximum frequency. This type of chirp is also represented in the first 6 chirps from Figure A.2. The following 2 chirps are denominated down-chirps since the frequency goes from the maximum to the minimum. This observed sequence of 6 up-chirps followed by 2 downchirps is usually used to indicate the start of a transmission. Figure A.2: Start of a CSS transmission. 103 Figure D.3: Right side Arduino-compatible headers. D.2. Morpho headers These headers give access to all STM32 pins. Figure D.4: Left side morpho headers. Figure D.5: Right side morpho headers. APPENDIX E. POCKETQUBE CODE Below are attached the comms.c most important functions from the PocketQube code. This file corresponds to the main of the COMMS thread. First of all, the void function corresponding to the COMMS state machine: void COMMS_StateMachine( void ) { /* Target board initialization*/ BoardInitMcu(); BoardInitPeriph(); /* Radio initialization */ RadioEvents.TxDone = OnTxDone; // standby RadioEvents.RxDone = OnRxDone; // standby RadioEvents.TxTimeout = OnTxTimeout; RadioEvents.RxTimeout = OnRxTimeout; RadioEvents.RxError = OnRxError; RadioEvents.CadDone = OnCadDone; /* Timer used to restart the CAD */ TimerInit(&CADTimeoutTimer, CADTimeoutTimeoutIrq); TimerSetValue(&CADTimeoutTimer, CAD_TIMER_TIMEOUT); /* App timmer used to check the RX’s end */ TimerInit(&RxAppTimeoutTimer, RxTimeoutTimerIrq); TimerSetValue(&RxAppTimeoutTimer, RX_TIMER_TIMEOUT); Radio.Init(&RadioEvents); //Initializes the Radio configuration(); //Configures the transceiver //EventBits_t EventBits; for(;;) //The only option to end the state machine is killing COMMS thread (by the OBC) Radio.IrqProcess(); //Checks the interruptions switch(State) { case RX_TIMEOUT: { RxTimeoutCnt++; Radio.Standby(); State = LOWPOWER; break; } case RX_ERROR: 113 { RxErrorCnt++; PacketReceived = false; Radio.Standby(); State = LOWPOWER; break; } case RX: { if(PacketReceived == true) { if(Buffer[0]==0xC8) { //DEINTERLEAVE unsigned char codeword_deinterleaved[127]; int index = deinterleave(Buffer, BufferSize, codeword_deinterleaved); decoded_size = index-NPAR; //DECODE REED SOLOMON int erasures[16]; int nerasures = 0; decode_data(codeword_deinterleaved, decoded_size); int syndrome = check_syndrome(); /* check if syndrome is all zeros */ if (syndrome == 0) { // no errs detected, codeword payload should match message }else { //nonzero syndrome, attempting correcting errors int result = 0;//result 0 not able to correct, result 1 corrected result =correct_errors_erasures (codeword_deinterleaved, index, nerasures, erasures); } memcpy(decoded, codeword_deinterleaved,decoded_size); if (pin_correct(decoded[0], decoded[1])) { State = LOWPOWER; if (decoded[2] == TLE){ Stop_timer_16(); //This is not necessary, put here for safety if (!tle_telecommand){ //First TLE packet State = RX; telecommand_rx = true; if(tle_counter==3){ tle_telecommand = true; } tle_counter++; } else{//Is the last TLE packet (there are 2) tle_telecommand = false; State = LOWPOWER; //Line unnecessary telecommand_rx = false; tle_counter=0; } process_telecommand(decoded[2], decoded[3]); //Saves the TLE } if (decoded[2] == ADCS_CALIBRATION){ Stop_timer_16(); //This is not necessary, put here for safety if (!calibration_telecommand){ //First TLE packet State = RX; telecommand_rx = true; if(calibration_counter==1){ calibration_telecommand = true; } calibration_counter++; } else{//Is the last TLE packet (there are 2) calibration_telecommand = false; State = LOWPOWER; //Line unnecessary telecommand_rx = false; calibration_counter=0; } process_telecommand(decoded[2], decoded[3]); //Saves the calibration } else if (telecommand_rx){//Second telecommand RX consecutively if (decoded[2] == last_telecommand[2]){ //Second telecommand received equal to the first CHANGE THIS TO CHECK THE WHOLE TELECOMMAND. USE VARIABLE compare_arrays Stop_timer_16(); if ((decoded[2] == RESET2) || (decoded[2] == EXIT_STATE) || (decoded[2] == TLE) || (decoded[2] == ADCS_CALIBRATION) || (decoded[2] == SEND_DATA) || (decoded[2] == SEND_TELEMETRY) || (decoded[2] == STOP_SENDING_DATA) || (decoded[2] == CHANGE_TIMEOUT) || decoded[2] == ACK_DATA || decoded[2] == NACK_TELEMETRY || decoded[2] == NACK_CONFIG || decoded[2] == ACTIVATE_PAYLOAD || decoded[2] == SEND_CONFIG|| decoded[2] == UPLINK_CONFIG ){ telecommand_rx = false; process_telecommand(decoded[2], decoded[3]); } else { request_execution = true; State = TX; } } else if(decoded[2] == ACK){ //Order execution ACK Stop_timer_16(); request_counter = 0; request_execution = false; reception_ack_mode = false; telecommand_rx = false; process_telecommand(last_telecommand[2], last_telecommand[3]); State = RX; } else{//Second telecommand received different from the first State = TX; telecommand_rx = false; error_telecommand = true; Stop_timer_16(); } } else{//First telecommand RX memcpy(last_telecommand, decoded, BUFFER_SIZE); last_telecommand[0] = MISSION_ID; //To avoid retransmitting the PIN last_telecommand[1] = POCKETQUBE_ID; tle_telecommand = false; telecommand_rx = true; State = RX; Start_timer_16(); } } else{//Pin not correct. If pin not correct it is assumed that the packet comes from another source. The protocol continues ignoring it State = TX; error_telecommand = true; Stop_timer_16(); xEventGroupSetBits(xEventGroup, COMMS_WRONGPACKET_EVENT); } PacketReceived = false;// Reset flag } } else //If packet not received, restart reception process { if (CadRx == CAD_SUCCESS) { channelActivityDetectedCnt++; // Update counter RxTimeoutTimerIrqFlag = false; TimerReset(&RxAppTimeoutTimer); // Start the Rx’s’s Timer } else { TimerStart(&CADTimeoutTimer); // Start the CAD’s Timer } Radio.Rx(RX_TIMEOUT_VALUE); //Basic RX code State = LOWPOWER; if (reception_ack_mode){ reception_ack_mode = false; } } break; } case TX: { /* TO TEST TELECOMMANDS */ State = LOWPOWER; if (error_telecommand){ //Send error message uint8_t packet_to_send[] = {MISSION_ID,POCKETQUBE_ID,ERROR}; Radio.Send(packet_to_send,sizeof(packet_to_send)); Radio.Send(packet_to_send,sizeof(packet_to_send)); error_telecommand = false; }else if (request_execution){ //Send request for execute telecommand order Radio.Send(last_telecommand,3); //TEST ONLY SENDING ONE REQUEST (NORMALLY PACKETS ARE TX IN PAIRS Radio.Send(last_telecommand,3); //TEST ONLY SENDING ONE REQUEST (NORMALLY PACKETS ARE TX IN PAIRS request_counter++; reception_ack_mode = true; State = RX; Stop_timer_16(); Start_timer_16(); } else if (tx_flag){ uint64_t read_photo[12]; uint8_t transformed[DATA_PACKET_SIZE]; if (window_packet < WINDOW_SIZE){ if (nack_flag){ if (nack_counter < nack_size){ Read_Flash(PHOTO_ADDR + nack[nack_counter]*DATA_PACKET_SIZE, &read_photo, sizeof(read_photo)); decoded[3] = nack[nack_counter]; //Number of the retransmitted packet nack_counter++; }else{//When all packets have been retransmitted, we continue with the next one nack_flag = false; nack_counter = 0;; packet_number = 0; window_packet = WINDOW_SIZE; } }else { Read_Flash(PHOTO_ADDR + packet_number*DATA_PACKET_SIZE, &read_photo, sizeof(read_photo)); decoded[3] = packet_number; //Number of the packet packet_number++; } decoded[0] = MISSION_ID; //Satellite ID decoded[1] = POCKETQUBE_ID; //Poquetcube ID (there are at least 3) decoded[2] = SEND_DATA; memcpy(&transformed, read_photo, sizeof(transformed)); for (uint8_t i=4; i<DATA_PACKET_SIZE+4; i++){ decoded[i] = transformed[i-4]; } TimerTime_t currentUnixTime = RtcGetTimerValue(); uint32_t unixTime32 = (uint32_t)currentUnixTime; decoded[DATA_PACKET_SIZE+4] = (unixTime32 >> 24) & 0xFF; decoded[DATA_PACKET_SIZE+5] = (unixTime32 >> 16) & 0xFF; decoded[DATA_PACKET_SIZE+6] = (unixTime32 >> 8) & 0xFF; decoded[DATA_PACKET_SIZE+7] = unixTime32 & 0xFF; decoded[DATA_PACKET_SIZE+8] = 0xFF; //Final of the packet indicator window_packet++; State = TX; Radio.Send( decoded, DATA_PACKET_SIZE +9); vTaskDelay(pdMS_TO_TICKS(3000)); Radio.Send( decoded, DATA_PACKET_SIZE +9); }else{ tx_flag = false; packet_number = 0; send_data = false; window_packet = 0; State = RX; } } else if (beacon_flag){ uint8_t packet_to_send[] = {MISSION_ID,POCKETQUBE_ID,BEACON}; Radio.Send(packet_to_send,sizeof(packet_to_send)); beacon_flag = false; } break; } case TX_TIMEOUT: { State = LOWPOWER; break; } case LOWPOWER: default: if (error_telecommand || tx_flag){ State = TX; } else if (reception_ack_mode || tle_telecommand){ State = RX; } else if (telecommand_rx){ //We have received at least one telecommand if (request_execution ){ //In this case we have to TX request or wait for ACK if (request_counter >= 3){ //If 3 request have been sent, we send an error message request_execution = false; error_telecommand = true; telecommand_rx = false; State = TX; request_counter=0; Stop_timer_16(); }else if (protocol_timeout){ //TX another request execution protocol_timeout = false; State = TX; }else {//Iterate till 500 ms approx State = RX; } }else{//We want to Rx the second telecommand int r = 0; int col; int row; char block[BLOCK_ROW_INTER][BLOCK_COL_INTER]; while(q < size){ col = 0; for(col; col < BLOCK_COL_INTER && !end; col++){ row = 0; for(row; row < BLOCK_ROW_INTER && !end; row++){ if (q < size){ block[row][col] = codeword[q]; q++; } else{ end = true; } } } for(int t = 0; t < BLOCK_COL_INTER; t++){ for(int p = 0; p < BLOCK_ROW_INTER; p++){ codeword_interleaved[r] = block[t][p]; r++; } } } return size; } int deinterleave(unsigned char *codeword_interleaved , int size,unsigned char* codeword_deinterleaved ){ interleave(codeword_interleaved , size,codeword_deinterleaved); bool end = false; while(!end){ if( memcmp(codeword_deinterleaved[size-1], 0xFF, 1) != 0){ size--; } else{ size --; end = true; } } return size; } int encode (uint8_t* buffer, uint8_t* encoded, int packet_size) { //ENCODE REED SOLOMON unsigned char codeword[256]; /* Initialization the ECC library */ initialize_ecc (); srand(time(NULL)); // Initialization, should only be called once. int ML = packet_size + NPAR; encode_data(buffer, packet_size, codeword); codeword[ML] = 0xFF; //Final of the packet indicator ML++; //INTERLEAVE int size = interleave(codeword, ML, encoded); //add random errors uint8_t r3 = rand() % 256; int rloc3 = rand() % (size); encoded[rloc3] = r3; uint8_t r4 = rand() % 256; int rloc4 = rand() % (size); encoded[rloc4] = r4; return size; } APPENDIX F. GROUND STATION CODE F.1. Receiving Regarding the ground station code, the receiving process takes place at the Radio.cpp file and the principal functions are the ones explained next. First of all, the listen function which is in charge of receiving, decoding and sending packets to the MQTT server. It also sends the NACKs in case of an error or the ACK when all the data is received. uint8_t Radio::listen() { // check if the flag is set (received interruption) if (!received) return 1; // disable the interrupt service routine while // processing the data disableInterrupt(); // reset flag received = false; size_t respLen = 0; uint8_t *respFrame = 0; int16_t state = 0; PacketInfo newPacketInfo; status.lastPacketInfo.crc_error = 0; // read received data if (ConfigManager::getInstance().getBoardConfig().L_SX127X) { SX1278 *l = (SX1278 *)lora; respLen = l->getPacketLength(); respFrame = new uint8_t[respLen]; state = l->readData(respFrame, respLen); newPacketInfo.rssi = l->getRSSI(); newPacketInfo.snr = l->getSNR(); newPacketInfo.frequencyerror = l->getFrequencyError(); } else { SX1268 *l = (SX1268 *)lora; respLen = l->getPacketLength(); respFrame = new uint8_t[respLen]; state = l->readData(respFrame, respLen); newPacketInfo.rssi = l->getRSSI(); newPacketInfo.snr = l->getSNR(); 129 } // check if the packet info is exactly the same as the last one if (newPacketInfo.rssi == status.lastPacketInfo.rssi && newPacketInfo.snr == status.lastPacketInfo.snr && newPacketInfo.frequencyerror == status.lastPacketInfo.frequencyerror) { Log::console(PSTR("Interrupt triggered but no new data available. Check wiring and electrical interferences.")); delete[] respFrame; startRx(); return 4; } status.lastPacketInfo.rssi = newPacketInfo.rssi; status.lastPacketInfo.snr = newPacketInfo.snr; status.lastPacketInfo.frequencyerror = newPacketInfo.frequencyerror; // print RSSI (Received Signal Strength Indicator) Log::console(PSTR("[SX12x8] RSSI:\t\t%f dBm\n[SX12x8] SNR:\t\t%f dB\n[SX12x8] Frequency error:\t%f Hz"), status.lastPacketInfo.rssi, status.lastPacketInfo.snr, status.lastPacketInfo.frequencyerror); // initialize static variable with current time static auto lastTime = std::chrono::high_resolution_clock::now(); auto currentTime = std::chrono::high_resolution_clock::now(); //compute time since last packet received auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - lastTime); // update lastTime with current time for the next call lastTime = currentTime; if (state == ERR_NONE && respLen > 0) { // read optional data Log::console(PSTR("Packet received (%u bytes):"), respLen); uint16_t buffSize = respLen * 3 + 1; if (buffSize > 255) buffSize = 255; char *rx_str = new char[buffSize]; for (int i = 0; i < respLen; i++) { sprintf(rx_str + i * 3 % (buffSize - 1), "%02x ", respFrame[i]); if (i * 3 % buffSize == buffSize - 3 || i == respLen - 1) Log::console(PSTR("%s"), rx_str); // print before the buffer is going to loop back } //send_data ack if (send_data){ if (last_data_packet == 0){ //add the correct received packets to the ack_data vector ACK_DATA_TC[0] = 0xC8; ACK_DATA_TC[1] = 0x9D; ACK_DATA_TC[2] = 0x18; } int received_index = respFrame[3]+3; ACK_DATA_TC[received_index]=0x01; //ACK_DATA_TC[last_data_packet+3] = respFrame[3]; if (((respFrame[3] == 0x13)||( duration > std::chrono::minutes(1)))&& last_data_packet>0){ time_t currentUnixTime = time(NULL); uint32_t unixTime32 = (uint32_t)currentUnixTime; ACK_DATA_TC[23] = (unixTime32 >> 24) & 0xFF; ACK_DATA_TC[24] = (unixTime32 >> 16) & 0xFF; ACK_DATA_TC[25] = (unixTime32 >> 8) & 0xFF; ACK_DATA_TC[26] = unixTime32 & 0xFF; Log::console(PSTR("Received packets (%u bytes):"), sizeof(ACK_DATA_TC)); char *ack_rx_data = new char[buffSize]; uint8_t ack_data[sizeof(ACK_DATA_TC)]; memcpy(ack_data,ACK_DATA_TC,sizeof(ACK_DATA_TC)); for (int i = 0; i < sizeof(ACK_DATA_TC); i++) { sprintf(ack_rx_data + i * 3 % (buffSize - 1), "%02x ", ack_data[i]); if (i * 3 % buffSize == buffSize - 3 || i == sizeof(ACK_DATA_TC)-1) Log::console(PSTR("%s"), ack_rx_data); // print before the buffer is going to loop back } send_data = false; last_data_packet = 0; ConfigManager& configManager = ConfigManager::getInstance(); uint8_t telecomand_encoded[256]; int size = configManager.encode(ACK_DATA_TC, sizeof(ACK_DATA_TC), telecomand_encoded); sendTx(telecomand_encoded, size); delay(500); sendTx(telecomand_encoded, size); Log::console(PSTR("Sending ACK DATA!")); } last_data_packet ++; } else{ //read convolution decoded and deinterleaved uint8_t data_deinter[respLen]; memcpy(data_deinter,respFrame,respLen); char *rx_str_deinter = new char[buffSize]; deinterleave(data_deinter,respLen); //delete padding of interleaved int index = respLen; bool end = false; while(!end){ if(data_deinter[index-1]!=0xFF) index--; else{ index --; end = true; } } Log::console(PSTR("Packet deinterleaved (%u bytes):"), index); for (int i = 0; i < index; i++) { sprintf(rx_str_deinter + i * 3 % (buffSize - 1), "%02x ", data_deinter[i]); if (i * 3 % buffSize == buffSize - 3 || i == index - 1) Log::console(PSTR("%s"), rx_str_deinter); // print before the buffer is going to loop back } //read convolution decoded, deinterleaved and rs decoded Log::console(PSTR("Packet deinterleaved and rs decoded (%u bytes):"), index); char *rx_str_deinter_ders = new char[buffSize]; uint8_t data_deinter_ders[index]; memcpy(data_deinter_ders,data_deinter,index); decode_rs(data_deinter_ders,index); for (int i = 0; i < index; i++) { sprintf(rx_str_deinter_ders + i * 3 % (buffSize - 1), "%02x ", data_deinter_ders[i]); if (i * 3 % buffSize == buffSize - 3 || i == index - 1) Log::console(PSTR("%s"), rx_str_deinter_ders); // print before the buffer is going to loop back } //read data packet Log::console(PSTR("Packet data (%u bytes):"), index - NPAR); char *rx_data = new char[buffSize]; uint8_t packet_data[index - NPAR]; memcpy(packet_data,data_deinter_ders,index - NPAR); for (int i = 0; i < index - NPAR; i++) { sprintf(rx_data + i * 3 % (buffSize - 1), "%02x ", packet_data[i]); if (i * 3 % buffSize == buffSize - 3 || i == index - NPAR - 1) Log::console(PSTR("%s"), rx_data); // print before the buffer is going to loop back } memcpy(respFrame,packet_data,index - NPAR); respLen = index - NPAR; } if(send_config){ send_config = false; } if(send_telemetry){ send_telemetry = false; } // if Filter enabled filter the received packet if (status.modeminfo.filter[0] != 0) { bool filter_flag = false; uint8_t filter_size = status.modeminfo.filter[0]; uint8_t filter_ini = status.modeminfo.filter[1]; for (uint8_t filter_pos = 0; filter_pos < filter_size; filter_pos++) { if (status.modeminfo.filter[2 + filter_pos] != respFrame[filter_ini + filter_pos]) filter_flag = true; } // if the msg start with tiny (test packet) remove filter if (respFrame[0] == 0x54 && respFrame[1] == 0x69 && respFrame[2] == 0x6e && respFrame[3] == 0x79) filter_flag = false; if (filter_flag) { Log::console(PSTR("Filter enabled, doesn’t look like the expected satellite packet")); delete[] respFrame; startRx(); return 5; } } status.lastPacketInfo.crc_error = false; //String encoded = base64::encode(packet_data, index - NPAR); String encoded = base64::encode(respFrame, respLen); MQTT_Client::getInstance().sendRx(encoded, noisyInterrupt); } else if (state == ERR_CRC_MISMATCH) { // if filter is active, filter the CRC errors if (status.modeminfo.filter[0] == 0) { // packet was received, but is malformed status.lastPacketInfo.crc_error = true; String error_encoded = base64::encode("Error_CRC"); MQTT_Client::getInstance().sendRx(error_encoded, noisyInterrupt); } else { Log::console(PSTR("Filter enabled, Error CRC filtered")); delete[] respFrame; startRx(); return 5; } } delete[] respFrame; struct tm *timeinfo; time_t currenttime = time(NULL); if (currenttime < 0) { Log::error(PSTR("Failed to obtain time")); status.lastPacketInfo.time = ""; } else { // store time of the last packet received: timeinfo = localtime(¤ttime); String thisTime = ""; if (timeinfo->tm_hour < 10) { thisTime = thisTime + " "; }// add leading space if required thisTime = String(timeinfo->tm_hour) + ":"; if (timeinfo->tm_min < 10) { thisTime = thisTime + "0"; }// add leading zero if required thisTime = thisTime + String(timeinfo->tm_min) + ":"; if (timeinfo->tm_sec < 10) { thisTime = thisTime + "0"; }// add leading zero if required thisTime = thisTime + String(timeinfo->tm_sec); status.lastPacketInfo.time = thisTime; } noisyInterrupt = false; // put module back to listen mode startRx(); if (state == ERR_NONE) { return 0; } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed Log::console(PSTR("[SX12x8] CRC error! Data cannot be retrieved")); int16_t buffSize = respLen * 3 + 1; if(send_config){ NACK_CONFIG_TC[0] = 0xC8; NACK_CONFIG_TC[1] = 0x9D; NACK_CONFIG_TC[2] = 0x1A; time_t currentUnixTime = time(NULL); uint32_t unixTime32 = (uint32_t)currentUnixTime; NACK_CONFIG_TC[3] = (unixTime32 >> 24) & 0xFF; NACK_CONFIG_TC[4] = (unixTime32 >> 16) & 0xFF; NACK_CONFIG_TC[5] = (unixTime32 >> 8) & 0xFF; NACK_CONFIG_TC[6] = unixTime32 & 0xFF; Log::console(PSTR("Config not received, send NACK packet (%u bytes):"), sizeof(NACK_CONFIG_TC)); char *nack_rx_data = new char[buffSize]; uint8_t nack_data[sizeof(NACK_CONFIG_TC)]; memcpy(nack_data,NACK_CONFIG_TC,sizeof(NACK_CONFIG_TC)); for (int i = 0; i < sizeof(NACK_CONFIG_TC); i++) { sprintf(nack_rx_data + i * 3 % (buffSize - 1), "%02x ", nack_data[i]); if (i * 3 % buffSize == buffSize - 3 || i == sizeof(NACK_CONFIG_TC)-1) Log::console(PSTR("%s"), nack_rx_data); // print before the buffer is going to loop back } ConfigManager& configManager = ConfigManager::getInstance(); uint8_t telecomand_encoded[256]; int size = configManager.encode(NACK_CONFIG_TC, sizeof(NACK_CONFIG_TC), telecomand_encoded); sendTx(telecomand_encoded, size); delay(500); sendTx(telecomand_encoded, size); Log::console(PSTR("Sending NACK CONFIG!")); send_config=false;