Low-Cost Orientation Determination System for CubeSat Based Solely on Solar and Magnetic Sensors

CubeSats require accurate determination of their orientation relative to the Sun, Earth, and other celestial bodies to operate successfully and collect scientific data. This paper presents an orientation system based on solar and magnetic sensors that offers a cost-effective and reliable solution for CubeSat navigation. Solar sensors analyze the illumination on each face to measure the satellite’s orientation relative to the Sun, while magnetic sensors determine the Earth’s magnetic field vector in the satellite’s reference frame. By combining the measured data with the known ephemeris of the satellite, the satellite–Sun vector and the magnetic field orientation can be reconstructed. The orientation is expressed using quaternions, representing the rotation from the internal reference system of the satellite to the selected reference system. The proposed system demonstrates the ability to accurately determine the orientation of a CubeSat using only two sensors, making it suitable for installations where more complex and expensive instruments are impractical. Additionally, the paper presents a mathematical model of a low-cost CubeSat orientation system and a hardware implementation of the sensor. The technology, using solar and magnetic sensors, provides a reliable and affordable solution for CubeSat navigation, supporting the increasing sophistication of miniature payloads and enabling accurate satellite positioning in space missions.


Introduction
An important aspect of CubeSat operations is determining the satellite's orientation relative to the Sun, Earth, and other celestial bodies. The technology used in the development of CubeSat orientation sensors includes solar and magnetic sensors [1,2]. This information is necessary for spacecraft orientation [3,4], control, and collecting accurate scientific data [5]. The purpose of the solar sensor is to determine the coordinates of the satellite-Sun vector [6,7] in the reference frame associated with the satellite. This is achieved by processing photoelectric signals from solar sensors located on the six sides of the satellite [8,9].
Modeling shows that the precision of attitude determination can be better than 1 • . Furthermore, the Radio Aurora Explorer 3U CubeSat [10] demonstrated, back in 2014, that it is possible to obtain information about the satellite's position with accuracy better than 1 • (solar light) in orbit [11,12]. This is especially true when the satellite is on the sunny side, as multiple sensors are used for successful task execution. However, this determination is more difficult during eclipses [13]. Determining the orientation of CubeSat satellites remains a challenging task, as they are small and still lack active orientation and control systems [14,15]. Additionally, new miniature payloads for space-based missions are becoming increasingly complex and require accurate knowledge of a satellite's position.

Materials and Methods
This chapter presents a mathematical model of the orientation system and provides detailed descriptions of the hardware architecture of the sensors.

