# Difference between revisions of "Qbcan modular"

This document is the qbcan user manual. It describes the qbcan CanSat kit, the soldering and assembly process and the software setup. It provides a step-by-step guide to help the user go through the development process, from the opening of the qbcan kit to transmitting data from one qbcan to another.

The qbcan kit has been developed by Open Cosmos, a start-up willing to use nano-satellites to provide simple and affordable access to space to organisations ranging from SMEs and research institutions to space agencies in developing countries.

Open Cosmos is based in London with an international mindset and the ambitious purpose to bring the possibility to use and develop space technology to a wider public. With that in mind, Open Cosmos has developed the qbcan, an educational CanSat kit for primary, secondary and tertiary education. The qbcan aims to engage and motivate the next generation of space engineers and scientists.

Support

In case you have any problem during the assembly or operations please post your questions into the Qbcan community.

Terminology / Definitions

BMP180 Pressure and temperature sensor. Low Level Converter 433 MHz transceiver

## System description

The qbcan bus provides all the required capabilities of a standard CanSat mission: radio communications, a temperature and pressure sensor and a computing platform with a wide range of interfaces. The user can then add extra functionality (adding sensors and actuators via the provided interfaces) and develop more complex systems.

The main components of the qbcan are:

• Arduino Pro Micro microcontroller.
• RFM69HW 433MHz transceiver.
• BMP180 pressure and temperature sensor.
• Low Level Converter.
• Antenna/Yagi antenna connector.
• Printed circuit board (PCB) that integrates the previous components.
• Rapid-development software library that interfaces with the transceiver and the pressure and temperature sensor.
• 9V battery.

The small qbcan footprint, the exposed Arduino Pro Micro pins and its mounting holes allow the qbcan to be flexible with respect its mounting location, allowing CanSat developers to mount it wherever is more convenient.

The qbcan (hardware and software) is open-source and users are encouraged to modify it and re-distribute their work.

### Microcontroller

Figure 1: Arduino Pro Micro pinout

The core of the qbcan is an Arduino Pro Micro microcontroller. The microcontroller provides the required computing power to the CanSat. The big number of interfaces provided by the Arduino Pro Micro allows the user to develop more complex CanSat missions by integrating additional peripherals. The main features of the Arduino Pro Micro are:

• ATmega32U4 running at 5V/16MHz.
• Easy to program using the Arduino integrated development environment.
• On-Board micro-USB connector for programming/provide power.
• I2C, SPI and UART serial communication ports.
• 4 channels to read analogue signals using a 10-bit analogue to digital converter.
• 5 Pulse Width Modulated output pins.
• 12 Digital Input Output pins.
• Tiny footprint: 33.0 x 17.8 mm.

The pinout of the Arduino Pro Micro can be seen in Figure 1:

All these pins and communication interfaces are available to the user except pin 7, 10, 16, 14 and 15 which are used to communicate with the transceiver. The I2C interfaces are shared with the pressure and temperature sensors, but are also available to the user.

### Transceiver

A RFM69HW 433 MHz transceiver is included to provide long range communication capabilities to the qbcan. The main features of the transceiver are:

• +20 dBm - 100 mW power output capability.
• High sensitivity: down to -120 dBm at 1.2 kbps.
• Programmable output power: -18 to +20 dBm in 1 dB steps.
• Fully integrated synthesiser with a resolution of 61 Hz.
• Frequency selectable by software over 256 different channels.
• 255 possible nodes in every channel.
• FSK, GFSK, MSK, GMSK and OOK modulations.
• Hardware 128 bit AES encryption.
• Over 400+ meters range using whip antennas and several km range using a Yagi antenna on the receiving end.

The transceiver communicates with the Arduino over the SPI interface and uses the pin 10 of the Arduino as the Slave Select (that is why this pin is reserved). The transceiver software, included with the qbcan, is interrupt driven (asynchronous response to incoming communications) and uses the Arduino pin 7 to provide this interrupt. Hence pin 7 is not available to the user. The antenna of the transceiver is a simple quarter wavelength monopole antenna. Using this transceiver, a qbcan can be used in a CanSat while another qbcan is used as ground station, receiving telemetry from the CanSat (and sending it to a PC via the USB port) and sending commands to the CanSat.

### Temperature and pressure control

The qbcan includes a BMP180 barometric pressure and temperature sensor. This sensor communicates over I2C and provides:

• Pressure sensing range: 300-1100 hPa (9000m to -500m above and below sea level).
• Up to 0.02 hPa / 0.17m altitude resolution.
• -40 to +85°C operational range, +-2°C temperature accuracy.

### Power

