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.