Blog Home

TinyGo on Arduino

Arduino TeamAugust 23rd, 2019

A few weeks ago, we announced that Arduino now works with TinyGo, the popular compiler that brings the Go programming language to microcontrollers. We had the opportunity to sit down with Ron Evans, Technologist for Hire, and learn more about the Arduino and TinyGo integration.

Some of our audience knows about Go (we ourselves use it to develop many of our tools). In a few words: what is TinyGo and how does it stand compared to Go itself?

TinyGo is a Go compiler for small places like microcontrollers. TinyGo is written in Go like the standard Go compiler, but TinyGo then uses the LLVM toolchain to compile Go programs to a fraction of their normal size. TinyGo also employs a different runtime implementation in order to target constrained environments.

Why choosing TinyGo over other languages?

If software is eating the world, then Go is eating the world of software. The popularity of Go is still rapidly expanding, and TinyGo helps bring the new “enterprise standard” language down to the smallest of processors. Also as a compiled language, TinyGo can offer substantially better performance and size efficiency than that of interpreted languages like JavaScript and Python.

How does TinyGo compare to embedded python and JavaScript implementations?

One good reason to use Go is the clear and maintainable code that Go insists that you create. Generally speaking, the normal Go tooling that is included with the language itself is what you use when writing TinyGo code. For example, the standard built-in code formatting. TinyGo includes implementations of the Go “net” package targeting the Arduino Nano33 IoT, so you can more easily reuse existing Go code for TCP/UDP or higher level protocols such as MQTT. This really makes it a lot easier to build commercial or industrial IoT solutions.

Another reason to use TinyGo is the ability to utilize Go’s concurrency. TinyGo implements “goroutines,” which can greatly simplify your code to take the greatest performance advantage offered by modern 32-bit microcontrollers.

With security in IoT being one of today’s hottest topics, which tools does TinyGo offer that enable the development of secure projects?

There are a number of things that can make development, deployment, and operations using TinyGo good for edge computing applications that require greater security. Since the code is compiled to binary, it is possible to use code signing and other well known approaches for secure computing.

Another is that any device data must be encrypted while in transit from from the device to any cloud storage or analytics. TinyGo on the Arduino Nano33 IoT can use standard APIs for SSL communication to cloud services, such as using the Eclipse Foundation’s Paho MQTT client for Go. This makes it a lot easier for developers to do the right thing the first time when creating applications.

How can TinyGo improve the Arduino ecosystem? How will our existing audience benefit from using it? Will they be able to use the Arduino libraries already existing?

There is a very active community in the Arduino world, with lots of existing useful libraries. We are planning much deeper integration for TinyGo powered by Arduino, more on this in the near future…

Many people love TinyGo because it’s simple yet powerful. Do you see any similarity with the Arduino mission of ‘making technology simple for everybody?'”

Arduino has really pioneered the open hardware movement, and defining clear APIs to devices has been a huge contribution. TinyGo very much tries to embody this same spirit, while at the same time provide an idiomatic Go language programming experience. Combine the sensibilities that have made TinyGo so popular and that are fueling our continuing growth, alongside the amazing capabilities powered by Arduino, and there are no limits to what we can do!

If you want to learn more about TinyGo, click here and here. During Gophercon, Ron Evans ran a hacking session dedicated to the Arduino Nano 33 IoT and TinyGo — you can discover more on this dedicated page on GitHub