The qbcan is powered by a standard 9V battery (not included). The connector to the battery is included and the user can acess: - 9V raw from the battery. - 5V regulated power from the PCB board or the ardwino raw pin. - 3.3V regulated power from the PCB.

If you plan to use more than 500 mA from the 5V line it is recommended to use the raw battery voltage and use your own voltage regulator.

### Library

A qbcan software library is included. It provides an easy-to-use interface with the transceiver and pressure and temperature sensors. An example code is provided to speed up the development of the CanSat mission. The library includes a CanSat example and a ground station example.

## Getting started

The qbcan is distributed as a kit and hence it needs to be assembled. In order to develop software for the Arduino Pro Micro and use the provided qbcan library, the development computer needs to be properly configured. The following section (Assembly) covers the physical assembly of the qbcan and the one after that (Software Installation) provides a step by step guide to set up the development environment.

In order to complete the software installation, one assembled qbcan is required. However, the software installation steps will only require having the Arduino Pro Micro and so they can be done before starting the assembly.

make 2 qbcan modules. By following these guidelines you will assemble one qbcan module that allows the possibility to remove and replace all the components. It is recommended to assemble the second qbcan module by soldering directly all the components using the pitch headers provided in each component bag (without using any female headers). This will result in a module suitable for prototyping and testing as any component can be easily replaced if damaged; and another compact module that can be used as a CanSat module once the final design has been qualified, being much more compact and reliable for its final mission.

### Assembly

The assembly of the qbcan is relatively simple and only requires basic soldering skills. If you don't have any experience with soldering, the process will take approximately 3 hours, but it should take less than 2 hours if you have soldering experience. Consult the suggested tutorials to familiarise yourself with soldering in case needed.

Figure 2: Example of "third hand" / "helping hands"

The tools required to assemble a qbcan are those required for soldering hobby electronics. We recommend to have the following equipment with you during the assembly process:

• Pliers and/or tweezers.
• Soldering iron and solder. It is important that the solder contains a flux core (this will facilitate the soldering).
• Optional but recommended - Flux remover (to clean flux residue). It is important to use a remover for the specific flux formulation of your solder. Some flux formulations do not require to clean the residue afterwards. If you do not have a specific flux remover at hand, Isopropyl alcohol or acetone could help remove most of the residue.
• Optional - A third hand (see Figure 2) is very convenient when you are alone while doing the assembly.
• Optional - A solder wick remover in case you make a mistake and want to unsolder the components.
• Optional - Extra flux (e.g. in a pen dispenser). This element is optional but can help soldering the voltage regulator, which is surface mounted.

To assemble the qbcan board you just need to follow the following steps:

#### Clean the board

With a pair of pliers remove imperfections (if any) from the board. These are leftovers from the fabrication process.

#### Solder the pin headers onto the Logic Level Converter and the BMP180 sensor

The first soldering steps are easy. We will be soldering the headers onto the Logic Level Converter (LLC) and the BMP180 sensor. Use the short 0.1" (2.54 mm) pitch headers included in each of the sensor plastic bags for this. You will have to cut in half the array of pins for the LLC. Place the shorter part of the headers through the bottom part of the sensor board, initial configuration shown in Figure 3. Start soldering the pins in the corners and follow with the rest as shown in Figure 4.

TIP: Make sure that the headers are perpendicular to the board surface, a crocodile clip fixing the centre area of both parts could be very helpful.
The final result for the Logic Level Converter is shown in Figure 5.


We will be using the same headers for the BMP180 sensor. Solder the header into the BMP180 board. The final result is shown in Figure 6.

Inspect the soldier and make sure that you have good quality connections with each of the pins isolated. Before continuing, remove any flux residue.

Figure 3: Pin orientation, place the shorter part of the short 2.54 mm-pitch pins through the sensor board

#### Solder pin headers to the Arduino Pro Micro

Now that you have some practice in soldering headers, solder the headers of the Arduino Pro Micro included separately from the Arduino Pro Micro bag. The procedure is exactly the same but using the long 0.1" (2.54 mm) pitch headers that have to be cut apart in 2 blocks of 12 pins each. The plastic header needs to be moved so that the length of the pin in each side of the plastic header is between 6 and 7 mm, for the short part, and approximately 8 mm for the long part (see Figure 7). Do this by introducing the long part of the pin in the female header and push the plastic holder down until it is in contact with the female header. See Figure 8. It is important to hold the female header against a hard surface as shown in Figure 8 to avoid breaking it. Repeat it for each of the pins.

The long part of the pins need to be placed through the Arduino Pro Micro board. The final results should look like Figure 9.

