FemtoSat Build Guide
Intro
Welcome to the Build Guide! This guide will give you instructions and links to resources that will help you design and build your femtosat.
Choosing a Sensor
Your femtosat must include at least one sensor. We currently recommend and provide support for two sensors:
- The BME280 atmospheric sensor, which measures humidity, pressure (altitude), and temperature.
- The ADXL345 inertial measurement unit, which measures 3-axis acceleration.
You may supply a different sensor of your choice, but you will be on your own when learning how to use it.
Prototyping with the Breadboard
Before designing your PCB, you'll build the breakout-board version of the femtosat circuit on a breadboard. This lets you test your wiring and code before making the final PCB. The club provides all of the prototyping parts:
- An ATmega328P development board (Arduino Nano)
- Adafruit BME280 breakout
- Adafruit ADXL345 breakout
- Adafruit RFM95W 915 MHz LoRa radio breakout
- A breadboard and jumper wires
Each breakout board has its own 3.3 V regulator, level shifting, and I2C pull-up resistors, so they are safe to use with the 5 V Arduino and don't need external pull-up resistors.
The Processor (ATmega328P)
The brain of the femtosat. It runs your code, reads the sensors, decides what to send, and hands packets to the radio.
- Everything else on the board is either something it talks to or something that powers it.
- It has built-in hardware for SPI and I²C, which is why some pins are fixed and others are your choice.
The I²C Bus (Sensors)
I²C lets many devices share just two wires:
- SDA carries data in both directions.
- SCL is the clock the processor ticks so everyone stays in step.
Both sensors share the same two wires because each answers to a unique address: BME280 is 0x77 and ADXL345 is 0x53 with SDO left open on the Adafruit boards. The processor calls out an address and only the matching sensor replies. That's why every SDA goes in one breadboard row and every SCL in another.
The SPI Bus (Radio)
SPI is faster than I²C and gives each direction its own wire:
- MOSI carries data from the processor to the radio.
- MISO carries data from the radio to the processor.
- SCK is the clock from the processor.
- NSS/CS selects the radio; pulling it low means "I'm talking to you."
More SPI devices can share MOSI, MISO, and SCK. Each just needs its own CS pin.
The radio link also includes DIO0, a one-way flag from the radio. It goes high when a packet finishes sending or arrives. Wiring it to INT0 lets the processor react instantly instead of constantly asking the radio "done yet?"
Power and Ground
- Dev board: every breakout's VIN goes to the 5 V rail. The Adafruit boards have their own regulator and level shifting, so 5 V is safe.
- Femtosat: the battery feeds a voltage regulator, and its output, 3V3, powers everything. There are no breakout regulators, so the parts run directly from 3V3.
- All grounds must connect. A signal is only a voltage compared to ground, so parts without a shared GND can't understand each other.
Wiring Help
Adafruit provides guides on wiring their boards:
Programming the Breadboard Prototype
The Arduino IDE
For programming your femtosat, you'll want to use the Arduino IDE. A guide for getting started can be found here: Getting Started with Arduino IDE.
- On the software page, download Linux AppImage 64 bits (X86-64).
- Make the file executable and run it:
chmod +x ~/Downloads/arduino-ide_2.3.10_Linux_64bit.AppImage~/Downloads/arduino-ide_2.3.10_Linux_64bit.AppImage - If you see
dlopen(): error loading libfuse.so.2, install FUSE: Ubuntu 24.04 and newer:sudo apt install libfuse2t64
Ubuntu 22.04:sudo apt install libfuse2
Fedora:sudo dnf install fuse - If you see a sandbox error on Ubuntu 24.04, start the AppImage with
--no-sandbox. - Give your account access to serial ports, then log out and back in: Ubuntu, Debian, Fedora:
sudo usermod -aG dialout $USER
Arch:sudo usermod -aG uucp $USER - On Ubuntu, if a CH340 USB-UART module disappears a second after you plug it in, remove the conflicting braille service with
sudo apt remove brltty.
Drivers: FTDI, CH340, CP210x. Linux and macOS include these drivers already.
At this point you should try uploading a simple example sketch (like Blink) to check that you can upload to your ATmega successfully.
Next, you'll want to begin programming the Arduino to read from the sensors and send packets to the radio. You can find guides for getting started, as well as example code, at Adafruit.com:
Don't forget to install the required libraries, which are linked in the guides.
Example Sketch
Before writing your code, install the Arduino IDE and the libraries described in The Arduino IDE. Start from the template below: the includes, pin definitions, and library objects are set up for you, and the comments in setup() and loop() describe what your code needs to do. Replace each comment with working code. The example sketches under File › Examples for each library show the function calls you'll need.
Select your development board under Tools › Board, choose its port under Tools › Port, upload, and open Tools › Serial Monitor at 9600 baud to check your output.
// Femtosat flight code template.
// Pins match the femtosat schematic, so this sketch runs on both the breakout prototype and your femtosat.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_ADXL345_U.h>
#include <RH_RF95.h>
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2 // ATmega pin 32 (PD2), radio DIO0
#define STATUS_LED 3 // ATmega pin 1 (PD3)
#define RF95_FREQ 915.0 // MHz
#define BME280_ADDR 0x77
RH_RF95 rf95(RFM95_CS, RFM95_INT);
Adafruit_BME280 bme;
Adafruit_ADXL345_Unified accel(12345);
uint32_t packetNum = 0;
void setup() {
// 1. Set the status LED pin as an output.
// 2. Start the serial port at 9600 baud.
// 3. Initialize the radio. If it fails, print an error to the Serial Monitor.
// 4. Set the radio frequency to RF95_FREQ (RadioHead defaults to 434 MHz, so this step is required).
// 5. Set the radio's transmit power.
// 6. Start the BME280 at BME280_ADDR. If it isn't found, print an error.
// 7. Start the ADXL345. If it isn't found, print an error.
// 8. Set the ADXL345's measurement range.
}
void loop() {
// 1. Read pressure, temperature, and humidity from the BME280.
// 2. Read the X, Y, and Z acceleration from the ADXL345.
// 3. Build a message containing the packet number and your readings, then increment packetNum.
// Hint: on the ATmega, sprintf() can't format floats; use dtostrf() to convert them to text.
// 4. Print the message to the Serial Monitor.
// 5. Turn the status LED on, send the message with the radio, wait until it finishes sending,
// then turn the status LED off.
// 6. Wait before taking the next reading.
}
Designing the Printed Circuit Board
Installing KiCad
For PCB design, we will be using a program called KiCad. KiCad is free and open source, and it has all the features you will need for femtosat. Download the current stable release for your operating system from kicad.org/download.
Schematic
Next, you will want to follow a guide to learn how to use KiCad to create a schematic diagram. KiCad's official guide is a good place to start: Getting Started in KiCad. The Schematic Editor manual covers every tool in detail.
Note that some of the parts we are using will not be found in the default KiCad libraries. You will be given a link to download the Femtosat library, which contains additional parts (like the sensors) to add to your schematic and board layout. It includes a symbol library (.kicad_sym) and a footprint library (a folder ending in .pretty). To add it to your project:
- Create your project with File › New Project in KiCad, then copy the Femtosat library files into your project folder.
- In the Schematic Editor, open Preferences › Manage Symbol Libraries, select the Project Specific Libraries tab, click the folder icon, and choose the
.kicad_symfile. - Open Preferences › Manage Footprint Libraries, select the Project Specific Libraries tab, click the folder icon, and choose the
.prettyfolder.
A add a symbol, P add a power symbol, W draw a wire, L add a net label, Q add a no-connect flag, R rotate, E edit properties, M move.
The datasheets for the active components contain suggestions for wiring. You should follow these guides to know how to wire the active components, what passive components are needed, and how to connect them.
Instructions
- Add the active components to the schematic, which can be found in the provided Femtosat library.
- the battery connector
- the voltage regulator
- the processor
- the sensors
- the radio
- Add passive components. Capacitors, resistors, and LEDs should be size 0805.
- capacitors: symbol
Device:C, footprintCapacitor_SMD:C_0805_2012Metric - resistors: symbol
Device:R, footprintResistor_SMD:R_0805_2012Metric - LEDs: symbol
Device:LED, footprintLED_SMD:LED_0805_2012Metric - antenna: symbol
Device:Antenna - connectors: symbols from
Connector_Generic(UART header) andConnector:AVR-ISP-6(ICSP header), footprints fromConnector_PinHeader_2.54mm
Assign footprints with Tools › Assign Footprints.
- capacitors: symbol
- The power supply:
- Connect the voltage regulator according to the datasheet.
Connect the battery connector to the voltage regulator. The battery connector should be wired as follows:
Pin 1 Battery voltage (positive) Pin 2 Ground - Add a resistor and LED to the output of the voltage regulator. This will be your power indicator.
- Name the output of the voltage regulator 3V3. This is your voltage supply for the rest of the circuit. In KiCad, use the
power:+3V3symbol; every+3V3symbol on the sheet is the same net.
- The processor:
- Connect VCC, AVCC, and AREF to 3V3. Connect all GNDs to ground.
- Add a 100nF decoupling capacitor between the supply voltage 3V3 and ground.
- Connect MOSI, MISO, and SCK to your SPI bus. Use pin 13 as the SS/CS line for the radio.
- Connect SDA and SCL to the I2C bus.
- Connect a 10k pull-up resistor to RESET.
- Optional: you may also add an LED to one of the digital output pins (PD3-PD7) for status indication.
- ICSP header:
This is a 2x3 header for programming the bootloader onto the ATmega. It should be connected as follows:
Pin 1 SPI MISO Pin 2 No connection (NC) Pin 3 SPI SCK Pin 4 SPI MOSI Pin 5 ATmega RESET (pin 29) Pin 6 Ground
- UART header:
This is a 1x6 header for programming your code onto the ATmega. It should be connected as follows:
Pin 1 ATmega RESET through a 100nF series capacitor Pin 2 ATmega pin 31 Pin 3 ATmega pin 30 Pin 4 No connection (NC) Pin 5 Ground Pin 6 Ground
- The radio:
- Connect 3.3V to 3V3. Connect all GNDs to ground.
- Add a 10uF decoupling capacitor between the supply voltage 3V3 and ground.
- Connect MOSI, MISO, and SCK to your SPI bus. Connect NSS to the SS/CS line for the radio.
- Connect DIO0 to pin 32 on the ATmega.
- Connect ANT to the antenna.
- The sensors:
- Connect according to their respective datasheets.
- Data connections via I2C are preferred over SPI.
- The I2C pull-up resistors:
- Your I2C bus should have a 4.7k pull-up resistor on both the clock and data line.
- LEDs:
- You'll need a series resistor to limit current through the LED to about 10mA. You may use a resistor calculator, such as the DigiKey LED Series Resistor Calculator, to find the value.
When your schematic is finished, mark any unused pins with a no-connect flag (Q) and run Inspect › Electrical Rules Checker (ERC). Fix every error before moving on to board layout.
Board Layout
Next, you'll want to turn your schematic into a PCB design. KiCad's PCB Editor manual is a good place to start.
- Open the PCB Editor and choose Tools › Update PCB from Schematic (
F8) to bring in your footprints. - Open File › Board Setup › Board Stackup › Physical Stackup and set the number of copper layers to 2.
- Draw the board outline on the Edge.Cuts layer. To round the corners, select the outline, right-click, and choose Shape Modification › Fillet Lines with a 3 mm radius.
- Add the string hole and zip-tie holes using footprints from KiCad's
MountingHolelibrary, setting the hole size to 2.5 mm for the zip-tie holes. - Place your components, then route traces with
X. PressVwhile routing to add a via to the other layer. - Add a ground plane with Place › Add Filled Zone on the GND net. Press
Bto refill zones after making changes. - Check your board in 3D with View › 3D Viewer (
Alt+3).
Requirements
- Your board must be no larger than 30x80 mm.
- Your board must have rounded corners with 3 mm radius.
- Your board must only have two copper layers (top and bottom).
- All SMD components must be on the top layer.
- Include space for the battery on the bottom of the board.
- Include holes for attaching battery with a zip-tie (2.5 mm diameter).
- The antenna must be as close as possible to the antenna port on the radio.
- The antenna must be as close as possible to the shorter edge of the PCB so that the entire length can extend from the PCB.
When you are finished with your PCB layout, be sure to run the Design Rule Check (DRC) tool (Inspect › Design Rules Checker) to make sure that you don't have errors that will prevent your PCB from being manufactured properly.
Ordering Your PCB
Your PCB will be manufactured by JLCPCB. There you will upload your Gerber files and choose your manufacturing settings. The settings can be left at their default values (although you may want to set "Mark on PCB" to "Remove Mark" to prevent the order number from being printed on the PCB).
To export your Gerber files from KiCad:
- In the PCB Editor, choose File › Fabrication Outputs › Gerbers (.gbr) and set the output directory to a new folder, such as
gerbers. - Select these layers:
F.Cu,B.Cu,F.Paste,B.Paste,F.Silkscreen,B.Silkscreen,F.Mask,B.Mask, andEdge.Cuts. - Check Check zone fills before plotting, Use Protel filename extensions, and Subtract soldermask from silkscreen, then click Plot.
- Click Generate Drill Files…, keep the output folder the same, choose Excellon format with millimeter units, and click Generate. Drill files are a separate step; without them your board will have no holes.
- Zip the folder and upload the zip file to JLCPCB.
You'll also want to order a solder stencil from OSH Stencils. There you will upload the same Gerber files. You'll want to choose Polyimide Film 5mil for the material.
Assembling the PCB
The components you need will be stocked at the Experiential Learning Center (ELC or ECEn Shop) where they will be available for purchase. Some components, like those specific to this project, may be consolidated in a single location. Other components will be in their usual places throughout the shop, and you will need to locate them.
We will be soldering components onto the PCB using the stencil and reflow technique. There are many good tutorials for how to do this, and you may want to explore several before you begin. The headers are through-hole parts that you will solder by hand after the stencil/reflow soldering is complete. The ELC has the soldering equipment you will need for your femtosat.
When adding components to your PCB, keep in mind the following:
- Integrated circuits (like the ATmega, sensors, and radio) must be oriented correctly. This is usually done by aligning the dot on the package (marking pin 1) with a dot on the PCB. Note: due to a last-minute change in the supplier for the radio, the radio will not align in this way. You should check the pin labels on the back to orient it correctly.
- LEDs are polarized, so orientation matters. You can check the polarity of an LED by setting a multi-meter to the diode setting and probing the LED. When the orientation is correct, the LED should glow.
- Resistors and most capacitors are not polarized. However, the 10 uF capacitor that the ELC has in stock is polarized, so you must verify the orientation. The stripe marks the positive terminal.
- The antenna is just a piece of solid wire cut to 1/4 of the wavelength.
Programming the Flight Computer
The Arduino IDE
You should have already installed the Arduino IDE, drivers, and libraries.
Unlike most Arduino boards, your femtosat doesn't use an external 16 MHz crystal oscillator. Instead, it uses the 8 MHz oscillator inside the ATmega chip. You'll need to add a board definition to tell the IDE to use the internal oscillator or it will be unable to communicate with the ATmega. We use MiniCore:
- Open File › Preferences (on macOS, Arduino IDE › Settings).
- In Additional boards manager URLs, paste
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.jsonand click OK. - Open Tools › Board › Boards Manager, search for MiniCore, and click Install.
- When uploading to your femtosat, use the same board settings as in Loading the Bootloader and select your USB-UART module under Tools › Port.
At this point you should try uploading a simple example sketch (like Blink) to check that you can upload to your ATmega successfully. In File › Examples › 01.Basics › Blink, change LED_BUILTIN to 3 so it blinks your status LED on PD3.
Loading the Bootloader
Before you can load code onto your processor, you must program the bootloader. This will be done through the ICSP header. You can learn more about this here. This requires an Arduino with a logic level shifter which will be provided for you.
- Connect the provided programmer to your ICSP header (pin 1 to pin 1) and power your femtosat.
- In the Arduino IDE, set Tools › Board to MiniCore › ATmega328, Clock to Internal 8 MHz, Variant to 328P / 328PA, Bootloader to Yes (UART0), and Programmer to Arduino as ISP. (Installing MiniCore is covered in The Arduino IDE.)
- Choose Tools › Burn Bootloader.
The Hardware Interface
The ATmega processor can not be connected directly to the USB port of a computer. This is because the USB protocol is complex and the ATmega doesn't support it. Instead, the ATmega can be programmed through a simple serial UART interface. To bridge the gap between USB and UART, a special USB-UART converter chip is used. This chip is built-in on Arduino boards, but for simplicity, it is not included on the femtosat boards. Instead, we will use a separate module with one of these USB-UART chips to interface between USB and the femtosat board.
Drivers: FTDI, CH340, CP210x. Linux and macOS include these drivers already.
The USB-UART programming module will connect to the UART header on your femtosat. When connecting the two boards together, be careful of the orientation of the connector. Be sure that the wires on the USB-UART module connect to the correct wires on the femtosat. Reversing the connector could damage your femtosat.
Pin Conversion
As you program your microprocessor, you'll need keep in mind that the pin numbering used in the Arduino IDE is different from the physical pin numbers on the microprocessor chip. Here is an image you can reference to convert between hardware and software pin numbers.