Flip & Click: compatible libraries

Some of the links on this blog are affiliated links. READ MORE

So, you’re the lucky owner of a Flip & Click board. What’s next? Will the click boards you already have work with the Flip & Click? In this blog post I will try to answer this question, and I will try all the click boards I have, identifying the code libraries that are Arduino Due / Flip & Click compatible.

According to this Wikipedia article, the first Arduino Diecimila was released in 2007 and it featured an ATMEGA168 microcontroller. The now ubiquitous Arduino Uno was released in 2010, aequipped with an ATMEGA328P microcontroller. All these Arduino boards have 5V logic levels. Besides this, after five years of its existence a lot of software libraries were written for the Arduino Uno.

In 2012 Arduino Due was born, featuring a ATSAM3X8E microcontroller, with a completely different processor architecture compared to the 328P, and 3.3V logic levels. Then came the Flip & Click in 2015 – that’s basically a redesigned Arduino Due board, with four extra mikroBUS sockets. Now, regardless if you have a Flip & Click board or an Arduino Due you’re facing a nasty problem: some early Arduino libraries are written using pure 8-bit C code, and they use direct access to the ATMEGA328P registers and timers. Those libraries will not work with the Due.

So, the big question is: what does work? There are two issues here: one is the 3.3V logic, so you need shields and breakout boards that are 3.3V compatible. The second issue is to find the software libraries that work with the Arduino Due.

I “solved” the logic level issue by using Click boards from MikroElektronika – think of those little boards as like mini shields. With a few exceptions, those boards are 3.3V configurable (actually they come with 3.3V voltage as factory setting). Take one Arduino Due, add one Mega Click Shield and the problem is almost solved: all you have to do is to find the correct pinout. If you have the Flip & Click it’s easier: just plug the click boards of your choice and you’re ready to go.

Now it comes to the software. The issue here is to find the libraries that work with the Due. This is what I do in this blog post: I will try all the click boards that I have and find the software libraries that work with the Arduino Due. All tests are performed using Arduino IDE version 1.6.6 from Arduino.cc. There’s no particular order, I will add click boards as I will test them. So, here we go:

BUZZ click

Driving a buzzer. Sounds simple, but the tone library in Arduino IDE doesn’t work with the Due. It seems that some functions have to be redefined to work with the timers inside ATSAM3X8E . This post from forum.arduino.cc provides the required functions definitions.

SHT1x click

In the SHT1x family from Sensirion we find several temperature/humidity sensors, the only difference being in the precision. The SHT1x click uses I2C lines for the sensor, albeit the sensor has its own dedicated communication protocol. One word of caution: there are pull-up resistors on the click board. If you place many I2C click boards of the Flip & Click, all these pull-up resistors will come in parallel, and so the current needed to pull down the pins will be higher. Beware that I2C lines have 3mA source/ 6mA sink current. Don’t go past these values or you will damage the microcontroller. There is also a SHT1x breakout board from Sparkfun. That board offers the possibility top disable the pull-up resistor completely. As for the rest, it goes just as the SHT1x click.

The library that I found to work is available from https://github.com/practicalarduino/SHT1x/.

Thunder Click

The trick here is to attach the interrupt needed by the AS3935 sensor as described here. Otherwise the code example published on my blog works fine.

Color click

It seems that the wire library for the ATSAM3X8E is seriously fucked up. Nothing works with this.

I found that I can use the Arduino.org IDE (zip file for non-administrator install) and by applying the patch described here I can make I2C to work.

This is a confirmed bug in the arduino Wire library:  https://github.com/arduino/Arduino/pull/1994




And overwrite in your arduino installation: hardware/arduino/sam/libraries/Wire/Wire.cpp

For me, this just fixed i2c on the Due.

Other people said that it gave a compile error – I don’t know why.

With this fix I found that the code library written by Raivis Rangelis and available on https://github.com/raivisr/TCS3471-Arduino-Library works fine. You may also wish to read my previous post regarding the use of color click board.

UV click

There is no code library for this click board. All you have to do is to read the data from the MCP3201 ADC. Just take the code from the Color and UV sensing project and keep only the code lines for the SPI communication.

As the A/D converters inside ATSAM3X8E have 12 bits resolution, you might wish to skip the MCP3201 ADC and read directly the output of the ML8511 IC UV sensor by changing the position of jumper J1 (A/D SEL). The resolution of the A/D converter of the Due can be changed using analogReadResolution().

Current Click

This lovely click board features one INA196 current shunt monitor, one MAX6106 voltage reference and the same MCP3201 12-bit ADC you find on the UV click. As such, one can use the code from the UV Click plus some computations to determine the actual current value based on the A/D result and shunt value.

Or you can just simply use the AN output of this click board and read the voltage using the ATSAM3X8E internal A/D, same as above.

Interrupt-driven click boards

There are several click boards that can be placed here. All these click board have in common the fact that they trigger an interrupt at when an event happens. As such, they don’t require a dedicated software library but an interrupt routine. As in Arduino Due (and the Flip & Click board) all pins can be used as external interrupt sources all you have to keep in mind is to correctly attach the interrupt in Arduino IDE – by this i mean that you will have to use attachInterrupt(digitalPinToInterrupt(pin), ISR, mode); syntax as described here.

Vibra click

This one uses just two pins: EN pin to enable/disable the sensor, and the INT pin to signal vibration. Sensitivity is adjusted in hardware using the potentiometer on the vibra click board.

Comparator click

Two comparators on one single click board, each comparator issuing its own interrupt.

Motion click

PIR type sensor, triggers one interrupt when motion is detected. Sensitivity is adjusted with the pot on the motion click board. Requires one EN pin to enable/disable motion sensing.

Shift-register based click boards

In this category we find the Bargraph click and the 7 seg click. Both boards will work fine with the ShiftOut function in Arduino IDE.

4×4 RGB Click

This works just fine with the Neopixel Adafruit library I used in other 4×4 RGB click projects.

WiFly Click

The first step to develop a nice IoT project is to connect to the Internet. The WiFly click is one of the few click boards that allow your Flip & Click to join a Wi-Fi network, with the help of a RN-131 embedded wireless LAN module. This click board uses serial communication, so don’t expect a blazing speed 🙂

I found that this library from https://code.google.com/p/wiflyserial1/ works fine. As prerequisites don’t forget to install first the Streaming library from http://arduiniana.org/libraries/streaming/ and the Pstring library from http://arduiniana.org/libraries/pstring/.





Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.