Theory of the Proposed Attitude Sensor
In this subchapter, a mathematical model based on the solar and magnetic sensors of the passive orientation system of the nanosatellite is constructed.
The solar and magnetic sensors are used to collect raw information about the CubeSat's orientation: the satellite-Sun vector and the magnetic field orientation. If the satellite's position in orbit is known, these data allow for the recovery of the satellite's attitude.
Solar sensors measure the orientation of the satellite relative to the Sun. These sensors measure the illumination of each face of the satellite, and the processing unit computes the direction of the satellite-Sun vector S [16,17]. Magnetic sensors are used to measure the Earth's magnetic field vector B in the satellite's reference frame.
If the ephemerides of the satellite are known, it is possible to determine the reference values of the magnetic field vector and the satellite-Sun vector from publicly available astronomical databases and models. By measuring the positions of the Sun and the value of the magnetic field using the satellite's sensors at a specific moment in time and comparing these data with real data, we obtain information about the satellite's position in the selected reference system. The attitude of a satellite can be conveniently expressed using quaternions. A quaternion is a mathematical object defined by four real numbers that represent a rotation in a three-dimensional space. The satellite's attitude is defined by a quaternion that rotates the internal satellite reference frame to align it with a selected reference frame (e.g., an inertial geocentric frame). In this work, the selected reference frame for attitude expression is J2000.
Both reference vectors B and S are expressed in the J2000 geocentric inertial coordinate system and denoted as Bj and Sj. The satellite's sensors measure these same vectors in coordinates related to the satellite and denoted as Bs and Ss. The position of the satellite is determined by a quaternion that aligns the satellite's coordinate system with the J2000 system. This quaternion is defined by the rotation that aligns two pairs of vectors: Bs, Ss, and Bj, Sj. This rotation is calculated in two steps. In the first step, a rotation that aligns the vectors Bs and Bj calculated by determining the direction vector of the rotation axis using Equation (1). This vector is equal to the normal vector to the plane formed by vectors Bs and Bj.
Then, the angle between vectors Bs and Bj is calculated using Equation (2): And a quaternion for the first rotation can be expessed in form: During this rotation, vector Bs is transformed into vector Bj, while vector Ss takes a new value Ss Equation (4): After the first rotation, vector Bs is transformed into vector Bj, and vector Ss takes on a new value, Ss .
In the second step, it becomes necessary to rotate vector Ss around the axis defined by vector Bj in order to align it with vector Sj. However, achieving perfect alignment is challenging due to measurement errors. The angles between the initial vectors Bs, Ss, Bj, and Sj are likely to differ, although they should ideally be the same in theory.
Therefore, a rotation of vector Bj is calculated to minimize the difference between the rotated vector Ss and vector Sj's norm. An optimization algorithm, such as the gradient descent method, can be employed to find the rotation angle that minimizes this difference. This is accomplished by defining a function f (α) that calculates the Euclidean difference between the rotated vector, Ss , and vector Sj. The rotation is determined by the rotation axis, which is equal to Bj, and the angle α, using Equation (5): where, rot (x,n,α) is the result of rotating the vector x by angle α around the axis n. Using the optimization algorithm, α is found that minimizes the value of the function. Now it is possible to calculate the second rotation quaternion, 'q2', using Equation (6): Finally, the quaternion expressing the orientation of the satellite is obtained by multiplying quaternions q1 and q2 using Equation (7): The result is verified in two steps. First, one calculates the triple product of vectors using Equation (8): dot(cross(quatrotate(q, Ss), Bj), Sj) where, dot is a dot (x,y) product operator, cross (x,y) is a cross product operator, quatrotate (q,x) is a function rotating a vector x according to the quaternion q. If the calculation is correct, the result should be close to zero (it means that the aligned vectors and vector Sj are on the same plane). The second verification step consists of comparing the vectors Bj and the rotated vector Bs using Equation (9): ||Bj − quatrotate(q, Bs)|| The result should also be close to zero.

Hardware Architecture
In this subchapter, the hardware architecture of the sensor connection to the microcontroller is implemented. An orientation determination system for CubeSats based on solar and magnetic sensors can be implemented using the following hardware architecture, which is shown in Figure 1: Finally, the quaternion expressing the orientation of the satellite is obtained multiplying quaternions q1 and q2 using Equation (7): The result is verified in two steps. First, one calculates the triple product of vect using Equation (8): where, dot is a dot (x,y) product operator, cross (x,y) is a cross product operator, quat tate (q,x) is a function rotating a vector x according to the quaternion q. If the calculat is correct, the result should be close to zero (it means that the aligned vectors and vec Sj are on the same plane). The second verification step consists of comparing the vectors Bj and the rota vector Bs using Equation (9):

|| , ||
The result should also be close to zero.

Hardware Architecture
In this subchapter, the hardware architecture of the sensor connection to the mic controller is implemented. An orientation determination system for CubeSats based on solar and magne sensors can be implemented using the following hardware architecture, which is sho in Figure 1: Six solar sensors, such as photodiodes, were placed on each face of the CubeSat measure the intensity of sunlight. The 6 faces of the CubeSat were determined as follo +x, −x, +y, −y, +z, −z.
A three-axis magnetometer was used to measure the Earth's magnetic field. T magnetometer was placed in a suitable location on the CubeSat to measure the intens and direction of the magnetic field. Six solar sensors, such as photodiodes, were placed on each face of the CubeSat to measure the intensity of sunlight. The 6 faces of the CubeSat were determined as follows +x, −x, +y, −y, +z, −z.
A three-axis magnetometer was used to measure the Earth's magnetic field. The magnetometer was placed in a suitable location on the CubeSat to measure the intensity and direction of the magnetic field.
A microcontroller was used to interact with the solar sensors and magnetometer for data processing. It was programmed to perform calculations to determine the satellite's orientation.
The overall system architecture is relatively simple and inexpensive as it only requires a few inexpensive sensors, a microcontroller, and power source components. The system can be integrated into a CubeSat during the design phase or added as an upgrade to existing CubeSat equipment.

Architecture and Model of Magnetic Sensor
In this subchapter, the architecture of the magnetic sensor used is presented. Electronic three-axis magnetometers based on anisotropic magneto-resistive (AMR) technology are used as magnetic sensors on CubeSats to measure the magnetic field strength in different directions. The magnetometer used is the LSM303DLH, an inexpensive three-axis digital magnetometer capable of measuring magnetic fields in the range of ±8 Gauss [18]. The LSM303DLH magnetic sensor is a digital compass that measures the Earth's magnetic field in three dimensions (X, Y, Z). The sensor is located such that its own coordinate axes coincide with the axes of the satellite's internal coordinate system, thus directly outputting the value of the Bs vector.

Practical Implementation of the Sensor Relative Attitude
In this chapter, a practical application of the orientation system is demonstrated, and the electrical circuit for sensor connections is presented. Additionally, a practical implementation in the form of a ready-made board is provided.
For the implementation of the above-proposed system, we used Arduino. The mathematical model of the CubeSat's orientation system was transformed into software code in the Arduino IDE. The block diagram of the system is shown in Figure 2.  Based on the constructed architecture of the CubeSat orientation system, a connection diagram of the sensors to the microcontroller was developed, as well as the manufacture of the orientation system board. The electrical circuit diagram of the system is shown in Figure 3.   Control of the actuating devices is carried out using the Atmega2560 (Microchip Technology Inc., Chandler, AZ, USA) microcontroller (U1). To operate the microcontroller at a clock frequency of 16 MHz, an HC-49S quartz resonator is used.
To connect the solar panels to the microcontroller (U1.1), current-limiting resistors of 86 kOhm and ports from A0 to A5 are used. The signals from the solar panels are fed to the microcontroller's 10-bit ADC for further processing.
The magnetometer is connected to the microcontroller via the I2C serial asymmetric bus, through port 20 and 21. The processed data is written to an SD card, which is connected to the microcontroller via the Serial Peripheral Interface (SPI).
The device is powered by an AMS1117 5 V linear voltage regulator, which converts the 12 V DC voltage to 5 V DC voltage, corresponding to the power supply level of the microcontroller's peripherals and external data-storage devices. As an alternative, a backup power source, such as a small battery, can be connected to ensure the system continues to function during power outages.
The radio electronic circuit of the device was designed using the EasyEda STD software environment, and the printed circuit board for the system was manufactured using a CNC milling machine (vmc650, Shandong, China). Files for cutting the foil-textolite were prepared in the flatcam program, as shown in Figures 4 and 5. microcontroller's peripherals and external data-storage devices. As an alternative backup power source, such as a small battery, can be connected to ensure the syste continues to function during power outages.
The radio electronic circuit of the device was designed using the EasyEda ST software environment, and the printed circuit board for the system was manufactur using a CNC milling machine (vmc650, Shandong, Сhina). Files for cutting t foil-textolite were prepared in the flatcam program, as shown in Figures 4 and 5. (a) (b)

Experimental Results
This chapter presents the results of experiments conducted to test the propos passive orientation system of the nanosatellite in the laboratory conditions of the univ sity. microcontroller's peripherals and external data-storage devices. As an alternative, a backup power source, such as a small battery, can be connected to ensure the system continues to function during power outages.
The radio electronic circuit of the device was designed using the EasyEda STD software environment, and the printed circuit board for the system was manufactured using a CNC milling machine (vmc650, Shandong, Сhina). Files for cutting the foil-textolite were prepared in the flatcam program, as shown in Figures 4 and 5.

Experimental Results
This chapter presents the results of experiments conducted to test the proposed passive orientation system of the nanosatellite in the laboratory conditions of the university.

Experimental Results
This chapter presents the results of experiments conducted to test the proposed passive orientation system of the nanosatellite in the laboratory conditions of the university.
The experiment was conducted in the university's laboratory. An electric lamp was chosen as a Sun emulator, and a supporting frame was used to install the CubeSat, which is shown in Figure 6. The experiment was conducted in the university's laboratory. An electric lamp was chosen as a Sun emulator, and a supporting frame was used to install the CubeSat, which is shown in Figure 6. Before characterizing the developed orientation sensor, calibration of the measurement instruments was carried out. Using an online calculator, the data of the Earth's position in the heliocentric reference system for the year 24 April 2023 were calculated [19], as well as the magnetic field data in the geocentric reference frame at the laboratory location [20].
The experiment was conducted in two stages.
The first stage of the experiment was carried out using solar sensors. The satellite was mounted on a three-axis holder at a distance of 32 cm from the solar emulator. The Before characterizing the developed orientation sensor, calibration of the measurement instruments was carried out. Using an online calculator, the data of the Earth's position in the heliocentric reference system for the year 24 April 2023 were calculated [19], as well as the magnetic field data in the geocentric reference frame at the laboratory location [20]. The experiment was conducted in two stages. The first stage of the experiment was carried out using solar sensors. The satellite was mounted on a three-axis holder at a distance of 32 cm from the solar emulator. The goal of the experiment was to determine the satellite-Sun vector and compare it with the real satellite-Sun orientation. As part of the experiment, solar panels were illuminated at different angles, and the following data were obtained: (a) First, one side of the CubeSat was illuminated. In Figure 7 below, it can be seen that the angle of incidence of the beam on the y+ panel is 90 • degrees. The table on  When the Sun's rays fall equally on both panels (angle of incidence 45 • , Figure 8a).

