Skip to content

Getting started

About Teensy CanSat kit

Teensy CanSat kit.

Teensy CanSat kit. Photo: Andøya Space

The kit is based on an Arduino compatible development board called Teensy. This means that, other than the name, the board is to be viewed as an Arduino and programmed as such. The programming language that is used is C, but in a «variant» of it which is often reffered to as it’s own language, Arduino, but is really a set of libraries hidden to the user to make programming of the Arduino boards easier to learn and use. Often programs that are written in Arduino can be used across many boards as they are ment to be as cross-compatible as possible, but some of the features of one boards is not existing on others, so there are exceptions to this. This will be the same for you when using the Teensy.

On the Teensy there is many pins that can be connected to external peripherals and devices. The pins can work in two ways: as inputs and outputs. If the pin is used as an input, the program measures what the voltage level is on the pin and returns that to the user. If the pin is used as an output, the user tells in the program what the voltage level should be on that pin and the microcontroller actually forces that voltage to be that value (either digital or analog, see below).

The Teensy is more powerful than most other Arduino boards, and all pins has more than one function. The pin functions can be divided into two categories: digital and analog. The digital pin functions can measure digital input and also output digital values. Digital values are either high (also often given as a ‘1’) value, in this case 3.3V, or a low value (often called ‘0’) with a voltage level of 0 volts. When it measure/samples a pin, that is measuring what the voltage is on that pin, it measures a high/true/1 if the levels are 3.3V or close to it. If it measures 0 volts or close to it, it registers it as a low/false/0. If the voltage is, for some reason, not close to either 0 or 3.3V however, the output can be either registered as a high or low, dependent of several factors. Computers live in a digital world and the usages of only measuring binary/digital values are huge, and one advantage is that it is extremely fast: the Teensy can output/input a digital values in less than 10 nano seconds!

If you want to measure or output not only digital values, the Teensy has two special internal peripherals called Analog to Digital converter (ADC) and a Digital to Analog Converter (DAC). Since all microcontrollers (which is essentially a simplified miniature computer) can only handle digital values the ADC and DAC works as an interface to an analog world: the ADC on the Teensy measures up to 4096 (12 bit) different linearly spaces analog values between 0 and 3.3 V. The DAC works in the completely opposite way: it takes a 12-bit value from the program and forces the pin to be on that value until it is changed by the user to another value. The Teensy has one ADC (technically three ADCs, but dont worry about that as they look like one for you as a user) and one DAC. However, that ADC and DAC has many channels, so even though it can only read input/output one at a time, it can work on many different pins. The DAC has only two pins (called DAC0 and DAC1) but the ADC has 26 channels/analog input pins, where 19 of them are available to you as a user (some is used for functions on the NAROM 2018 kit already and some are on pins that are not easily accessable).

We have discussed digital input/output pins already, but it is a sub-category of digital pins we have not yet talked about. There are only two voltage levels on digital pins, but the voltage levels can vary in time in many (infinite) different ways. The most popular way to communicate with the outside world is through serial communication: this is where one or a few pins vary dependently on each other in a very specific way based on some standard. You are guaranteed to have heard of USB communication: this is a serial protocol with two wires working together as one output in a special way (if we dont consider the new variants) to communicate in a extremely fast, standardized fasion between devices. In the embedded world of microcontrollers there are numerous other serial communication standards, with UART, SPI and I2C as one of the more famous/widespread, but all of these work with the same basic idea: alternating one/few pins in a specific way in time makes communication fast, cheap and simple. There are reasons not to use parallel communication which was very popular in the 80s and 90s which we will not come into here.

Teensy vs. Arduino Uno

The Teensy CanSat kit was made to deal with some of the more negative sides of using an Arduino Uno based kit. The benefits of using an Arduino Uno and a shield on top of it, is that it is familiar to many that have some experience with Arduino, since the Uno is what most people start of with when playing with Arduinos. Also, it has a physical size/pinout that many shields are using.

The drawbacks, however, is many. It is a 5 volt based system, which in some cases when using older sensors is a benefit, but most sensors, especially digital ones, are 3.3v based and hence you do need an interface/buffer between a 3.3v based sensor and the Arduino to use it. All Arduinos except the large Zero (48 MHz) and Due (84 MHz) are relatively slow, running on a 8/16 MHz CPU and relatively expensive compared to what you get. Some Arduinos do not have built-in USB interface, so it uses a USB chip (most often a secondary MCU) which is slow.

The Teensy 3.5 based v2018 kit tries to solve these issues. It is a based on a 3.3V system running on a Cortex M4F core with 120 MHz nominal CPU speed (which is overclockable, but this is normally not needed working with Cansat). It has 23 analog input channels (where 19 of these are available to the user on the Cansat kit) and 2 analog outputs (DAC0 and DAC1, which share pins with A21 and A22 channels). True analog outputs are not available on any of the Arduino boards except the Arduino Zero and Due. All GPIO pins are 5V tolerant (which is not true on the pin compatible Teensy 3.6 board). And it has a built in micro-SD card SDIO interface that runs up to 20 MB/s! Also, it is a true 12 Mbps USB device.

You can find the schematics (pin-out diagram) for the Teensy CanSat kit here.

As already stated, the Teensy 3.5 is 5V tolerant device on all general purpose input/output pins (GPIO), meaning that you can put 5V on the inputs. It can only output 3.3V, of course, but it can handle inputs up to 5V. However, note that the ADC is not 5V tolerant, so never put anything over 3.3V input on the ADC pins!

Assembly guide

Component list

Component list

  • Teensy 4.1
  • CanSat Shield v2018 (Circuit board)
  • RFM96 Radio Module
  • Voltage Regulator TO252-3. This voltage regulator can be used with batteries voltages up to 5.5V . If you choose to use for example a 9V battery in stead of the 3.7V Lipo battery suggested below, you need to use another voltage regulator. A link can be found in the components list above.
  • Buzzer
  • Temperature sensor NTC (NTCLE300E3103SB)
  • Surface mounted 1206 resistors (5 · 4,7 kΩ and 1 · 470 Ω)
  • Surface mounted 1206 capacitors (2 · 10 μF and 2 · 1 μF)
  • Header (Male pin connector) 3 x 32-pin
  • Light diode
  • GY-91 – 10 DOF multi sensor module with MPU-9255 and BMP280
  • Sma connector
  • Sma cable for antenna

Power supply (battery)

(This type and size of battery is optional, but will for convenience be included in the Teensy CanSat kit on courses/workshops by Andøya Space):

  • Li battery 3.7V 1000 mAh
  • Battery charger for micro USB cable and and a DIY JST DS LOSI 2-pin connector plug with wire
  • Battery connection wire

Li battery 3.7V 1000 mAh.

Li battery 3.7V 1000 mAh. Photo: Andøya Space

Assembly steps

Note that the pictures shown in this section was taken of a previous version of the Teensy kit. You will find a few discrepancies from your version, but will be able to assemble the board anyway. The resistors in the pictures may not have the same value or number as stated in the text, so in case of descrepancies follow the instructions in the text.

Step 1

Solder the 4 capacitors onto the backside of the board:

  • C1 and C3: 10 μF
  • C2 and C4: 1 μF

Headers

Step 2

Solder the four 4,7 kΩ resistors onto the backside of the board on the places named R1, R2, R5 and R6.

  • R1, R2, R5, R6: 4,7 kΩ

Headers

Step 3

Solder the voltage regulator to the backside of the board. Position: U1

Both the two pins on one side of the regulator and the larger ground plane on the other side of the voltage regulator has to be soldered to the board as shown in the figure to the right.

Headers Headers

Step 4

Solder the radio module onto the board (on the upside of the board). Be sure to place the radio module in the right orientation.

A square shows where the black chip on the radio should be situated.

Headers Headers

Step 5

Cut headers to the following lengths:

  • 24 pins
  • 24 pins
  • 8 pins
  • 2 pins

Headers

Step 6

Solder the Teensy 4.1 onto the board using two 24-pin headers and one 2-pin header.

Put the headers and the Teensy in place on the board:

Headers

The end of the Teensy holding the USB-connector should be placed as indicated on the board.

The 2-pin header is used for connection to the NTC. See the red drawing in the picture below:

Headers

Solder then first the Teensy to the 2-pin and 24-pin headers and afterwards the pin headers to the board at the back side of the board.

Step 7