The long pins will enable your peripherals (GPS, actuators or other sensors) to be connected to any pins of the Arduino by using female headers or female jumper wires (see Figure 10).

Before continuing, inspect the connections and clean any flux residue.

Figure 10:Left - Female headers. Right - Female jumper wires.

#### Solder the headers to the RFM69

Solder the 2 mm-pitch pins header to the RFM69 with the short part of the pin through the board, as shown in Figure 11. You will have to cut 2 blocks of 8 pins each from the spare 2 mm-pitch pin array that comes separately. Start soldering the two end pins of the header to fix it to the board, and then solder the ones in between. The final result should look like in Figure 12.

#### Solder voltage regulator to the board

This first component that we will solder on the qbcan board is the voltage regulator (see Figure 13). Due to the small size of this component, this is going to be one of the difficult parts to be soldered onto the board. Be patient, do not rush. Consult the suggested tutorials and familiarise yourself with Surface Mount Soldering (SMD) before attempting to solder this component. Use a pair of fine tweezers or pliers to place the component in the correct position. Solder the wide leg first and once this is done, continue with the three smaller parallel legs as shown in Figure 14.

Figure 13: Voltage regulator
Figure 14

#### Assembly of the components onto the board - solder the pin headers

In order to assemble the components onto the board there are two different approaches to be followed. The first one, described in this manual, is to solder female header to the board so that the components can be easily plugged and removed if necessary. The second one, is to solder the components directly to the board. This approach leads to a quicker implementation and a more compact qbcan which may be needed for very space-constrained CanSats.

