Teensy – Arduino on Steroids

I love the Arduino Eco-System. Although I do not really like the IDE, the whole system is awesome. And it allows to quickly prototype ideas. And, as everything is Open Hardware, it also allows you to build your own PCBs with the same components used by Arduino. I am not in the business for creating a large-scale electronics product. But it’s very important for me that I could.

While working on my DIY Home Automation System I noticed some limitations with the current Arduino Hardware Offers. I have created my own Atmel 328p based PCB for my sensor nodes. The Atmel 328p is the MCU that drives Arduino Uno, Nano, Micro Pro, Sparkfuns Redboard and various other Prototype Systems. This MCU is quite fast (up to 20 MHz), can be run on batteries for a long time (if you care about your current consumption) and is easy to use program with the Arduino IDE. But there are limitations. You only get about 2K SRAM and 32K of program memory. That is enough for devices that only connect to a few sensors, driving a few motors, etc. But it’s not enough for more complex projects.

My DIY Home Automation Network needs a hub, that acts as a bridge between the Internet and the sensor nodes. Sensor Nodes are using nRF24L01+ Radio Modules. The Hub also hosts such a radio module, but has to send the signals in to the cloud. Although I wanted to have nice devices in the end I tried an Arduino Yun as a hub. The hub does not have to be very pretty as it will be placed in a small room that is not exposed. A small enclosure will do it. Arduino Yun is a great device that hosts both an Arduino MCU and a full-fledged Linux on the same device, connected with a bridge. Using the bridge you can run shell commands from the Arduino MCU on the Linux side and receive the results. You do not have to build a whole HTTP-client, as Linux already has one. I have written a small tutorial about that: Running Node.js on Arduino Yun.

All of that worked fine – in the lab. Using the sensor networks in the wild (well, in my house), I found it very difficult to debug the system. In order to save power the nodes do not have any LEDs, Display, whatever. I added some LEDs to the Arduino Yun that showed it’s state and if sensor data came in. But all in all it did not really help. I found sensor data in the cloud, but not from all nodes. And I could not really see the routing in the nRF24L01+ network. Attaching displays to the sensor nodes has not been an option due to power restrictions. I had to add a display to the hub. That would give me the option of adding some sort of user interface to it. But Arduino Yun only has 2K SRAM, and adding a display and it’s quite large driver code I ended up with not enough SRAM left. I could optimize everything so it perhaps would fit, but I would not have any room to add a UI to the hub later on. I have been quite disappointed about this limitation. I think the Yun should have built with a beefier Arduino-MCU. It should be possible to drive a display trough the bridge from the Linux side, but that would be way to slow. Although I really liked the idea of the Yun, it did not fit my needs.

Teensy is here to help

Searching for an Arduino Compatible small device Google with tell you to have a closer look at: Teensy. Teensy is just an amazing piece of hardware, created by Paul J Stoffregen. Paul did an amazing job with Teensy, especially the latest version 3.1. Teensy ist very small. If you find an Arduino Nano or Micro Pro small, you will be amazed how small Teensy really is. And it’s very, very powerful. Teensy features an ARM Cortext MPU with 64 KB SRAM and 256 KB Program memory. That is a lot of space and enough to do a lot of cool stuff. What I really love about the Teensy is how bootloading it is solved. I had a few issues with programming Arduinos. Teensy features a tiny uploader software, that is either triggered by the Arduino IDE or by pressing the reset button on the device. And uploading new code always worked. I really love that. Just install the Teensy Hardware Plugin in your Arduino IDE 1.0.x (it does not support 1.5.x at the moment) and you are good to go.

There are a lot of Arduino Compatible devices out there, typically featuring beefier ARM Cortext MPUs. SparkCore, RFDuino, Intel Galilleo, you name it. All of these devices are called Arduino Compatible in that they run simple sketches without porting code. What they really did is, that they ported the Arduino Wiring API (analogRead, pinMode, etc) to their own platform. That way the simple sketches just run on them. But If you want to use external libraries for LCD Displays, sensors, etc. you might run into problems. You will have to port them yourself. What I love about Arduino is that rapid in rapid prototyping. For a lot of sensors, motors, components and devices there are Arduino libraries available. Hook up the wires, import the library, run a Sample and you are ready to build on that. Porting code just for testing a new component does not make sense for me. And therefore my SparkCore and RFDuino did not get much love.

Teensy should have the same issues: Code must be ported to the platform in some cases. But Paul does an amazing job doing that. Just check out the official Adafruit Libraries. In nearly all of them Paul did some work to support Teensy. He did optimize LCD Display drivers to the max featuring very, very fast frame rates when these displays are used with a Teensy. All in all I did not find a single library that did not work out of the box with my Teensy (3.1). That is how Arduino compatible devices should work. And Paul does an amazing job. Paul, if you read that: Thank you very much!

Teensy with CC3000 = Internet of Things Device

I had so much fun with my Teensy, that I decided to give it a try, although that means that I had to rewrite my hub from scratch (well that sending sensor data to the web as the RF24 Libraries just worked out of the box). I opted for an Adafruit CC3000 breakout module for my tests. Be sure to buy the V1.1 version as the previous version had problems with multiple SPI devices. CC3000 is a very capable device with a lot of great features and a very good library to get started. This library also works with Teensy out of the box. With just a few lines of code you can connect to a WLAN Network and can create GET-Requests. Running the Internet Time and Date Sample worked out of the box.

My Teensy now runs these components simultaneously (using SPI):

Running all these devices with an Atmel 328p based MPU has not been possible as 2K SRAM have not been enough. But Teensy’s 64KB SRAM are more than enough to implement a great Touch based User Interface and all the Network Routing functionality.

There have been some issues though. It’s necessary that you use Teensys Hardware SPI (11,12,13 for Miso, Mosi and Clk) and you have to use specific Pins for chip select. See your Teensy 3 pinout diagram for more infos which pins should be used.

I hope you had some fun reading and if you are into that Internet of Things stuff, I really encourage you to have a closer look at the Teensy CC3000 combination.

2 thoughts on “Teensy – Arduino on Steroids

  1. Phillip, I was recently introduced to the Teensy 3.1 board and as well trying to integrate home automation system that is truly learnable and activated by voice and sensors. however when it comes to electronics I really don’t know that much about wiring boards or writing code (other than some html). I know how to make the system work via internet But I don’t know how to design/build/code it. Teensy 3.1 is the way to begin and my R&D lead me to you. Email me. Please. Lets create something. D.Brandt007@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *