- =
Building
- Electronics
- Code
- Frame
Operating
02. Programming the satellite
Learning to work with the onboard computers
The operation of all satellite subsystems in orbit is controlled by microcontrollers and microprocessors — computing devices with built-in memory, as well as systems for interacting with other onboard electronics (signal generators and converters, communication interfaces, etc.).
What onboard computers does MySat have?
In most real CubeSats, there are no special “space computers” — instead, they use standard general-purpose microcontrollers, which are widely applied on Earth in many other fields, such as household appliances, scientific equipment, and education. The microcontrollers used in MySat belong to this same category.
Working with the onboard computers
Since MySat is an educational project, we use the Arduino Integrated Development Environment (Arduino IDE) as a software tool for working with the microcontrollers. This is free and easy-to-use software designed for educational purposes. Arduino IDE allows you to create programs in the Arduino language (based on C++), upload them to the microcontroller’s memory, and also “communicate” with the microcontrollers from your PC.
To work with the microcontrollers, you will need…
Preparing the Arduino IDE environment on your PC:
1 Download and install Arduino IDE v. 2.0+ from the official website.
⇒ download Arduino IDE
(www.arduino.cc/en/software)
2 Install the board package for the ESP32 family:
2.1 Open the Boards Manager in Arduino IDE:
Go to Tools > Board > Boards Manager…
2.2 Use the search bar to find “esp32 by Espressif Systems”
2.3 Select board package version 2.0.17 and install it
3 Install the driver for the provided USB-to-TTL converter
3.1 Download the driver for your OS from the official website.
⇒ Silicon Labs
(www.silabs.com/software-and-tools/usb-to-uart-bridge-vcp-drivers)
For Windows, choose “CP210x VCP Windows”.
3.2 Install driver
For Windows, run the installation wizard (.exe) and follow the on-screen instructions.
Changing the firmware of the microcontrollers
Uploading firmware to ESP32-CAM:
1 Download the MySat project source code from GitHub
⇒ to MySat Github
(github.com/MySatKit/MySatKit-Firmware)
To download:
Click “Code▾”, then “Download ZIP”
What`s inside the downloaded archive?
3 Install the libraries required for building the MySat firmware for ESP32-CAM
Extract the “libraries.zip” archive into the “libraries” folder inside your Arduino IDE sketchbook folder.
If the “libraries” folder does not exist in your sketchbook folder — create it.
How to find the Arduino IDE sketchbook folder?
By default, it is located at { C: \ Users \ ”USER NAME” \ Documents \ Arduino }.
To confirm, in Arduino IDE go to File > Preferences and check the field “Sketchbook location”.
4 Open the project file – “MySat_main.ino”
It is located in … \ ino \ MySat_main, and should be opened using the Arduino IDE.
When you open this file, all .h files located in the same folder should also open as tabs in the
Arduino IDE interfac
If only the .ino file opens, make sure you extracted the entire project folder correctly.
5 Select the board type “AI Thinker ESP32-CAM”
Use the ‘Select Other Board and Port’ window — open it by clicking the dropdown menu in the top navigation bar:
… and select “AI Thinker ESP32-CAM”.
Alternative: Tools > Board > esp32 > AI Thinker ESP32-CAM
6 Verify that the project compiles
Go to Sketch > Verify/Compile
or press the [ ✓ ] button in the toolbar:
Please wait. It may take up to several minutes to build the project.
A successful project check is indicated by:
– the pop-up window ‘Done compiling’:
– the output lines “Sketch uses…” and “Global variables use”:
A successful compilation means that your software is configured correctly and all required files are present on your PC.
7 Put the ESP32-CAM into firmware upload mode
The ESP32-CAM must be inserted into the MySat board (A).
To change the mode:
7.1 Place a jumper on the boot pins of the MySat board ( A ).
7.2 Restart the ESP32 to enter bootloader mode:
a. press the “Reset” button on board (A) for v.1.5.3+ boards
or
b. insert and then remove the Remove Before Flight plug
8 Connect the ESP32-CAM to your PC
8.1 Connect the 4-wire ribbon cable to the USB-to-TTL converter 8.2 Use the ribbon cable to connect the programmer port of the MySat board ( A ) to the USB-to-TTL converter:
8.3 Plug the USB-to-TTL converter into the USB port of your PC.
Select the PC serial port to which the ESP32-CAM is connected
When you connect the board, your PC’s operating system should create a virtual serial port for the microcontroller.
On Windows, serial ports are named in the format “COM X” (short for “communication port”).
You need to specify in Arduino IDE which serial port to use.
To do this, open the “Select Other Board and Port” window by clicking the drop-down menu in the top navigation bar:
Next, in the “PORTS” section, select the desired port.
I see many different ports available. How do I choose the correct one?
Remember which ports are available when the ESP32-CAM is connected to your PC. Then disconnect the USB-to- TTL converter from your PC and check the list of ports again. The port that disappears is the one you need to use.
Upload the firmware to the ESP32-CAM
To do this, go to Sketch > Upload,
or click the [→] button:
A successful upload is indicated by:
the pop-up window “Done uploading”:
the output lines “Leaving…” and “Hard resetting…”:
11 Return the ESP32 to program execution mode.
To change the mode:
11.1 Remove the jumper from the boot pins:
11.2 Restart the ESP32 to return it to normal operation. To do this:
a. Press the “Reset” button on MySat board ( A ) for v.1.5.3+ boards
or
b. Disconnect the USB-to-TTL converter from your PC, then insert and remove the Remove Before Flight plug.
Hooray! If everything went correctly, you have successfully uploaded the new firmware to the ESP32-CAM.
This concludes Module 2 – Getting to Know the Onboard Computers.
You can now proceed to Module 3 – Assembling Your CubeSat’s Frame ⇒
Uploading firmware to Nano board (ATmega328P): Complete the first two steps of the ESP32-CAM firmware upload instructions, if you haven’t done so already:
1 Download the MySat project source code from GitHub
⇒ to MySat Github
(github.com/MySatKit/MySatKit-Firmware)
2 Extract the downloaded archive to any folder
3 Open the project file – “MySat_Nano_ATmega328p.ino”
It is located in … \ ino \ MySat_Nano_ATmega328p
4 Select the board type “Arduino Nano”
Use the ‘Select Other Board and Port’ window — open it by clicking the dropdown menu in the top navigation bar:
… and select “Arduino Nano”. Alternative: Tools > Board > Arduino AVR boards > Arduino Nano
Why is “Arduino Nano” option chosen?
The ATmega328P microcontroller board included in the MySat kit is a full clone of the original
Arduino® Nano board from “Arduino AG,” although it is manufactured by a different producer.
5 Connect the Nano board (ATmega328P) to your PC
To do this, connect the microcontroller to your PC using the USB cable provided in the MySat kit. If you are working with the Nano board already installed in the MySat board assembly, disable power to the other electronic components by inserting the Remove Before Flight plug into the corresponding socket.
6 Select the PC serial port to which the ESP32-CAM is connected
When you connect the board, your PC’s operating system should create a virtual serial port for the microcontroller.
On Windows, serial ports are named in the format “COM X” (short for “communication port”).
You need to specify in Arduino IDE which serial port to use. To do this, open the “Select Other Board and Port” window by clicking the drop-down menu in the top navigation bar:
Next, in the “PORTS” section, select the desired port.
I see many different ports available. How do I choose the correct one?
Remember which ports are available when the ESP32-CAM is connected to your PC. Then disconnect the USB-to- TTL converter from your PC and check the list of ports again. The port that disappears is the one you need to use.
7 Upload the firmware to the (ATmega328P)
To do this, go to Sketch > Upload,
or click the [→] button:
A successful upload is indicated by:
– the pop-up window “Done uploading”:
– The outputs “Sketch uses…” and “Global variables use”
and the absence of any new outputs afterward:
Upon completion, the Nano board will automatically exit the upload mode.
I see the outputs:
avrdude: stk500_getsync() attempt X of 10: not in sync: …
during the upload attempt. What should I do?
In Arduino IDE, go to Tools > Processor and select “ATmega328P (Old Bootloader)”. Then try uploading the firmware again (repeat step 7).
Hooray! If everything went correctly, you have successfully uploaded the new firmware to the Nano board.