Solder the light diode (D1) and the R4 resistor (470 Ω) onto the board. (R6 in the photo is wrong and should be R4)

Headers

Light diode polarity: The (green) marked end of the diode must point towards the D1 pad on the pcb.

Headers

Step 8

Solder the GY-91 onto the board using a 8-pin header.

Use the short end of the header downwards trough the board.

Make sure you place the GY-91 parallel to the shield to get the direction of the sensor x-, y- and z-axis parallel and/or orthogonal to the board.

Headers

Step 9

Solder the NTC temperature sensor and a 4.7 kΩ resistor onto the board.

R3: 4.7 kΩ

Headers

Step 10

Solder the sma connetor onto the board.

Headers

Remember to solder on both sides of the board.

Headers

Step 11

Solder the buzzer onto the board:

Headers

Put the buzzer legs through the holes in the board:

Headers

and solder on the back side:

Headers

Step 12

Solder the battery connection wire to the board.

Solder the red wire of the «battery connection wire» to the board at VIN and solder the black wire to the corresponding position marked GND. Only use batteries with voltages up to 5.5V, or change the default regulator to another that can handle voltages higher that 5.5V.

Attach a small amount of hot glue to the board where you soldered the wires. This will prevent the battery wires to break too easily.

Tip

You could use terminal blocks here as used in the micro:bit CanSat kit to prevent issues with wires breaking and avoid resoldering.

If you have chosen to use an external voltage regulator, you can use the position marked «3.3V» in stead of the VIN position.

Teensy 4.1 pin-out

The Teensy 4.1 has many advanced functions that we will not state here. If you would like to read more about them, please see the pinout page, the Sparkfun product page and the PJRC (which manufactures the Teensy boards) forum which is excellent.

In the figure below you can see the name and place of the Teensy 4.1 board pins that are the most relevant for the Cansat kit.

Purple pins are I2C, green is SPI, blue (RX1 and TX1) is UART, orange is analog (marked A0 to A22) and digital (marked DAC0 and DAC1) and the grey is GPIO. As you can see, some pins are multipurpose. Almost every pin can be used as GPIO, but only a few pins can be used as I2C, SPI and UART, and almost half of the GPIO pins can also be used as analog pinouts.

Please note that the Teensy CanSat kit has some specific uses of some of the pins, especially the SPI pins which are used by the radio. If you need SPI, you could in principle use the SPI0 bus, but life is going to be simpler for you if you use the SPI1 bus available on pin 0 (MOSI1) , 1 (MISO) and 32 (SCK), which can be seen on the general pinout page).

Pin-out

Teensy 4.1 pin-out. Image: https://www.pjrc.com/teensy/pinout.html

Kit components and pins

The completed kit seen in the image at the top of this page, you can see the Teensy 4.1 on the bottom side of the PCB. On the Teensy you can see the USB port on the right side of the figure, the microcontroller in the middle (the black square with text on it) and the micro-SD card mount on the left side. The buzzer, marked with text, is on the top left on the Cansat PCB and is free to be controlled by the user by GPIO. Here you can find the components list for this Andøya Space Education v2018 Cansat kit.

Graphics of an unpopulated top side

Graphics of an unpopulated top side. Image: Andøya Space

Graphics of an unpopulated bottom side

Graphics of an unpopulated bottom side. Image: Andøya Space

On the top right side the radio can be seen, and on the far right side the antenna SMA connector can be seen. The radio has a dedicated article (here) in the CanSat book documentation and will not be described further here. On the top middle, the GY-91 (IMU+pressure) board can be seen in a purple PCB color. This has a BMP280 pressure sensors and a 9 DOF MPU9255 IMU which has 3-axis accelerometer, 3-axis gyro and 3-axis magnetometer.

Graphics of the clear PCBs can be seen in figures above. As can be seen, many of the Teensy pins have an adjacent pin that you as a user of the Cansat kit can control as much as you would like. There are pins that are not broken out with an adjacent pin, however, and these are either for power (5V when connected to USB, Vin, 3.3V or Gnd) or for functions already in use by components on the Cansat kit. These functions are SPI0 for the radio, I2C0 for the IMU/pressure board and GPIO pin 29 for the buzzer. Analog channel A10 and A11 is used for the NTC sensor and for measuring the battery voltage (through a voltage divider).

Alternative pins/busses

Although the Cansat kit uses SPI0 and I2C0 already, you can in principle use this for other uses aswell. However, it is much easier for you to use a dedicate bus (a completely different component on the microcontroller that is independent on SPI0 and I2C0). Both SPI1 (pin 0, 1 and 32) and I2C1 (37 and 38)/ I2C2 (pin 2 and 3) can be used by you. This is also true for the UART which has Serial1 connected to pin 26 and 27 in addition to pin 0 and 1, Serial2 to pin 9 and 10, Serial3 to pin 7 and 8 and Serial4 is connected to pin 31 and 32.

CanSat Mechanics Design

Before dropping or launching the CanSat, the electronics and battery in the CanSat must be mounted on a bracket or in other ways secured in the can to be able to handle the stress of a launch and separation from a rocket or dropped to the ground from a drone.

An example is illustrated in the figure below, where the electronics is mounted on a robust bracket. The parachute must be connected to the bracket, not the can. The can is just a shield to protect the electronics against direct impact.

The CanSat with bracket

The CanSat with bracket. Image: Andøya Space

Another suggestion is a 3D-printed can, designed to keep the electronics and battery secure in place. Students at a Norwegian secondary school (Bodin VGS) designed a can for their cansat as the one below.

3D printed cansat can designes by students at Bodin Vgs

3D printed cansat can designes by students at Bodin Vgs. Image: Andøya Space

If you want to design your own can, you may want to start with this design file. See the Downloads section below. There you can find more examples of 3D printed mechanical structures.

The whole concept of CanSat is that neither weight nor volume shall be bigger than a standard soda can. You can find the (preliminary) requirements in the chapter on competition requirements.

The antenna should be a wire antenna because of its flexibility so when the CanSat lands, the antenna won’t be damaged during impact.

Programming the Arduino

Teensy is an Arduino compatible development board. This means that, other than the name, the board is to be viewed as an Arduino and programmed as such. The programming language that is used is C, but in a "variant" of it which is often reffered to as it’s own language, Arduino, but is really a set of libraries hidden to the user to make programming of the Arduino boards easier to learn and use. Often programs that are written in Arduino can be used across many boards as they are ment to be as cross-compatible as possible, but some of the features of one boards is not existing on others, so there are exceptions to this. This will be the same for you when using the Teensy.

Installing the Arduino IDE

Firstly, you need to download the Arduino IDE 2. An Integrated development environment (IDE) is a type of software running on a computer that is made to simplify programming of devices. The Arduino IDE is both used to write the code to be uploaded to the Arduino/Teensy boards and uploading the code itself to the bord. The IDE has built-in compilers and everything else needed to upload the code and will do that in the background when you tell it to do so.

There are different download options for Windows: The .exe-installer is preferred, as you can choose to install Arduino IDE as a single user or system-wide (for all users). Avoid using the Arduino Cloud Editor for the CanSat project.

Installing libraries

After installing the Arduino IDE, start the IDE. Andøya Space has written a couple of libraries to simplify working with the Teensy CanSat. Download the libraries for the GY-91 sensor and the GFM96 radio, and save it to your hard drive.

IMU GY-91 IMU RFM96

In the Arduino IDE, click the "Sketch" menu, further into "Include library" and press "Add .ZIP Library...".

How to include a zipped Library in Arduino

How to include a zipped Library in Arduino. Image: Andøya Space

The menu will then prompt you for the location of the zip files, but choose only one of them and press OK, and the Arduino IDE will import the library. Do this for both libraries, and you should be good to go.

Connecting the Teensy

Connect the CanSat board (or only the Teensy if you have not yet soldered it to the CanSat PCB) using a Micro-USB to USB cable to your computer. This should automatically download the proper driver to your computer and install it.

Teensy is supported using Arduino’s Boards Manager. A separate installer is no longer needed, but to enable support, an "additional boards manager URL" must be added in the preferences screen. Click File > Preferences and add this link: https://www.pjrc.com/teensy/package_teensy_index.json

Screenshot from Arduino IDE Photo: Andøya Space

Adding support for Teensy in Arduino IDE Photo: Andøya Space

Click the OK button and the board manager now see the Teensy board. Click Install to start the download.

Screenshot from Arduino IDE Photo: Andøya Space