2.
When the two panels are illuminated unevenly, Figure 8b. In both cases, the sensor accurately determines the angle of incidence of the Sun's rays, and using this data, we found the coordinates of the vector ⃗. For example, in the case shown in Figure 8b, we have ⃗ 0,86 ⃗ 0,51 ⃗. (c) In the following experiment, the Sun illuminates three faces of the satellite. Two experiments were carried out: one when the Sun's ray illuminates three panels equally (angle of incidence α = 60.8°, (Figure 9a), and the second case when one of the panels is illuminated at different angles (Figure 9b). In both cases, the data from In both cases, the sensor accurately determines the angle of incidence of the Sun's rays, and using this data, we found the coordinates of the vector ⃗. For example, in the case shown in Figure 8b, we have ⃗ 0,86 ⃗ 0,51 ⃗. (c) In the following experiment, the Sun illuminates three faces of the satellite. Two experiments were carried out: one when the Sun's ray illuminates three panels equally (angle of incidence α = 60.8°, (Figure 9a), and the second case when one of the panels is illuminated at different angles (Figure 9b). In both cases, the data from the solar sensors are correct. For example, in the second experiment, we have ⃗ 0,67 ⃗ 0,67 ⃗ 0,32 ⃗. In both cases, the sensor accurately determines the angle of incidence of the Sun's rays, and using this data, we found the coordinates of the vector → n ns . For example, in the case shown in Figure 8b, we have  (c) In the following experiment, the Sun illuminates three faces of the satellite. Two experiments were carried out: one when the Sun's ray illuminates three panels equally (angle of incidence α = 60.8 • , (Figure 9a), and the second case when one of the panels is illuminated at different angles (Figure 9b). In both cases, the data from the solar sensors are correct. For example, in the second experiment, we have (c) In the following experiment, the Sun illuminates three faces of the satellite. Two experiments were carried out: one when the Sun's ray illuminates three panels equally (angle of incidence α = 60.8°, (Figure 9a), and the second case when one of the panels is illuminated at different angles (Figure 9b). In both cases, the data from the solar sensors are correct. For example, in the second experiment, we have ⃗ 0,67 ⃗ 0,67 ⃗ 0,32 ⃗. The second stage of the experiment included both Sun sensors and a magnetic sensor. To implement the experiment, we chose a reference frame associated with the labor- The second stage of the experiment included both Sun sensors and a magnetic sensor. To implement the experiment, we chose a reference frame associated with the laboratory room, replacing J2000 for our laboratory experiment. The Sun emulator was placed along the X-axis, so the vector Sj was equal to: After loading the coordinates and installing the satellite, we rotated the satellite relative to the Sun with a 20 • step and recorded the results of the satellite sensors along the way.
(a) During the first experiment, the CubeSat rotated around an axis passing through the center of the faces z+ and z−. Accordingly, the Sun's rays fell in such a way that they illuminated two panels simultaneously (+x, +y) as shown in Figure 10. The magnetic sensor was installed in such a way that its own axes coincided with the axes of the satellite, aligning with the normal directions to the solar panels. Subsequently, data were collected from the magnetic and solar sensors, from which orientation information was extracted. Additionally, prior to the experiment, we calculated the theoretical quaternion for each angle. These data are presented in Table 1.
After the first experiment, we need to calculate the average error for each component. To calculate the average error between two quaternions, you can use the formula for the average absolute error given by Equation (10): Here, q1, q2, q3, q4 are the components of the theoretical quaternion, and p1, p2, p3, p4 are the components of the measured quaternion.
Analyzing the results of the first experiment (Figure 11), we apply the formula for the average absolute error and draw the following conclusion: an error of 1.2% has been identified, indicating a substantial and satisfactory agreement between the working hypothesis, theoretical assumptions, and the experimental results. the center of the faces z+ and z−. Accordingly, the Sun's rays fell in such a way that they illuminated two panels simultaneously (+x, +y) as shown in Figure 10. The magnetic sensor was installed in such a way that its own axes coincided with the axes of the satellite, aligning with the normal directions to the solar panels. Subsequently, data were collected from the magnetic and solar sensors, from which orientation information was extracted. Additionally, prior to the experiment, we calculated the theoretical quaternion for each angle. These data are presented in Table 1.     The objective of the second experiment was to illuminate three faces of the CubeSat simultaneously. The experiment was conducted as follows: The satellite was positioned such that the Sun equally illuminated three panels adjacent to one of the vertices ( Figure 12). Simultaneously, a magnetic sensor was installed inside the satellite, aligned with the local magnetic axis as the initial position. Illumination readings of the satellite panels were then taken. The experimental results corresponding to the satellite's vertices are shown in Table 2.
By comparing the analysis from the tables, it can be observed that the Sun's rays fell on the three satellite panels in a highly consistent manner. Additionally, this algorithm calculates the orientation of the nanosatellite, specifically the quaternion.
Analyzing the results of the first experiment (Figure 11), we apply the formula for the average absolute error and draw the following conclusion: an error of 1.2% has been identified, indicating a substantial and satisfactory agreement between the working hypothesis, theoretical assumptions, and the experimental results. Figure 11. Sensor measurement error. Experiment 2: The objective of the second experiment was to illuminate three faces of the CubeSat simultaneously. The experiment was conducted as follows: The satellite was positioned such that the Sun equally illuminated three panels adjacent to one of the vertices ( Figure 12). Simultaneously, a magnetic sensor was installed inside the satellite, aligned with the local magnetic axis as the initial position. Illumination readings of the satellite panels were then taken. The experimental results corresponding to the satellite's vertices are shown in Table 2.
By comparing the analysis from the tables, it can be observed that the Sun's rays fell on the three satellite panels in a highly consistent manner. Additionally, this algorithm calculates the orientation of the nanosatellite, specifically the quaternion.

Conclusions
This paper includes a discussion of the results obtained from laboratory tests conducted on an inexpensive CubeSat in the CubeSat format. The primary objective of these tests was to determine the coordinates of the satellite-Sun vector in the satellite's reference frame, using magnetic sensors and Sun sensors. These coordinates were then utilized to accurately determine the CubeSat's orientation. By incorporating a magnetic sensor and developing a mathematical model of the CubeSat's passive orientation system, experimental testing was conducted under controlled laboratory conditions. The results of these tests demonstrated the system's capability to accurately determine the satellite's orientation throughout the orbital day.
In the first experiment, the proposed sensor of the passive orientation system of the nanosatellite was tested. A comprehensive analysis of the solar panels was performed, and a mathematical model for the solar sensors was constructed. Additionally, experiments were conducted at various distances from the solar simulator. The detailed data and findings of this experiment can be found in the source provided [16].

Conclusions
This paper includes a discussion of the results obtained from laboratory tests conducted on an inexpensive CubeSat in the CubeSat format. The primary objective of these tests was to determine the coordinates of the satellite-Sun vector in the satellite's reference frame, using magnetic sensors and Sun sensors. These coordinates were then utilized to accurately determine the CubeSat's orientation. By incorporating a magnetic sensor and developing a mathematical model of the CubeSat's passive orientation system, experimental testing was conducted under controlled laboratory conditions. The results of these tests demonstrated the system's capability to accurately determine the satellite's orientation throughout the orbital day.
In the first experiment, the proposed sensor of the passive orientation system of the nanosatellite was tested. A comprehensive analysis of the solar panels was performed, and a mathematical model for the solar sensors was constructed. Additionally, experiments were conducted at various distances from the solar simulator. The detailed data and findings of this experiment can be found in the source provided [16].
In the second experiment, aimed at enhancing the accuracy of the nanosatellite's orientation, a second sensor was incorporated to measure the Earth's magnetic field. Following the integration of this second sensor, a mathematical model of the complete passive orientation system was developed. The outcome of this experiment yielded an orientation sensor with an error rate of 1.2%, which was a significant achievement in laboratory conditions.
In conclusion, the exclusive utilization of solar and magnetic sensors for orientation determination presents a cost-effective solution for CubeSats. These sensors are generally affordable and have low power requirements, making them particularly advantageous for CubeSats with limited resources. Moreover, the combination of information gathered from these sensors enables accurate orientation determination without the need for additional sensors or complex algorithms. This straightforward and cost-effective method of orientation determination is a noteworthy advancement in enhancing access to spaceflight for a broader range of organizations.
It is worth noting that this system exhibits potential for further expansion in the future. It can be adapted to accommodate various installations, incorporate various sensor types, facilitate scientific research, and investigate various anomalies. By harnessing the benefits of solar and magnetic sensors, CubeSat missions can continue to evolve and effectively address the increasing demands of space exploration and scientific investigations.
In summary, the results obtained from the laboratory tests validate the effectiveness and reliability of the proposed orientation system based on solar and magnetic sensors. These results instill confidence in the system's ability to accurately determine the CubeSat's orientation, thereby supporting the successful operation and data collection of CubeSat missions. With its affordability, simplicity, and adaptability, this orientation system offers a promising avenue for advancements in CubeSat technology and expands the opportunities for organizations to participate in space-based activities. Funding: This research has been funded by the Science Committee of the Ministry of Education and Science of the Republic of Kazakhstan (Grant No. AP14869120-Development and creation of narrow-directional «satellite-satellite» antenna systems with the best and optimal characteristics for the CubeSat form factor).

Institutional Review Board Statement: Not applicable.
Informed Consent Statement: Not applicable.

Data Availability Statement:
The data that has been used is confidential.