Begin soldering the 2.54 mm-pitch female header for the Arduino (#1 in Figure 15 - left) and follow with the rest of the headers. You will have to cut one block of 12 female headers from the array that comes separately. Solder the pin in one end of the header to fix one side and then the other end (see Figure 16). Once this is done, proceed to solder the pins in the middle.

Continue with the same type of headers for the BMP180 sensor and the LLC. Solder headers #2, #3 and #4 as shown in Figure 17. You will have to cut 2 blocks of 6 female headers and one block of 5 female headers from the array that comes separately. Clean the side of the header from cutting imperfections, this is important to make sure that the header #3 fits in its place next to #2. Do not worry if some pins are broken when cutting as there are some spares provided.

Follow with the 2 mm-pitch female headers for the RFM 69 (#5 and #6 in Figure 15 - right), you will have to cut 2 blocks of 8 female headers from the 2 mm-pitch female headers array that comes separately. Finish by soldering the second 2.54 mm-pitch female header for the Arduino (#7 in Figure 15 left). The final result should look like in Figure 18.

Figure 15: Different size headers are soldered on both sides of the qbcan board. The numbers represent the recommended soldering order. Left - Arduino 2.54 mm female headers. Right - 2.54 mm-pitch female headers for BMP180 and LLC (2, 3 and 4) and 2 mm-pitch female headers for RFM69 (5 and 6).

Figure 16: Solder the pin in one end of the header to fix one side and then the other end

Figure 17: Solder headers #2, #3 and #4

Figure 18: Female headers soldered on the board.

#### Solder the battery connector to the board

The following component to be soldered onto the board is the battery connector. This is also a tricky step since the board hole is bigger than the metal conductor of the battery connector. Use a third hand (or ask somebody to help you) so that you are able to place everything in the right position and solder. Be careful not to burn your assistant with the soldering iron! It is also important that you solder the red wire to the positive (+) terminal and the black wire to the negative (-) terminal, as marked on the board. After soldering you will have something similar to Figure 19.

Figure 19: Battery connector soldered to the board

After finishing the soldering clean the connection, plug a standard 9V battery (not included) and check that the regulator output voltage is as expected using a voltmeter.

#### Solder the antenna to the board

The RFM69 is a 433 MHz transceiver which we will use with a wire monopole antenna. This is the simplest type of antenna consisting of a piece of wire with the length of a quarter of wavelength. For a frequency of 433 MHz the length of the antenna can be easily computed using the following equation

$l=\frac{\lambda}{4}=\frac{c}{4f}$

The speed of light is represented by the term c=299792458 m/s. For 433 MHz, l = 17.3 cm. A wire already cut to the specified length is already provided, pass it through the board hole and solder it to the dedicated pin hole, as shown in Figure 20. It is important for the antenna to be as straight as possible. If it is curved or bended the performance and the range will decrease.

In case the qbcan is going to be used as ground station, a Yagi antenna connector can be soldered instead to gain extra range. There are four surface soldering ground points, two on the top side of the PCB and two on the bottom, as well as one in the middle that can be soldered either on top or bellow. The position in which this adapter shall be soldered is shown in Figure 21.

#### Connect the components to the board

Once all the headers are soldered to the qbcan board, the components can be connected to them by plugging each component into its specific location.

##### Connect Logic Level Converter and the BMP180 to the board

Connect the components to their respective positions. For the Logic Level Converter, check that the High Voltage (HV) and Low Voltage (LV) sides are oriented correctly by looking at the board marks. The BMP180 needs to fit within the board limits (see the board marks for the outline of where the BMP180 should go). The final result after this step is shown in Figure 22.

Figure 22: Logic Level Converter and BMP180 solder into the board
##### Connect the RFM69 headers into the board

The next step will be connecting the RFM69 onto the board. On the board the antenna pinhole is marked with ANA. Make sure to connect the RFM69 board in such a way that the pin marked with ANA on the back of the RFM69 board matches with the one on the qbcan board (see Figure 23).

Figure 23: Connect the RFM69 matching the ANA pin in the RFM69 with the ANA pinhole of the board
##### Connect the Arduino to the board

The next step is to connect the Arduino Pro Micro to the board. This should not be difficult. Refer to the marking on the board to know how the Arduino should be oriented. Figure 24 shows how the board looks like after completing this step.

Figure 24: Arduino assembled to the qbcan board

### Software Installation

The Arduino Pro Micro microcontroller is the core component of the qbcan but it will need to be programmed in order to perform its mission. In this section you will learn to set-up a development PC with which you will be able to develop and upload code to your qbcan. The following steps will guide you through the whole process.

#### Install the Arduino IDE

The core of the qbcan is an Arduino Pro Micro. Arduino is a family of open-source microcontroller boards widely used for hobby projects. In order to program the Arduino you need to install its Integrated Development Environment (IDE). On the Arduino software page you can find the latest IDE package. Download the software version dedicated to your platform and install it. Arduino is programmed in C. Using this IDE you will be able to compile the code and upload it to the Arduino. Arduino is a very popular rapid-prototyping board with many tutorials and forums available online that can be very helpful when getting started in this environment. If you do not have any experience in programming C and/or Arduino we recommend you to watch the Jeremy Blum Arduino tutorials.

#### Install the Pro Micro drivers

The Arduino IDE works out of the box with most Arduino boards, but not with the Arduino Pro Micro. In order to make it work additional drivers need to be installed. Follow this guide to install the drivers for Windows or this guide to install the drivers for Mac/Linux. This guide follows a different approach which is valid for both Windows and Mac/Linux. Follow it in case the first one is not successful.

#### Board selection in the Arduino IDE

Once the driver has been correctly installed, the right board in the Arduino IDE can be selected. Go to Tools > Board and select Sparkfun Pro Micro. Under Tools > Processor select ATmega32U4 (5V, 16MHz). Select the correct port in Tools > Port. Since Arduino Pro Micro is very similar to Arduino Fio or Leonardo, in some cases selecting the Arduino Fio or Arduino Leonardo boards in the IDE (in Tools > Board) will also work. Therefore, if you are having problems installing the drivers, you can also try this option.

#### Check your installation

Now you are ready to start programming Arduino Pro Micro and it is a good time to check that everything is correctly installed. In order to test the installation, you do not need to have the qbcan assembled. Just pick the Arduino Pro Micro and plug it to your computer using the micro USB cable. Using Arduino IDE you can upload this sketch to the Arduino to check that the whole set-up is working (you will see two LEDs blinking). If that works, your qbcan is ready and you can start using it as your CanSat bus.

#### Download and Install the qbcan Arduino Library

qbcan is distributed with an Arduino Library that helps you interface with the transceiver RFM69 and the pressure and temperature sensor BMP180. In order to install the library, go into the Arduino IDE and click to Sketch > Import Library > Add Library. Then go to the folder where you have saved the qbcan library, browse to qbcan.zip and accept. You will then need to close and start again the Arduino IDE for the library to be loaded. To make sure that the library has been correctly installed, check that the qbcan examples can be found in File > Examples > qbcan.

#### Test qbcan using the qbcan Library examples

The qbcan Library contains examples you can use to check that the whole system works properly. In order to access the examples in the Arduino IDE, click on File > Examples > qbcan. You can find a CanSat example that measures temperature and pressure and transmits them to the ground station.

The GroundStation example can be used with another qbcan to receive this data. To do so, open the serial monitor in Tools > Serial Monitor and set the speed of the serial connection to 9600 baud (this value depends on how you define the serial connection in the qbcan code. See the "Using the RFM69 transceiver" section).

If you run each of the codes on two different qbcan you will be able to send and receive data and test the sensors. In order to try these examples, you will need to have a completely assembled qbcan kit. We encourage you to use these examples as starting point for your projects.

## Library

A very important part of the qbcan is the software library. This library provides an easy-to-use interface to the transceiver and the pressure and temperature sensor. In Sec. 3.2 a step-by-step guide on how to install the qbcan library can be found.

In this sections there are some tips exposed regarding the usage of the libraries and some introductory samples of useful code to be implemented in your mission.

### Library basics

To use the library you will need to include the qbcan library and the SPI.h and Wire.h libraries at the beginning of your code, so that the qbcan can have access to the SPI and I2C buses.

 //Include the required libraries#include <qbcan.h> //Core qbcan library#include <Wire.h> //I2C bus library#include <SPI.h> //SPI bus library

The SPI.h and Wire.h libraries are part of the Arduino IDE and thus no installation is required. The library qbcan.h needs to be placed at the top of the sketch.

### Using the BMP180 pressure and temperature sensor

The qbcan library provides a class to interface with the BMP180 pressure and temperature. To create the sensor object use the following snippet.

 //Create the pressure and temperature sensor objectBMP180 bmp;

Use this piece of code just after the library #include. This will create the sensor object.

On the setup() function you will need to initialise the sensor. You can do this with the following piece of code:

 void setup(){ 	//Initialize serial connection for debugging	Serial.begin(9600); 	// Initialize pressure sensor.	if (bmp.begin())		Serial.println("BMP180 init success");	else	{		//In case of error let user know of the problem		Serial.println("BMP180 init fail (disconnected?)\n\n");	    while(1); // Pause forever.	} }

After initialising the sensor it is ready to measure. To measure temperature and pressure you can use the following piece of code (note that the temperature unit is degrees Celsius and the pressure unit is mbar).

 //Declare temperature and pressure variablesdouble T,P; // Get a new temperature and pressure readingbmp.GetData(T,P)

After taking the measurement you can send the data to the serial port to be displayed in your PC serial monitor with the following piece of code:

 //Display dataSerial.print("Absolute pressure: ");Serial.print(P,2);Serial.println(" mb.");Serial.print("Temperature: ");Serial.print(T,2);Serial.println(" deg C.");

### Using the RFM69 transceiver

The library also provides a class to interface with the transceiver. You can create the object as follows.

 //Radio objectRFM69 radio;

Before initialising the RFM69 object on the setup() function it is useful to define some of the transceiver parameters as follows:

 //Radio Parameters#define NODEID        2    //unique for each node on same network#define NETWORKID     100  //the same on all nodes that talk to each other#define GATEWAYID     1    //Receiving node #define ENCRYPTKEY    "sampleEncryptKey" //The same on all nodes!

The NETWORKID can be set from 0 to 255 and that changes the physical channel used for the link (i.e. the frequency). Although in this guide the NETWORKID is considered a parameter, it can be changed during runtime. For this, you will need to re-initialise the library.

The NODEID is the node in a particular channel and can be set from 1 to 255. Therefore, we can have up to 255 qbcan operating in the same frequency, although they cannot transmit at the same time. Messages are generally send to a specific node and that is the GATEWAYID. So if you are configuring a transmitter/receiver make sure that you are transmitting to the correct node. Also a receiver can sniff all the packets in a network, thus receiving all traffic in that network independently if the messages where addressed to that particular node. To configure the radio on the setup you can just use the following code.

 void setup() { 	//Initialize serial connection for debugging	Serial.begin(9600); 	//Initialize radio	radio.initialize(FREQUENCY,NODEID,NETWORKID);	radio.setHighPower(); //Use the high power capabilities of the RFM69HW	radio.encrypt(ENCRYPTKEY);	Serial.println("Transmitting at 433 Mhz"); }

To send data through the network.

 //Send Datachar payload[50];sprintf(payload,"T: %d C, P: %d mb.",(int)T,(int)P);   Serial.print(payload);radio.send(GATEWAYID, payload, 50);Serial.println("Send complete");

In the radio.send() function, the last argument is the length of the message to be transmitted In the example above the the message payload is 50 bytes long and we are sending it in full although the actual message is not that long (so it could be optimised).

In order to receive data transmitted through the network, the following piece of code can be used:

 if (radio.receiveDone()){	for (byte i = 0; i < radio.DATALEN; i++)	Serial.print((char)radio.DATA[i]);}

Use radio.promiscuous(true); to activate the "promiscuous" mode to listen all packets from the network in use.

There are also some other functions that you may find useful when receiving messages:

radio.SENDERID - returns the sender node id.

radio.TARGETID - returns the message target node id (in case you are sniffing all the packets in the network).