Adding support for Teensy in Arduino IDE Photo: Andøya Space

When completed, you can select the board version and start proceed to the programming part.

Screenshot from Arduino IDE Photo: Andøya Space

Adding support for Teensy in Arduino IDE Photo: Andøya Space

When a new Teensy is connected to power it runs a standard program (called sketch in Arduino) which blinks a LED light on the board every second. If this does not happen and the Teensy is brand new (no new program has been uploaded), check the connections and that the Teensy has power and is not short circuited.

Here is the blink program example:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Upload your first program

After you have properly configured the Teensy board in the Arduino IDE, we can upload our first sketch. Start with a fresh, new program (File -> New…) and press the "Upload" button (which will store the program, compile it and then upload it to the board) as seen in the figure below.

Screenshot from Arduino IDE Photo: Andøya Space

Uploading code in Arduino IDE Photo: Andøya Space

If your Teensy was blinking, the blinking should stop after uploading this sketch. An upload progress var can also be seen in the tiny Teensyduino add-on window that should have appered (note that it might be hidden behind other windows you have on your screen). If the upload was not a success, a error should appear in the bottom of the Arduino IDE in orange text stating:

Teensy did not respond to a USB-based request to automatically reboot.
Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.

If you have checked that the Teensy is properly connected and configured in Arduino IDE, try uploading the sketch again and press the button on the Teensy board (the physical board) at the same time (a single tap is enough). It is very rare that this is needed, so if you got an error message, it is more likely that there is something wrong on your end (either bad connections, wrong configuring or power issues).

Read data

Open the Serial Monitor to look at the data which is received from the Arduino Uno board. The Serial Monitor is opened by clicking the icon to the right in the toolbar (Figure to the right). The Serial Monitor will open a new window which will give you a serial text stream of the data printed from the Arduino Board.

Screenshot from Arduino IDE Photo: Andøya Space

Serial monitor in Arduino IDE Photo: Andøya Space

Testing the CanSat kit

Now that you have assembled the CanSat kit, we are ready to test the kit. In this article we will first load in a sketch to the Teensy, and do some simple testing with GPIOs and the ADC. After that we will test the Cansat kit itself with some of the onboard components.

Loading the first sketch

First, start by connect the Teensy board (which now is mounted to the Cansat PCB) by USB cable. We do not need any more power than USB for now (now battery needed). When plugging in the cable, the LED light on the Cansat PCB should light up. If not, please detach the board and problem-solve why. All computers have a fail safe that will demount a USB device if it draws too much power, so if you have a short-circuit, your computer will try to demount the Teensy device and you will normally need to do a reboot. This is what normally what should happen, at least.

When you imported the two Cansat related libraries into the Arduino IDE, some examples was automatically added. We will start be using these now. First, go to Files -> Examples and locate the Cansat_RFM96 sub-menu. There you will find the sketch called «Cansat_DigitalAndAnalog». Select this and upload it to the Teensy. Remember to configure the Arduino IDE to use the Teensy properly with the Tools -> Board and Tools -> Ports as you have already done in the «Getting started with the primary mission» chapter page. There is not need to alter this program before running it.

After a successfull upload, open the Serial Monitor by either pressing the magnifying glass icon on the top, right side of the IDE window or go to Tools -> Serial Monitor. The Serial monitor window will show you all the communication from the Teensy to the computer (not the other way around).

(For the advanced user merging from other Arduino boards: there is no need to change the baud rate in the Serial monitor due to the USB core communication on the Teensy boards, unlike on other Arduino boards which uses a UART to USB bridge which is baud rate dependent. The Teensy 3.5 is a true 15 Mbps USB device independent on the baud rate you set.)

Text should now appear in the window similar as to in the figure below, with a new line every second. We output the time since the microcontroller started running in milliseconds, the value of the digital pins 2 and 3 and the voltage at pin A0 and A1 (already converted for us in the code).

Screenshot from Serial Monitor.

Screenshot from Serial Monitor. Screenshot: Andøya Space

The Teensy board has many pins on the outer edges, and the all the pins on the Teensy that is available for your control (some of the pins are used by functions on the board and should never be used by the user) has an adjacent 0.1″ header pin. If you see closely you can see that these header pins (which should be unpopulated) are electrically connected to the pin closest to it on the Teensy. So whatever voltage you set on that pin, that is the voltage that the Teensy will measure. Take a jumper cable which should have been given to you by the tutor and take one line at the header pin marked 3.3V on the Cansat PCB and the other end on digital pin 2 and 3, and on the analog pin A0 and A1. See Figure 2. What happens with the values in Serial Monitor?

Pins A0, A1, D2, D3 shown

Pins A0, A1, D2, D3 shown. Photo: Andøya Space

The digital pin 2 is configured as an input without so called pullup or pulldown resistors, but pin 3 is configured in software to have pullup. What that means is that, if nothing drives the line, meaning actively setting the voltage to something, the voltage will always be high (3.3 volts) since it is tied to a resistor with a high resistance to 3.3V. You might see the difference between the two when you connect a jumper cable between 3.3V and the two digital inputs 2 and 3. Actively setting 3.3V by you with the cable on pin 3 should make no difference to the output, it should just stay at 1 (logic high). Doing the same thing with pin 2, however, which do not have a pullup resistor, could make a difference. Dependent on multiple factors, the pin will always be logic high when you set the voltage to 3.3 volts with the cable, but might go to 0 when not being set by you (when not using the cable on the pin).

What happens when you set 0 V (there is a header pin marked with GND on the Cansat PCB, which means 0V power line) on pin 2 and 3? Try both, and also see what happens when you do the same with analog pin A0 and A1. What happens if you only touch A0 and A1 with your finger without using a cable? In some cases you can adjust the voltage level on the analog input, as all human bodies act as a capacitor (watching the voltage level from your finger on much higher sample rates than 1 Hz will show you rapid changes in voltage levels!).

Testing the Cansat components

We will now try and read the sensors which you soldered on the board. As in the previous case, go to Files -> Examples and find the sketch called «Cansat_TestCB». This is a ready-made sketch that tests the onboard sensors. From the start, it outputs these values:

Battery voltage (floating if no battery is connected)
Temperature of the NTC sensor in centrigrades
Accelerometer in x, y and z direction
Gyroscope in x, y and z direction
Magnetometer in x, y and z direction
Pressure in hPa/mbar

To view the data, open Serial Monitor again to see the data streaming out over the USB port, ten lines pr second. See figure below:

Screenshot from Serial Monitor

Screenshot from Serial Monitor. Screenshot: Andøya Space

But a new feature in Arduino is that you quite easily can plot! The format being output by the Cansat shield is in the format that the plotting tool wants. Close the Serial Monitor and open the Serial Plotter in the dropdown menu Tools. The problem with plotting all of these parameters is that they are quite difference. The pressure is around 100 and if you lift up and shake and turn the Cansat you will see that it is not easy to see all of the graphs at the same time, since they all share the same vertical axis. We need to do something about that, and we will do that next.

Close the Serial Plotter and scroll to the top of the sketch. You will see these lines close to the top:

    #define USE_BUZZER         0
    #define OUTPUT_TEMP        1
    #define OUTPUT_VIN         1
    #define OUTPUT_ACC         1
    #define OUTPUT_GYRO        1
    #define OUTPUT_MAG         1
    #define OUTPUT_PRESSURE    1

These are precompiler flags that let you include or dont include parts of your code (in addition to a bunch of things, that we will not touch upon here). Set all of these to 0 instead of one except the one with OUTPUT_TEMP in it. This make the precompiler only include the part of the code that outputs the temperature, not output the other things. In the code, you can see what it will include or not include by these logical statements:

    #if OUTPUT_TEMP == 1
        Serial.print(read_temp_direct());
        Serial.print("\t");
    #endif

If you set

    #define OUTPUT_TEMP 1

the precompiler will include the code, and if you change the 1 to a 0 like

    #define OUTPUT_TEMP 0

it will not include the code. This make it quite easy for you as a user to enable or disable some parts of the code, without knowing how the code works. So set all of the #define lines to 0 except the temperature line, and upload the sketch again. Make sure that you have closed the Serial Plotter window before uploading the code. After you have uploaded it, open the Serial Monitor and see that it is only one column of data streaming out pr line, and this should be the approximate temperature of the Cansat kit (the NTC sensor). Close down the Serial Monitor window and open the Serial Plotter. You should know see some variance in the data, and while touching the NTC sensor to heat it up, you should see great change in temperature. See figure below as an example of this.

Screenshot from Serial Plotter

Screenshot from Serial Plotter. Screenshot: Andøya Space

In some cases it can be better to view the data in the Serial Monitor as text and in others it can be better to plot. Often when viewed in Serial Monitor it can be better to output all the data at the same time, and most often it is better to output only a few things when using the Serial Plotter. Play around with this!

If you wonder what the x axis in the Serial Plotter is, its the number of samples it got since you opened it. So since we’re outputting at 10 Hz, its the number of seconds divided by ten since you opened the window.

Understanding the code

Lastly, we have made a fun, little quirk in the program. If you enable the USE_BUZZER flag with the line

    #define USE_BUZZER 1
and open Serial Plotter and at the same time as outputting the temperature variable, what happens when you heat up the temperature sensor? Play around with this, and find out where and how this works in the sketch and where you can adjust the treshold.

Understanding code written by others is quite usefull, at least at the start. There are parts of the code that will be usefull for you to use later on, so it will be very good for you to spend some time trying to understanding this sketch, at least parts of it.

Analog-Digital conversion on the Teensy

On the Teensy there is many pins that can be connected to external peripherals and devices. The pins can work in two ways: as inputs and outputs. If the pin is used as an input, the program measures what the voltage level is on the pin and returns that to the user. If the pin is used as an output, the user tells in the program what the voltage level should be on that pin and the microcontroller actually forces that voltage to be that value (either digital or analog, see below).

The Teensy is more powerful than most other Arduino boards, and all pins has more than one function. The pin functions can be divided into two categories: digital and analog. The digital pin functions can measure digital input and also output digital values. Digital values are either high (also often given as a ‘1’) value, in this case 3.3V, or a low value (often called ‘0’) with a voltage level of 0 volts. When it measure/samples a pin, that is measuring what the voltage is on that pin, it measures a high/true/1 if the levels are 3.3V or close to it. If it measures 0 volts or close to it, it registers it as a low/false/0. If the voltage is, for some reason, not close to either 0 or 3.3V however, the output can be either registered as a high or low, dependent of several factors. Computers live in a digital world and the usages of only measuring binary/digital values are huge, and one advantage is that it is extremely fast: the Teensy can output/input a digital values in less than 10 nano seconds!

If you want to measure or output not only digital values, the Teensy has two special internal peripherals called Analog to Digital converter (ADC) and a Digital to Analog Converter (DAC). Since all microcontrollers (which is essentially a simplified miniature computer) can only handle digital values the ADC and DAC works as an interface to an analog world: the ADC on the Teensy measures up to 4096 (12 bit) different linearly spaces analog values between 0 and 3.3 V. The DAC works in the completely opposite way: it takes a 12-bit value from the program and forces the pin to be on that value until it is changed by the user to another value. The Teensy has one ADC (technically three ADCs, but dont worry about that as they look like one for you as a user) and one DAC. However, that ADC and DAC has many channels, so even though it can only read input/output one at a time, it can work on many different pins. The DAC has only two pins (called DAC0 and DAC1) but the ADC has 26 channels/analog input pins, where 19 of them are available to you as a user (some is used for functions on the NAROM 2018 kit already and some are on pins that are not easily accessable).

We have discussed digital input/output pins already, but it is a sub-category of digital pins we have not yet talked about. There are only two voltage levels on digital pins, but the voltage levels can vary in time in many (infinite) different ways. The most popular way to communicate with the outside world is through serial communication: this is where one or a few pins vary dependently on each other in a very specific way based on some standard. You are guaranteed to have heard of USB communication: this is a serial protocol with two wires working together as one output in a special way (if we dont consider the new variants) to communicate in a extremely fast, standardized fasion between devices. In the embedded world of microcontrollers there are numerous other serial communication standards, with UART, SPI and I2C as one of the more famous/widespread, but all of these work with the same basic idea: alternating one/few pins in a specific way in time makes communication fast, cheap and simple. There are reasons not to use parallel communication which was very popular in the 80s and 90s which we will not come into here.

Downloads

IMU GY-91-library Radio RFM96 library GY-91 first_sketch 3D print by Bodin vgs More 3D CanSat designs