Posts with «tronixstuff» label

First Look – Arduino M0 Pro with 32 bit ARM Cortex M0

Here at tronixstuff we keep an open mind with regards to new hardware, and in this spirit we have the following “first look” of the new Arduino M0 Pro (previously called the Arduino Zero) from Arduino SRL. If the term Arduino SRL is new to you – click here to learn more.

This is the second Arduino-branded board that takes the leap from 8-bit to 32-bit microcontrollers (with the Due being the first), and according to Arduino SRL offers a lot of promise:

With the new Arduino M0 pro board, the more creative individual will have the potential to create one’s most imaginative and new ideas for IoT devices, wearable technologies, high tech automation, wild robotics and other not yet thinkable adventures in the world of makers.

The Arduino M0 pro represents a simple, yet powerful, 32-bit extension of the Arduino UNO platform. The board is powered by Atmel’s SAMD21 MCU, featuring a 32-bit ARM Cortex® M0 core.

With the addition of the M0 board, the Arduino family becomes larger with a new member providing increased performance.

The power of its Atmel’s core gives this board an upgraded flexibility and boosts the scope of projects one can think of and make; moreover, it makes the M0 Pro the ideal educational tool for learning about 32-bit application development.
Atmel’s Embedded Debugger (EDBG), integrated in the board, provides a full debug interface with no need for additional hardware, making debugging much easier. EDBG additionally supports a virtual COM port for device programming and traditional Arduino boot loader functionality uses.

Lots of buzzwords in there, so let’s push that aside and first consider the specifications:

Microcontroller – ATSAMD21G18, 48pins LQFP – the “main” microcontroller
EDBG Microcontroller – AT32UC3A4256, 100pins VFBGA
Operating Voltage – 3.3 V
DC Input Voltage (recommended) – 6-15 V
DC Input Voltage (limits) – 4.5-20 V
Digital I/O Pins – 14, with 12 PWM and UART
Analogue Input Pins – 6, 12-bit ADC channels
Analogue Output Pins – 1, 10-bit DAC
DC Current per I/O Pin – 7 mA
Flash Memory – 256 KB
SRAM – 32 KB
Clock Speed – 48 MHz

Lots of good stuff there – increased clock speed, increased flash memory (sketch space) and SRAM (working memory). No EEPROM however you can emulate one.

Note that the M0 Pro is a 3.3V board – and also the DC current per I/O pin is only 7 mA. Once again the user will need to carefully consider their use of external circuitry and shields to ensure compatibility (as the “classic” Arduino boards are 5V and can happily source/sink much more current per I/O pin).

The ADC (analogue-to-digital) converters have an increased resolution – 12-bit… and the addition of a true DAC (digital-to-analogue) converter allows for a true variable voltage output. This could be useful for sound generation or other effects. You can pore over the complete details including board schematics from the website.

Moving on, let’s have a look around the Arduino M0 Pro board itself:

You can’t miss the sticker asking you to download the IDE – as Arduino SRL have forked up the Arduino IDE and run off with it. Click here to download. Upon removing the sticker you have:

Note the connector for the JTAG interface which works in conjunction with Atmel Studio software for debugging. You can also use the USB connection which connects to the EDBG microcontroller (example). When Atmel offers a native MacOS version we’ll investigate that further. SPI isn’t D10~D13 as per the older boards, instead it is accessed via the six pins on the right-hand side of the board. Turning the M0 Pro over doesn’t reveal any surprises:

And like the Due there are two USB ports:

A Programming USB port for uploading sketches through the Arduino IDE and “normal” use, along with a native USB port for direct connection to the main microcontroller’s serial connection. For “regular” Arduino IDE use, you can stick with the Programming port as usual.

So let’s try out the M0 Pro. We’ve downloaded the IDE (which can co-exist with the IDE). Drivers are included with the IDE for Windows users, so the board should be plug and play. Note that if you need to reflash the Arduino bootloader – Atmel Studio is required. Moving on – within the Arduino IDE you need to set the board type to “Arduino M0 Pro (Programming Port)”:

… and the Programmer to “M0 Pro Programming Port”:

… both of these options are found in the Tools menu. When using these faster boards we like to run a simple speed test that calculates Newton Approximation for pi using an infinite series, written by Steve Curd from the Arduino forum. You can download the sketch to try yourself.

In previous tests the Arduino Mega2560 completed the test in 5765 ms, and the Arduino Due crushed it in 690 ms. As you can see below the M0 Pro needed 1950 ms for the test:

Not bad at all compared to a Mega. Thus the M0 Pro offers you a neat speed bump in an Uno-compatible form-factor. At this point those of you who enjoy making your own boards and dealing with surface-mount components have an advantage – the Atmel ATSAMD21G18 is available in TQFP package for under US$6… so you could cook up your own high-performance boards. Example.

At this point I’m curious about the onboard 10-bit DAC that’s connected to pin A0, so I connected the DSO to A0 and GND, and uploaded the following sketch:

void setup() 

void loop() 
  for (int i=0; i<1024; i++)
  for (int i=1023; i>=0; --i)

… which resulted with the following neat triangle waveform:

… and here it is with the statistics option:

With a frequency of 108.7 Hz there’s a lot of CPU overhead – no doubt controlling the MCU without the Arduino abstraction will result with increased performance. Finally – for some other interesting examples and “how to” guides for the M0 Pro, visit the Arduino labs page for this board.

Conclusion for now

There are many pros and cons with the Arduino M0 Pro. It is not the best “all round” or beginner’s board due to the limitations of the hardware GPIO. There’s the DAC which could be useful for creating Arduino-controlled power supplies – and plenty of PWM outputs… but don’t directly connect servos to them. However if you can live with the current limits – and need a faster clock speed with an Arduino Uno-compatible board type – then the M0 Pro is an option for you.

Furthermore the M0 Pro offers an interesting bridge into the world of 32-bit microcontrollers, and no doubt the true performance of the MCU can be unlocked by moving away from the Arduino IDE and using Atmel Studio. If you have any questions for the team about the Arduino M0 Pro ask in their support forum.

And if you would like your own Arduino M0 Pro – is offering a 10% discount off this new board until the end of November 2015. Enter the coupon code “tronixstuff” in the shopping cart page to activate the discount**. – which along with being Australia’s #1 Adafruit distributor, also offers a growing range and great value for supported hobbyist electronics from Altronics, DFRobot, Freetronics, Jaycar, Seeedstudio and much much more.

As always, have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

** discount not available in conjunction with any other offer, and not valid for CCHS/MELBPC deliveries or pickup orders. 

The post First Look – Arduino M0 Pro with 32 bit ARM Cortex M0 appeared first on tronixstuff.

Control your Arduino over the Internet using Blynk


There are many ways of remotely-controlling your Arduino or compatible hardware over the Internet. Some are more complex than others, which can be a good thing or a bad thing depending on your level of expertise. Lately we’ve become more interested in this topic and have come across Blynk, which appeared to be a simple solution – and thus the topic of our review.

What is Blynk?

From their website: “Blynk is a Platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. It’s a digital dashboard where you can build a graphic interface for your project by simply dragging and dropping widgets. 

It’s really simple to set everything up and you’ll start tinkering in less than 5 mins. Blynk is not tied to some specific board or shield. Instead, it’s supporting hardware of your choice. Whether your Arduino or Raspberry Pi is linked to the Internet over Wi-Fi, Ethernet or this new ESP8266 chip, Blynk will get you online and ready for the Internet Of Your Things.” Here is the original launch video:


Blynk started off as an idea, and raised initial funding through Kickstarter – which was successful and the system has now launched. Blynk comprises of an app on your smartphone (Android or iOS) inside which you can add widgets (controls) to send commands back to your development board (Arduino etc.).

For example, you can add a switch to turn a digital output on or off. Furthermore, data from sensors connected to the development board can be send back to the smartphone. The data passes through the Blynk Cloud server, or you can download and run your own server on your own hardware and infrastructure.

How much does it cost?

Right now (September 2015) the Blynk system is free. We downloaded the app and experimented without charge. We believe that over time there will be payment required for various functions, however you can try it out now to see if Blynk suits your needs then run with it later or experiment with other platforms.

Getting Started

Well enough talk, let’s try Blynk out. Our hardware is an Android smartphone (the awesome new Oppo R7+) for control, and a Freetronics EtherTen connected to our office modem/router:

You can also use other Arduino+Ethernet combinations, such as an Arduino Uno with an Ethernet shield. First you need to download the app for your phone – click here for the links. Then from the same page, download the Arduino library – and install it like you would any other Arduino library.

For our first example, we’ll use an LED connected to digital pin 7 (via a 560 ohm resistor) shown above. Now it’s time to set up the Blynk app. When you run the app for the first time, you need to sign in – so enter an email address and password:

Then click the “+” at the top-right of the display to create a new project, and you should see the following screen:

You can name your project, select the target hardware (Arduino Uno) – then click “E-mail” to send that auth token to yourself – you will need it in a moment. Then click “Create” to enter the main app design screen. Next, press “+” again to get the “Widget Box” menu as shown below, then press “Button”:

This will place a simple button on your screen:

Press the button to open its’ settings menu:

From this screen you can name your button, and also determine whether it will be “momentary” (i.e., only on when you press the button) – or operate as a switch (push on… push off…). Furthermore you need to select which physical Arduino pin the button will control – so press “PIN”, which brings up the scrolling menu as shown below:

We set ours to D7 then pressed “Continue”. Now the app is complete. Now head back to your computer, open the Arduino IDE, and load the “Arduino_Ethernet” sketch included with the library:

Then scroll down to line 30 and enter the auth key that was sent to you via email:

Save then upload the sketch to your Arduino. Now head back to your smartphone, and click the “Play” (looks like a triangle pointing right) button. After a moment the app will connect to the Blynk server… the Arduino will also be connected to the server – and you can press the button on the screen to control the LED.

And that’s it – remote control really is that easy. We’ve run through the process in the following short video:

Now what else can we control? How about some IKEA LED strips from our last article. Easy… that consisted of three digital outputs, with PWM. The app resembles the following:

… and watch the video below to see it in action:

Monitoring data from an Arduino via Blynk

Data can also travel in the other direction – from your Arduino over the Internet to your smartphone. At the time of writing this (September 2015) you can monitor the status of analogue and digital pins, and widgets can be added in the app to do just that. They can display the value returned from each ADC, which falls between zero and 1023 – and display the values in various forms – for example:

The bandwidth required for this is just under 2 K/s, as you can see from the top of the image above. You can see this in action through the video below:


We have only scratched the surface of what is possible with Blynk – which is an impressive, approachable and usable “Internet of Things” platform. Considering that you can get an inexpensive Android smartphone or tablet for under AU$50, the overall cost of using Blynk is excellent and well worth consideration, even just to test out the “Internet of Things” buzz yourself. So to get started head over to the Blynk site.

And finally a plug for our own store – – which along with being Australia’s #1 Adafruit distributor, also offers a growing range and Australia’s best value for supported hobbyist electronics from DFRobot, Freetronics, Seeedstudio and much much more.

As always, have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Control your Arduino over the Internet using Blynk appeared first on tronixstuff.

Tronixstuff 20 Sep 09:30

Experimenting with Arduino and IKEA DIODER LED Strips


A few weeks ago I found a DIODER LED strip set from a long-ago trek to IKEA, and considered that something could be done with it.  So in this article you can see how easy it is to control the LEDs using an Arduino or compatible board with ease… opening it up to all sorts of possibilities.

This is not the most original project – however things have been pretty quiet around here, so I thought it was time to share something new with you. Furthermore the DIODER control PCB has changed, so this will be relevant to new purchases. Nevertheless, let’s get on with it.

So what is DIODER anyhow? 

As you can see in the image below, the DIODER pack includes four RGB LED units each with nine RGB LEDs per unit. A controller box allows power and colour choice, a distribution box connects between the controller box and the LED strips, and the whole thing is powered by a 12V DC plugpack:

The following is a quick video showing the DIODER in action as devised by IKEA:


Thankfully the plugpack keeps us away from mains voltages, and includes a long detachable cable which connects to the LED strip distribution box. The first thought was to investigate the controller, and you can open it with a standard screwdriver. Carefully pry away the long-side, as two clips on each side hold it together…

… which reveals the PCB. Nothing too exciting here – you can see the potentiometer used for changing the lighting effects, power and range buttons and so on:

Our DIODER has the updated PCB with the Chinese market microcontroller. If you have an older DIODER with a Microchip PIC – you can reprogram it yourself.

The following three MOSFETs are used to control the current to each of the red, green and blue LED circuits. These will be the key to controlling the DIODER’s strips – but are way too small for me to solder to. The original plan was to have an Arduino’s PWM outputs tap into the MOSFET’s gates – but instead I will use external MOSFETs.

So what’s a MOSFET?

In the past you may have used a transistor to switch higher current from an Arduino, however a MOSFET is a better solution for this function. The can control large voltages and high currents without any effort. We will use N-channel MOSFETs, which have three pins – Source, Drain and Gate. When the Gate is HIGH, current will flow into the Drain and out of the Gate:

A simplistic explanation is that it can be used like a button – and when wiring your own N-MOSFET a 10k resistor should be used between Gate and Drain to keep the Gate low when the Arduino output is set to LOW (just like de-bouncing a button). To learn more about MOSFETS – get yourself a copy of “The Art of Electronics“. It is worth every cent.

However being somewhat time poor (lazy?), I have instead used a Freetronics NDrive Shield for Arduino – which contains six N-MOSFETs all on one convenient shield  – with each MOSFET’s Gate pin connected to an Arduino PWM output.

So let’s head back to the LED strips for a moment, in order to determine how the LEDs are wired in the strip. Thanks to the manufacturer – the PCB has the markings as shown below:

They’re 12V LEDs in a common-anode configuration. How much current do they draw? Depends on how many strips you have connected together…

For the curious I measured each colour at each length, with the results in the following table:

So all four strips turned on, with all colours on – the strips will draw around 165 mA of current at 12V. Those blue LEDs are certainly thirsty.

Moving on, the next step is to connect the strips to the MOSFET shield. This is easy thanks to the cable included in the DIODER pack, just chop the white connector off as shown below:

By connecting an LED strip to the other end of the cable you can then determine which wire is common, and which are the cathodes for red, green and blue.

The plugpack included with the DIODER pack can be used to power the entire project, so you will need cut the DC plug (the plug that connects into the DIODER’s distribution box) off the lead, and use a multimeter to determine which wire is negative, and which is positive.

Connect the negative wire to the GND terminal on the shield, and the positive wire to the Vin terminal.  Then…

  • the red LED wire to the D3 terminal,
  • the green LED wire to the D9 terminal,
  • and the blue LED wire to the D10 terminal.

Finally, connect the 12V LED wire (anode) into the Vin terminal. Now double-check your wiring. Then check it again.


Now to run a test sketch to show the LED strip can easily be controlled. We’ll turn each colour on and off using PWM (Pulse-Width Modulation) – a neat way to control the brightness of each colour. The following sketch will pulse each colour in turn, and there’s also a blink function you can use.

// Controlling IKEA DIODER LED strips with Arduino and Freetronics NDRIVE N-MOSFET shield
// CC by-sa-nc John Boxall 2015 - 
// Components from

#define red 3
#define green 9
#define blue 10
#define delaya 2

void setup() 
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);

void blinkRGB()
  digitalWrite(red, HIGH);
  digitalWrite(red, LOW);
  digitalWrite(green, HIGH);
  digitalWrite(green, LOW);
  digitalWrite(blue, HIGH);
  digitalWrite(blue, LOW);

void pulseRed()
  for (int i=0; i<256; i++)
  for (int i=255; i>=0; --i)

void pulseGreen()
  for (int i=0; i<256; i++)
  for (int i=255; i>=0; --i)

void pulseBlue()
  for (int i=0; i<256; i++)
  for (int i=255; i>=0; --i)

void loop()

Success. And for the non-believers, watch the following video:

Better LED control

As always, there’s a better way of doing things and one example of LED control is the awesome FASTLED library by Daniel Garcia and others. Go and download it now – Apart from our simple LEDS, the FASTLED library is also great with WS2812B/Adafruit NeoPixels and others.

One excellent demonstration included with the library is the AnalogOutput sketch, which I have supplied below to work with our example hardware:

#include <FastLED.h>

// Example showing how to use FastLED color functions
// even when you're NOT using a "pixel-addressible" smart LED strip.
// This example is designed to control an "analog" RGB LED strip
// (or a single RGB LED) being driven by Arduino PWM output pins.
// So this code never calls FastLED.addLEDs() or
// This example illustrates one way you can use just the portions 
// of FastLED that you need.  In this case, this code uses just the
// fast HSV color conversion code.
// In this example, the RGB values are output on three separate
// 'analog' PWM pins, one for red, one for green, and one for blue.
#define REDPIN   3
#define GREENPIN 9
#define BLUEPIN  10

// showAnalogRGB: this is like, but outputs on 
// analog PWM output pins instead of sending data to an intelligent,
// pixel-addressable LED strip.
// This function takes the incoming RGB values and outputs the values
// on three analog PWM output pins to the r, g, and b values respectively.
void showAnalogRGB( const CRGB& rgb)
  analogWrite(REDPIN,   rgb.r );
  analogWrite(GREENPIN, rgb.g );
  analogWrite(BLUEPIN,  rgb.b );

// colorBars: flashes Red, then Green, then Blue, then Black.
// Helpful for diagnosing if you've mis-wired which is which.
void colorBars()
  showAnalogRGB( CRGB::Red );   delay(500);
  showAnalogRGB( CRGB::Green ); delay(500);
  showAnalogRGB( CRGB::Blue );  delay(500);
  showAnalogRGB( CRGB::Black ); delay(500);

void loop() 
  static uint8_t hue;
  hue = hue + 1;
  // Use FastLED automatic HSV->RGB conversion
  showAnalogRGB( CHSV( hue, 255, 255) );

void setup() {
  pinMode(REDPIN,   OUTPUT);
  pinMode(BLUEPIN,  OUTPUT);

  // Flash the "hello" color sequence: R, G, B, black.

You can see this in action through the following video:


So if you have some IKEA LED strips, or anything else that requires more current than an Arduino’s output pin can offer – you can use MOSFETs to take over the current control and have fun. And finally a plug for my own store – – offering a growing range and Australia’s best value for supported hobbyist electronics from adafruit, DFRobot, Freetronics, Seeed Studio and much much more.

As always, have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Experimenting with Arduino and IKEA DIODER LED Strips appeared first on tronixstuff.

Editorial – Arduino versus Arduino

Over the last few months a large split in the Arduino ecosystem has been made public with some interesting results, and possibly could be the start of the end of the project as we know it. After a few people asked me directly about my thoughts on the Arduino versus Arduino matter, I’ve decided to articulate them in this editorial.

From the beginning the Arduino team has consisted of Massimo Banzi, David Cuartielles, David Mellis, Tom Igoe, and Gianluca Martino – and over the years we have always thought of this core team as the people who brought us the Arduino world.

Furthermore the main manufacturer of the Arduino-branded boards in Italy – “Smart Projects S. r. L” belongs to team member Gianluca Martino, and this organisation paid royalties to the team for the right to manufacture the boards.

Moving on, in 2008 the five formed a company to hold the trademarks and so forth that would allow for more commercial opportunities with regards to licensing and so forth.

However as Massimo wrote in a recent Make: magazine article, Gianluca had registered the Arduino name in Italy amongst other nefarious actions.

To top this off, Massimo tells us that Smart Projects have stopped paying the royalties for over twelve months. This has been most disappointing as being the supplier to Arduino resellers across the globe, resellers thought they were doing the right thing by buying the real boards. A

And to add insult to injury, Smart Projects changed their name to Arduino S. r. L., and was sold by Gianluca Martino in 2014. This company has created their own Arduino website (ending with .org instead of .cc) – and even forked their own version of the IDE and given it a version number starting with 1.7, which is greater than the current 1.6.3. No doubt this will trap a few users into thinking that Arduino S. r. L. (which we’ll shorten to ASrL) is the legitimate supplier and site for Arduino. For more information about the later developments, read this article form Hackaday.

So from what we can tell, the manufacturing member of the original Arduino team has gone off and tried to replicate the Arduino ecosystem under their own terms, allegedly misappropriating the Arduino name and trademark and denying royalties – and is currently still the only source of what have always been “genuine Arduino boards”.

Wow, what a mess.

More keen observers will realise that there isn’t anything wrong with reproducing their own Arduino-compatible boards thanks to the open-source nature of the hardware, and there must be a google of copies, compatibles and knock-offs in the market. And it’s ok to fork the IDE for modify, improve or bork it up to your own requirements as long as yout stick to the original software licence.

However the alleged royalty issue and trademark and name theft is not ok. So where does this leave the Arduino team now? From what I can learn, the rest of the original Arduino team are moving forward and will continue to innovate with new devices and projects which is admirable – and they have agreed to work with manufacturer/retailers such as adafruit to produce new boards (such as the Arduino Gemma).

At this point how does this affect you, as a potential or current Arduino enthusiast? That’s an excellent question. If you have always believed in supporting the Arduino team by purchasing genuine boards – it would seem this option is no longer available until the original team find a new manufacturing partner.

And how does this affect Arduino resellers? As an Arduino reseller ourselves ( we made our position as clear as we could at the time. Our position at Tronixlabs is that we want to continue to sell boards that benefit the Arduino team, however we’re a business that aims to meet the needs of all of our customers – and thus we offer compatibles as well.

We have contacted the Arduino team for guidance about future Arduino-branded boards and await their reply. What we do look forward to, however, is a cheaper reseller cost. The freight charge from Europe plus the board costs at the time were quite extraordinary.

Furthermore if Arduino S. r. L introduce a compelling product that people want – hey we’ll sell that as well. The following day Nate from Sparkfun made a similar statement. Whether they make their thoughts public or not, we’re confident that all resellers will take a similar stand, as you don’t want to specifically pick a side in case the other side has a great product that you want to sell. Then again, why would a manufacturer hold back their product to a retailer if said retailer offers products from the competition?

As Kent Brockman would say “… only time will tell”.

From this juncture we look forward to what the Arduino team has for us in the future with great interest… and we’re also following Arduino S. r. L as well to see what they come up with.

However don’t panic – for day to day use nothing has changed for us as enthusiasts. However – do we owe the Arduino team our support? Absolutely – so many people have benefited from their original idea and work for everyone’s benefit. If you feel so inclined, you can directly donate funds to the Arduino project via the IDE download page.

Finally, a great lesson can be learned from these recent events. If your team comes up with a great idea, product or service – before you get serious spend the time and resources required to formalise ownership of intellectual property, naming rights, copyrighted work, and so forth.

We look forward to your thoughts and notes about the situation, which can be left in our moderated comment section. And finally a plug for my own store – – offering a growing range and Australia’s best value for supported hobbyist electronics from adafruit, DFRobot, Freetronics, Seeed Studio and much much more.

As always, have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Editorial – Arduino versus Arduino appeared first on tronixstuff.

Tutorial – Using DS1307 and DS3231 Real-time Clock Modules with Arduino

We keep getting requests on how to use DS1307 and DS3231 real-time clock modules with Arduino from various sources – so this is the first of a two part tutorial on how to use them. For this Arduino tutorial we have  two real-time clock modules to use, one based on the Maxim DS1307:

and another based on the DS3231:

There are two main differences between the ICs on the real-time clock modules, which is the accuracy of the time-keeping. The DS1307 used in the first module works very well, however the external temperature can affect the frequency of the oscillator circuit which drives the DS1307’s internal counter.

This may sound like a problem, however will usually result with the clock being off by around five or so minutes per month. The DS3231 is much more accurate, as it has an internal oscillator which isn’t affected by external factors – and thus is accurate down to a few minutes per year at the most. If you have a DS1307 module- don’t feel bad, it’s still a great value board and will serve you well.

With both of the modules, a backup battery is installed when you receive them from Tronixlabs, however these are an inexpensive variety and shouldn’t be relied on for more than twelve months. If you’re going to install the module in a more permanent project, its’ a good idea to buy a new CR2023 battery and fit it to the module.

Along with keeping track of the time and date, these modules also have a small EEPROM, an alarm function (DS3231 only) and the ability to generate a square-wave of various frequencies – all of which will be the subject of a second tutorial.

Connecting your module to an Arduino

Both modules use the I2C bus, which makes connection very easy. If you’re not sure about the I2C bus and Arduino, check out the I2C tutorials (chapters 20 and 21), or review chapter seventeen of my book “Arduino Workshop“.

Moving on – first you will need to identify which pins on your Arduino or compatible boards are used for the I2C bus – these will be knows as SDA (or data) and SCL (or clock). On Arduino Uno or compatible boards, these pins are A4 and A5 for data and clock:

If you’re using an Arduino Mega the pins are D20 and D21 for data and clock:

If you’re using an Pro Mini-compatible the pins are A4 and A5 for data and clock, which are parallel to the main pins, as shown below:

DS1307 module

If you have the DS1307 module you will need to solder the wires to the board, or solder on some inline header pins so you can use jumper wires. Then connect the SCL and SDA pins to your Arduino, and the Vcc pin to the 5V pin and GND to GND.

DS3231 module

Connecting this module is easy as header pins are installed on the board at the factory. You can simply run jumper wires again from SCL and SDA to the Arduino and again from the module’s Vcc and GND pins to your board’s 5V or 3.3.V and GND. However these are duplicated on the other side for soldering your own wires.

Both of these modules have the required pull-up resistors, so you don’t need to add your own. Like all devices connected to the I2C bus, try and keep the length of the SDA and SCL wires to a minimum.

Reading and writing the time from your RTC Module

Once you have wired up your RTC module. enter and upload the following sketch. Although the notes and functions in the sketch refer only to the DS3231, the code also works with the DS1307.

#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
  return( (val/10*16) + (val%10) );
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
  return( (val/16*10) + (val%16) );
void setup()
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(30,42,21,4,26,11,14);
void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
  // sets time and date data to DS3231
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec( & 0x7f);
  *minute = bcdToDec(;
  *hour = bcdToDec( & 0x3f);
  *dayOfWeek = bcdToDec(;
  *dayOfMonth = bcdToDec(;
  *month = bcdToDec(;
  *year = bcdToDec(;
void displayTime()
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  // send it to the serial monitor
  Serial.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  if (minute<10)
  Serial.print(minute, DEC);
  if (second<10)
  Serial.print(second, DEC);
  Serial.print(" ");
  Serial.print(dayOfMonth, DEC);
  Serial.print(month, DEC);
  Serial.print(year, DEC);
  Serial.print(" Day of week: ");
  case 1:
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
  case 7:
void loop()
  displayTime(); // display the real-time clock data on the Serial Monitor,
  delay(1000); // every second

There may be a lot of code, however it breaks down well into manageable parts.

It first includes the Wire library, which is used for I2C bus communication, followed by defining the bus address for the RTC as 0x68. These are followed by two functions that convert decimal numbers to BCD (binary-coded decimal) and vice versa. These are necessary as the RTC ICs work in BCD not decimal.

The function setDS3231time() is used to set the clock. Using it is very easy, simple insert the values from year down to second, and the RTC will start from that time. For example if you want to set the following date and time – Wednesday November 26, 2014 and 9:42 pm and 30 seconds – you would use:


Note that the time is set using 24-hour time, and the fourth paramter is the “day of week”. This falls between 1 and 7 which is Sunday to Saturday respectively. These parameters are byte values if you are subsituting your own variables.

Once you have run the function once it’s wise to prefix it with // and upload your code again, so it will not reset the time once the power has been cycled or micrcontroller reset.

Reading the time form your RTC Is just as simple, in fact the process can be followed neatly inside the function displayTime(). You will need to define seven byte variables to store the data from the RTC, and these are then inserted in the function readDS3231time().

For example if your variables are:

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

… you would refresh them with the current data from the RTC by using:

readDS3232time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

Then you can use the variables as you see fit, from sending the time and date to the serial monitor as the example sketch does – to converting the data into a suitable form for all sorts of output devices.

Just to check everything is working, enter the appropriate time and date into the demonstration sketch, upload it, comment out the setDS3231time() function and upload it again. Then open the serial monitor, and you should be provided with a running display of the current time and date, for example:

From this point you now have the software tools to set data to and retrieve it from your real-time clock module, and we hope you have an understanding of how to use these inexpensive modules.

You can learn more about the particular real-time clock ICs from the manufacturer’s website – DS1307 and DS3231.

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Tutorial – Using DS1307 and DS3231 Real-time Clock Modules with Arduino appeared first on tronixstuff.

Tronixstuff 01 Dec 01:43

Tutorial – L298N Dual Motor Controller Modules and Arduino

Learn how to use inexpensive L298N motor control modules to drive DC and stepper motors with Arduino. This is chapter fifty-nine of our huge Arduino tutorial series.

You don’t have to spend a lot of money to control motors with an Arduino or compatible board. After some hunting around we found a neat motor control module based on the L298N H-bridge IC that can allows you to control the speed and direction of two DC motors, or control one bipolar stepper motor with ease.

The L298N H-bridge module can be used with motors that have a voltage of between 5 and 35V DC. With the module used in this tutorial, there is also an onboard 5V regulator, so if your supply voltage is up to 12V you can also source 5V from the board.

So let’s get started!

First we’ll run through the connections, then explain how to control DC motors then a stepper motor. At this point, review the connections on the L298N H-bridge module.

Consider the following image – match the numbers against the list below the image:

  1. DC motor 1 “+” or stepper motor A+
  2. DC motor 1 “-” or stepper motor A-
  3. 12V jumper – remove this if using a supply voltage greater than 12V DC. This enables power to the onboard 5V regulator
  4. Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if >12V DC
  5. GND
  6. 5V output if 12V jumper in place, ideal for powering your Arduino (etc)
  7. DC motor 1 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control.
  8. IN1
  9. IN2
  10. IN3
  11. IN4
  12. DC motor 2 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control.
  13. DC motor 2 “+” or stepper motor B+
  14. DC motor 2 “-” or stepper motor B-

Controlling DC Motors

To control one or two DC motors is quite easy with the L298N H-bridge module. First connect each motor to the A and B connections on the L298N module. If you’re using two motors for a robot (etc) ensure that the polarity of the motors is the same on both inputs. Otherwise you may need to swap them over when you set both motors to forward and one goes backwards!

Next, connect your power supply – the positive to pin 4 on the module and negative/GND to pin 5. If you supply is up to 12V you can leave in the 12V jumper (point 3 in the image above) and 5V will be available from pin 6 on the module. This can be fed to your Arduino’s 5V pin to power it from the motors’ power supply. Don’t forget to connect Arduino GND to pin 5 on the module as well to complete the circuit.

Now you will need six digital output pins on your Arduino, two of which need to be PWM (pulse-width modulation) pins. PWM pins are denoted by the tilde (“~”) next to the pin number, for example:

Finally, connect the Arduino digital output pins to the driver module. In our example we have two DC motors, so digital pins D9, D8, D7 and D6 will be connected to pins IN1, IN2, IN3 and IN4 respectively. Then connect D10 to module pin 7 (remove the jumper first) and D5 to module pin 12 (again, remove the jumper).

The motor direction is controlled by sending a HIGH or LOW signal to the drive for each motor (or channel). For example for motor one, a HIGH to IN1 and a LOW to IN2 will cause it to turn in one direction, and  a LOW and HIGH will cause it to turn in the other direction.

However the motors will not turn until a HIGH is set to the enable pin (7 for motor one, 12 for motor two). And they can be turned off with a LOW to the same pin(s). However if you need to control the speed of the motors, the PWM signal from the digital pin connected to the enable pin can take care of it.

This is what we’ve done with the DC motor demonstration sketch. Two DC motors and an Arduino Uno are connected as described above, along with an external power supply. Then enter and upload the following sketch:

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup()
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
void demoOne()
  // this function will run the motors in both directions at a fixed speed
  // turn on motor A
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, 200);
  // turn on motor B
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, 200);
  // now change motor directions
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH); 
  // now turn off motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
void demoTwo()
  // this function will run the motors across the range of possible speeds
  // note that maximum speed is determined by the motor itself and the operating voltage
  // the PWM values sent by analogWrite() are fractions of the maximum speed possible 
  // by your hardware
  // turn on motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH); 
  // accelerate from zero to maximum speed
  for (int i = 0; i &lt; 256; i++)
    analogWrite(enA, i);
    analogWrite(enB, i);
  // decelerate from maximum speed to zero
  for (int i = 255; i &gt;= 0; --i)
    analogWrite(enA, i);
    analogWrite(enB, i);
  // now turn off motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);  
void loop()

So what’s happening in that sketch? In the function demoOne() we turn the motors on and run them at a PWM value of 200. This is not a speed value, instead power is applied for 200/255 of an amount of time at once.

Then after a moment the motors operate in the reverse direction (see how we changed the HIGHs and LOWs in thedigitalWrite() functions?).

To get an idea of the range of speed possible of your hardware, we run through the entire PWM range in the function demoTwo() which turns the motors on and them runs through PWM values zero to 255 and back to zero with the two for loops.

Finally this is demonstrated in the following video – using our well-worn tank chassis with two DC motors:

Controlling a Stepper Motor

Stepper motors may appear to be complex, but nothing could be further than the truth. In this example we control a typical NEMA-17 stepper motor that has four wires:

It has 200 steps per revolution, and can operate at at 60 RPM. If you don’t already have the step and speed value for your motor, find out now and you will need it for the sketch.

The key to successful stepper motor control is identifying the wires – that is which one is which. You will need to determine the A+, A-, B+ and B- wires. With our example motor these are red, green, yellow and blue. Now let’s get the wiring done.

Connect the A+, A-, B+ and B- wires from the stepper motor to the module connections 1, 2, 13 and 14 respectively. Place the jumpers included with the L298N module over the pairs at module points 7 and 12. Then connect the power supply as required to points 4 (positive) and 5 (negative/GND).

Once again if your stepper motor’s power supply is less than 12V, fit the jumper to the module at point 3 which gives you a neat 5V power supply for your Arduino.

Next, connect L298N module pins IN1, IN2, IN3 and IN4 to Arduino digital pins D8, D9, D10 and D11 respectively. Finally, connect Arduino GND to point 5 on the module, and Arduino 5V to point 6 if sourcing 5V from the module.

Controlling the stepper motor from your sketches is very simple, thanks to the Stepper Arduino library included with the Arduino IDE as standard.

To demonstrate your motor, simply load the stepper_oneRevolution sketch that is included with the Stepper library, for example:

Finally, check the value for

const int stepsPerRevolution = 200;

in the sketch and change the 200 to the number of steps per revolution for your stepper motor, and also the speed which is preset to 60 RPM in the following line:


Now you can save and upload the sketch, which will send your stepper motor around one revolution, then back again. This is achieved with the function

myStepper.step(stepsPerRevolution); // for clockwise
	myStepper.step(-stepsPerRevolution); // for anti-clockwise

Finally, a quick demonstration of our test hardware is shown in the following video:

So there you have it, an easy an inexpensive way to control motors with your Arduino or compatible board. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Tutorial – L298N Dual Motor Controller Modules and Arduino appeared first on tronixstuff.

Tronixstuff 25 Nov 11:54

Tutorial – PCF8574 backpacks for LCD modules and Arduino

Learn how to use inexpensive serial backpacks with character LCD modules with your Arduino. This is chapter fifty-eight of our huge Arduino tutorial series.


Using LCD modules with your Arduino is popular, however the amount of wiring requires time and patience to wire it up correctly – and also uses a lot of digital output pins. That’s why we love these serial backpack modules – they’re fitted to the back of your LCD module and allows connection to your Arduino (or other development board) with only four wires – power, GND, data and clock.

You can use this with LCD modules that have a HD44780-compatible interface with various screen sizes. For example a 16 x 2 module:

The backpack can also be used with 20 x 4 LCDs. The key is that your LCD must have the interface pads in a single row of sixteen, so it matches the pins on the backpack – for example:

Hardware Setup

Now let’s get started. First you need to solder the backpack to your LCD module. While your soldering iron is warming up, check that the backpack pins are straight and fit in the LCD module, for example:

Then solder in the first pin, while keeping the backpack flush with the LCD:

If it’s a bit crooked, you can reheat the solder and straighten it up again. Once you’re satisfied with the alignment, solder in the rest of the pins:

Now to keep things neat, trim off the excess header pins:

Once you’ve finished trimming the header pins, get four male to female jumper wires and connect the LCD module to your Arduino as shown in the following image and table. Then connect your Arduino to the computer via USB:

Software Setup

The next step is to download and install the Arduino I2C LCD library for use with the backpack. First of all, rename the “LiquidCrystal” library folder in your Arduino libraries folder. We do this just to keep it as a backup.

If you’re not sure where your library folder can be found – it’s usually in your sketchbook folder, whose location can usually be found in the Arduino IDE preferences menu:

Next, visit… and download the latest file, currently we’re using v1.2.1. Expanding the downloaded .zip file will reveal a new “LiquidCrystal” folder – copy this into your Arduino libraries folder.

Now restart the Arduino IDE if it was already running – or open it now. To test the module we have a demonstration sketch prepared, simply copy and upload the following sketch:

/* Demonstration sketch for PCF8574T I2C LCD Backpack 
Uses library from GNU General Public License, version 3 (GPL-3.0) */
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C	lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack

void setup()
  // activate LCD module
  lcd.begin (16,2); // for 16 x 2 LCD module

void loop()
  lcd.home (); // set cursor to 0,0
  lcd.setCursor (0,1);        // go to start of 2nd line
  lcd.setBacklight(LOW);      // Backlight off
  lcd.setBacklight(HIGH);     // Backlight on

After a few moments the LCD will be initialised and start to display our URL and the value for millis, then blink the backlight off and on – for example:

If the text isn’t clear, or you just see white blocks – try adjusting the contrast using the potentiometer on the back of the module.

How to control the backpack in your sketch

As opposed to using the LCD module without the backpack, there’s a few extra lines of code to include in your sketches. To review these, open the example sketch mentioned earlier.

You will need the libraries as shown in lines 3, 4 and 5 – and initialise the module as shown in line 7. Note that the default I2C bus address is 0x27 – and the first parameter in the LiquidCrystal_I2C function.

Finally the three lines used in void setup() are also required to initialise the LCD. If you’re using a 20×4 LCD module, change the parameters in the lcd.begin() function.

From this point you can use all the standard LiquidCrystal functions such as lcd.setCursor() to move the cursor and lcd.write() to display text or variables as normal. The backlight can also be turned on and off with lcd.setBacklight(HIGH) or lcd.setBacklight(LOW).

You can permanently turn off the backlight by removing the physical jumper on the back of the module.

Changing the I2C bus address

If you want to use more than one module, or have another device on the I2C bus with address 0x27 then you’ll need to change the address used on the module. There are eight options to choose from, and these are selected by soldering over one or more of the following spots:

There are eight possible combinations, and these are described in Table 4 of the PCF8574 data sheet which can be downloaded from the NXP website. If you’re unsure about the bus address used by the module, simply connect it to your Arduino as described earlier and run the I2C scanner sketch from the Arduino playground.

We hope you enjoyed this tutorial and you can make use of it. Finally, if you enjoyed this tutorial, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

The post Tutorial – PCF8574 backpacks for LCD modules and Arduino appeared first on tronixstuff.

Tronixstuff 24 Sep 12:57

Project Review – Silicon Chip Capacitance Substitution Box


Every month Australian electronics magazine Silicon Chip publishes a variety of projects, and in some cases various (well … one of two) electronics retailers will pick up the project and offer it as a kit. However for an increasing number of new projects they don’t, which leaves the interested reader with one option – build the entire project from scratch.

But thankfully this is no longer the case – as the team from Silicon Chip now offer a range of project PCBs and matching front panels for sale directly from their website. Although buying these parts is not the cheapest option, it gives the busy person who likes making things a quick start – or the inexperienced more opportunities to complete a successful project.

So as a test of this new service, I bought the PCB and front panel for the Capacitance Substitution Box project described by Nicholas Vinen in the Juily 2012 issue of SC:

This is something I’ve meant to make for a while – but didn’t really have the inclination to make one from scratch, so it was neat to see a version published in the magazine. I believe the subjects in the magazine article are oftern prototypes, which explains the difference in colour for the front panel.

The parts arrived in a week after placing the order, and are of a high quality:

When complete, the capacitance substitution box PCB and panel will fit nicely into an Altronics H0151 enclosure, so you don’t need to do any drilling or filing. The next task was to organise the required parts. The rotary switches, terminal posts and the usual odds and ends can be found at Altronics, Jaycar or other suppliers. However the main components – the capacitors – offered two options.

The first option is to simply use capacitors from personal stock or the stores. However the tolerance of these parts can vary wildly, with up to twenty percent either way. This is ok for simple uses, however when values are combined – the tolerance of larger values can negate the lower values completely. So instead I’ve chosen the second option – which involves using brand-name low-tolerance capacitors.

Thus I turned to element14 who stock not only a huge range of not only regular but also the low-tolerance capacitors, and can also have them on my desk usually by the next working day. Finally, it’s nice to have all the parts arrive in little bags… neatly organised ready to go:

It’s easy to search for low-tolerance parts with element14, as the automatic filtering has tolerance as a parameter:

Furthermore you can also ensure you have the voltage rating of at least 50V DC as well. So after half an hour the capacitor order was completed and arrived when expected – using parts from Panasonic, Vishay, and Wima. The tolerances of our capacitors used varied between one and ten percent, which will help improve the accuracy of the substitution box.


The PCB has the capacitor values labelled neatly on the silk-screen, so soldering in all the capacitors was a relatively simple but long operation. Having them arrive in separate packets made life a lot easier. During the soldering process it’s a good idea to have a  break or two, which helps you avoid fatigue and making any mistakes.

There may be a few capacitors that are a little too wide to fit with the others, so they can be mounted on the other side of the PCB:

However they all end up fitting well:

The next step was to configure the first rotary switch for six position use, then cut the plastic stopped from the side of each rotary switch. In the following image you have a before and after example:

Now the rotary switches can have their shafts trimmed and then be soldered onto the PCB:

However ensure you have the first rotary switch in the right way – that is the selections are selected across the top half, not the bottom. Remove the nuts from the rotary switches, and double-check all the capacitors are fitted, as once the next step is completed … going back will be difficult to say the least.

At this point the banana sockets can be fitted to the panel, and then soldered into place, and then you’re finished. Just place the panel/PCB combination inside the box and screw it down:

Using the Capacitance Substitution Box

Does it work? Yes – however you don’t get exact values, there will always be a tolerance due to the original tolerance of the capacitors used and the stray capacitance of the wires between the box and the circuit (or capacitance meter). Nevertheless our example was quite successful. You can see the box in action with our Altronics LC meter kit in this video.

Again, using the best tolerance capacitors you can afford will increase the accuracy of this project.


Over time this would be a useful piece of equipment to have – so if your experiments or projects require varying capacitor value, this project will serve the purpose nicely. Plus it helps with mental arithmetic and measures of capacitance! Please do not ask me for copies of the entire Silicon Chip article, refusal may offend. Instead – visit their website for a reprint or digital access.

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Project Review – Silicon Chip Capacitance Substitution Box appeared first on tronixstuff.

Add long-distance connectivity to your Arduino with the CATkit System


Have you ever wanted to connect your Arduino to sensors or other devices but over a long distance? And we don’t mean a few metres – instead, distances of up to 100 metres? Doing so is possible with the CATkit system from SMART greenhouse.

This system is a combination of small boards that are connected between your Arduino and external devices using CAT5 networking cable, giving a very simple method of connecting devices over distances you previously thought may not have been possible – or have used costly wireless modules in the past.

The maximum distances possible depend on the signal type, for example:

  • analogue signals up to 100 metres (with a 0.125 V drop)
  • 1-wire signals (ideal for DS18B20 temperature sensors) up to 75 metres
  • SPI bus up to 50 metres
  • I2C bus up to 35 metres
  • Serial data at 9600 bps varies between 50 and 100 metres

In principle you could also use this with other development boards that utilise the Arduino Uno shield form-factor and work with 5V – so not for the Arduino Due, etc. For more information check out the .pdf documentation at the bottom of this page.

How it works

For each system you need one CATkit Arduino shield:

… and one or more Kitten boards. These are both inline – in that they can “tap in” to a run:

or have one RJ45 socket for installation at the end of a cable run:

Note that the inline Kitten has male pins for the breakout, and the end unit has females. These units are available in kit form or assembled. You then use the network cables between the shield and each Kitten, for example:

Each Kitten can distribute six signals, and up to three can be connected to one CATkit shield. These three distribute analogue pins 0~5, digital pins 0~5 and 6~11 respectively. You can also introduce external power to the CATkit shield and the onboard regulator will offer 5V at up to 950 mA for the power bus which can be accessed from the inline or end Kitten boards. This saves having to provide separate 5V power to devices away from the Arduino, and very convenient for sensors or remote I2C-interface displays.  

Using the CATkit system

If you have the units in kit form, assembly is very simple. For example – the main CATkit shield:

The shield is in the latest Arduino R3 format, and all the required parts are included. The PCB is neatly solder-masked and silk-screened so soldering is easy. The power regulator is in D-PAK form, however with a little help it’s easy to solder it in:

Otherwise the shield assembly is straight forward, and in around ten minutes you have the finished product (somehow we lost the DC socket, however one is included):

The cut-out in the PCB gives a neat clearance for the USB socket.  The inline unit was also easily assembled, and again the kit includes all the necessary parts:

… and after a few minutes of soldering the board is ready:

A benefit of using the kit version is that you can directly solder any wires from sensors straight to the PCB for more permanent installations. 

Using the CATkit system

Any Arduino user with a basic understanding of I/O will be ready for the CATkit system. You can think of it as a seamless extension to the required I/O pins, taking into account the maximum distances possible as noted on the CATkit website or earlier in this review.

For a quick test we connected an I2C-interface LCD using an inline Kitten module via 5M of network cable, as shown in this video.


With a little planning and the CATkit system you can create neat plug-and-play sensor or actuator networks with reusable lengths of common networking cable. To do so is simple – and it works, so for more information and distributors please visit the product website.

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

[Note – CATkit system parts are a promotional consideration from SMART green house]

The post Add long-distance connectivity to your Arduino with the CATkit System appeared first on tronixstuff.

Tronixstuff 12 Apr 23:33

Review – Intel Galileo Arduino-compatible Development Board


Over the last year or two the rise of the single-board computer has captured the imagination and energy of many people, to the point where popular opinion has been that the Arduino world had been left behind. However this is far from the truth – there’s Arduino-compatible SBCs such as the pcDuino and now we have one from Intel  – the Intel Galileo.

Apparently the Galileo has been available in limited distribution for a few months, and now that the marketing machine has started up – we finally had the chance to order an Intel Galileo last week and now have one as the subject for this review. It’s our first look, based on information we could find at the time and some experimenting.

What’s in the box?

In the retail package we found the Intel Galileo itself:

… a diagram of what to do in the lid:

… and a universal AC to 5V 2A DC power supply with various fittings for different regions:

The only paper documentation was a safety and regulatory information booklet which gets recycled. We didn’t find a USB cable nor some stand-offs to lift the board off the bench a little.


The Galileo is based a new chipset from Intel, the Quark SoC X1000 Application Processor, a 32-bit Intel Pentium-class system on a chip. For the uninitiated, the Galileo is a single-board computer running a small version of Linux that can somewhat emulate an Arduino Uno R3 in software. The hardware specifications are as such (from the Arduino website):

  • 400MHz 32-bit Intel® Pentium instruction set architecture (ISA)-compatible processor o 16 KBytes on-die L1 cache
    • 512 KBytes of on-die embedded SRAM
    • Simple to program: Single thread, single core, constant speed
    • ACPI compatible CPU sleep states supported
    • An integrated Real Time Clock (RTC), with an optional 3V “coin cell” battery for operation between turn on cycles.
  • 10/100 Ethernet connector
  • Full PCI Express* mini-card slot, with PCIe 2.0 compliant features
    • Works with half mini-PCIe cards with optional converter plate
    • Provides USB 2.0 Host Port at mini-PCIe connector
  • USB 2.0 Host connector
    • Support up to 128 USB end point devices
  • USB Device connector, used for programming
    • Beyond just a programming port – a fully compliant USB 2.0 Device controller
  • 10-pin Standard JTAG header for debugging
  • Reboot button to reboot the processor
  • Reset button to reset the sketch and any attached shields
  • Storage options:
    • Default – 8 MByte Legacy SPI Flash main purpose is to store the firmware (or bootloader) and the latest sketch. Between 256KByte and 512KByte is dedicated for sketch storage. The download will happen automatically from the development PC, so no action is required unless there is an upgrade that is being added to the firmware.
    • Default 512 KByte embedded SRAM, enabled by the firmware by default. No action required to use this feature.
    • Default 256 MByte DRAM, enabled by the firmware by default.
    • Optional micro SD card offers up to 32GByte of storage
    • USB storage works with any USB 2.0 compatible drive
    • 11 KByte EEPROM can be programmed via the EEPROM library.

However unlike other SBCs on the market – you don’t get any video or audio output.

Let’s have a quick look around the board. Here you can see the DC socket and microSD card socket:

 From the view below you can see the Arduino shield stacking headers and flash memory:

… more jumpers for settings, a USB host socket, USB connection (client) socket, RS232 via 3.5mm socket (!) and 10/100 Ethernet:

… and some nifty jumpers to select 3.3 or 5V operation for shields and IOREF:

… this jumper pair is to add a 3V battery to keep the real-time clock ticking over when the main supply is removed:

Perhaps a CR2032 button cell holder would be preferable, there’s plenty of room on the PCB. Finally – the two reset buttons:

If you want to reset your emulated Arduino, press the one on the left (labelled I). If you want to reboot the entire computer, press the one on the right (labelled X). This seems a little counter-intuitive, as you would imagine the button closer to the stacking headers would reset the Arduino. Note that if you reboot the computer, the last sketch you’ve uploaded will be removed and need to be uploaded again. Furthermore, more often than not rebooting the Galileo wasn’t entirely successful – and required a full removal of USB, power then replacing the power and USB to get another connection.

Turning the Galileo over reveals some fascinating PCB track patterns, and the mini-PCIe connector:

Getting Started

Having a slight bent towards Arduino, the first thing we like to do is get the blink sketch running. The documentation is scattered all over the place, so start from and follow the links listed in the “Explore Intel makers” column. The closest thing to a quick setup guide can be downloaded hereThere’s a video by what sounds to be a ten year old explaining the board – who signs off by telling us it’s ok to break something (hopefully not the Galileo at $77 a pop). Marketing FTW. Eventually we found the official Intel support page for the Galileo, so bookmark that for future reference.

However if you just want to get started as quickly as possible, keep reading. First, download the Arduino IDE for Galileo from here. Next, extract the IDE folder to your root directory – and don’t have any spaces in the folder name. For example, use:


and not:

C:\Arduino IDEs\galileo IDE\

Now plug in your Galileo – and always plug the 5V power into the Galileo before the USB (use the “USB client” socket). For Windows the USB driver (for “Gadget Serial v2.4”) is in the IDE folder, just point Windows to the top Galileo Arduino IDE folder.

Note that it takes around twenty seconds for the PC to recognise the Galileo via USB (as the Galileo needs time to boot up – it’s running Linux). For Windows users – after loading the IDE, check which COM port has been allocated. For some reason the Galileo can’t deal with COM10 or higher. To change this, head over to the Device Manager. Open Ports (COM & LPT) then right-click the Galileo and click properties:

Next, click the Port Settings tab, then Advanced:

Then select a free COM port number that’s under 10, close all the dialogue boxes and restart the computer. After the reboot, load the IDE, select the right board and serial port in the Tools menu – then select Firmware Update in the Help Menu. If for some reason you put a memory card in the microSD card slot – remove it before this process.

A confirmation box will appear, so move forward and wait for the process to finish. Don’t touch the IDE, board or anything near the Galileo until this finishes. Read some kit reviews. The update process took eight minutes for us, however will depend on the speed of your Internet connection.

Finally, try the ubiquitous blink sketch. Once uploaded,  the tiny LED next to the coin cell jumpers will blink as requested. Now we’ll explore more about using the Galileo as an Arduino-compatible board.

How Arduino-compatible is the Galileo?

The first thing we like to do with new boards that differ from the classic Uno is to run a speed test, and for this we use the following sketch by Steve Curd from the Arduino forum:

// Pi_2
// Steve Curd
// December 2012
// This program approximates pi utilizing the Newton's approximation.  It quickly
// converges on the first 5-6 digits of precision, but converges verrrry slowly
// after that.  For example, it takes over a million iterations to get to 7-8
// significant digits.
// I wrote this to evaluate the performance difference between the 8-bit Arduino Mega,
// and the 32-bit Arduino Due.

#define ITERATIONS 100000L    // number of iterations
#define FLASH 1000            // blink LED every 1000 iterations

void setup() {
  pinMode(13, OUTPUT);        // set the LED up to blink every 1000 iterations

void loop() {

  unsigned long start, time;
  unsigned long niter=ITERATIONS;
  int LEDcounter = 0;
  boolean alternate = false;
  unsigned long i, count=0;
  float x = 1.0;
  float temp, pi=1.0;

  Serial.print("Beginning ");
  Serial.println(" iterations...");

  start = millis();  
  for ( i = 2; i < niter; i++) {
    x *= -1.0;
    pi += x / (2.0f*(float)i-1.0f);
    if (LEDcounter++ > FLASH) {
      LEDcounter = 0;
      if (alternate) {
        digitalWrite(13, HIGH);
        alternate = false;
      } else {
        digitalWrite(13, LOW);
        alternate = true;
      temp = 40000000.0 * pi;
  time = millis() - start;

  pi = pi * 4.0;

  Serial.print("# of trials = ");
  Serial.print("Estimate of pi = ");
  Serial.println(pi, 10);

  Serial.print("Time: "); Serial.print(time); Serial.println(" ms");


It calculates Newton Approximation for pi using an infinite series. For comparison an Arduino Due takes 690 ms, an Arduino Mega 2560 takes 5765 ms, and a pcDuino v2 can do it in 9 to 43 ms (depending on what else is running on Linux). So out of the box, the Galileo takes 279 ms:

Out of the box there is 262144 bytes available for sketches. As the Arduino is emulated, the hardware for I/O is a little different than you may have expected, and provided by a variety of I2C port expanders, MUXs and so on. For example I2C can only run at 100 kHz in master mode, no slave mode, and similar restrictions on SPI as well. Again, review this page to learn more about the internal hardware differences between an Arduino Uno and Intel Galileo.

Visit this page and scroll down to the block diagram for a visual representation, and while you’re there – review the entire page to learn more about the specific Arduino Uno R3 implementation on the Galileo. A lot of work has been done to allow successful emulation of the Arduino using the Quark CPU and internal OS. For example the EEPROM library just works, and has 11264 bytes of storage.

You can get an idea of what is supported “out of the box” by reviewing the libraries included with the Galileo’s IDE installation, for example:

So most of the basic requirements are covered at the time of writing. And unlike some other SBCs emulating Arduino, the onboard Ethernet “just works” as it should with the Ethernet library – and the USBHost library can take advantage of the matching socket on the board. Again – research is the key, so spend some time determining if the Galileo can solve your problems.

One interesting example of the limitations of the “emulated” Arduino is the speed, and this has been highlighted by Al Williams of Dr Dobb’s journal – who ran a simple sketch to see how fast a digital output pin could be set. As GPIO is provided by external SPI- and I2C-based interface ICs, there will be a speed hit. But how much? Naturally we can’t use port manipulation so we’re back to simple digitalWrite functions with the following sketch:

int pin = 2;
boolean a = false;
void setup() 
  pinMode(pin, OUTPUT);     

void loop() 
  digitalWrite(pin, a=!a);

An Arduino Uno running the sketch was clocked at 96.34 kHz:

… and the Intel Galileo was clocked at … 225.2 Hz:

This test isn’t a criticism of the Galileo, just an example of what you need to keep in mind when using it. If you’re curious about the real-time clock it’s accessed via Linux. Finally, there’s a list of known issues on the Intel forum – so check this out to get a grip on what is and is not working in terms of Arduino compatibility. One more thing – you will need a memory card installed if you want the Galileo to remember sketches after power-off.

Update – thanks to our friends (!) at reddit, you can push some I/O faster – see this post in the Intel forum.

Linux – internal

The Galileo arrived pre-loaded with a very light version of Linux, however due to the lack of video output you need to access the “computer” via some old-school methods. And thus one method is via Telnet over Ethernet. If you don’t have a Telnet client, try PuTTY. To get started, ensure you have your Galileo connected to power, client USB to PCm and to your LAN. Then upload the following sketch to your Galileo:

void setup()
  system("telnetd -l /bin/sh");

void loop()
  system("ifconfig eth0 > /dev/ttyGS0");

The observant will notice by using the system function you can send instructions to the Linux command line from your Arduino sketch. And any resulting output text can be sent to the serial monitor by directing it to ttyGS0.

Anyhow, the above sketch will run the ifconfig command and return relevant networking data about your Galileo – including its IP address:

Once you have the IP address, you can Telnet in and command your Galileo just like it’s 1992:

Don’t get too excited, there isn’t that much installed (e.g. no gcc or make). For more information on the Poky linux, visit the project page. Apart from running vi my *nix memory is a bit vague, however the onboard system is quite minimal. If you want to do anything serious, such as use a WiFi or other PCIe card – you’ll need to boot your Galileo with an external OS stored on a microSD card. Another way of looking at the Galileo is that it’s a board not for development with, but for running code built on a different system and then loaded onto the Galileo.

Linux – external

As I haven’t been a *nix user for a very long time, it didn’t seem worthwhile to spend a whole day preparing for an installing the external OS on the Galileo for review. However from what I can tell you’ll need to do this to run anything substantial including WiFi adaptors, python, node.js and so on. Which in my personal opinion sort of ruins the Galileo for me. Other SBCs can do all of this a lot easier, cheaper and with better documentation.

Arduino Support

As the Galileo is from Intel and not Arduino, you need to ask for support in the Intel forum. This will be an interesting test for Intel, will they invest in a substantial support effort or just stand back and say it’s all open source? Time will tell. In the meanwhile there is a gallery hosted by Intel with links to different projects.


Once again – remember that the Galileo is a limited single-board computer that emulates (to a certain, varying degree) an Arduino Uno R3. It is a contender if you need to integrate some Arduino-based control with software running on a light Linux machine, and all in a compact board. Or if you want to experiment with USB host and Ethernet on the Arduino platform at the same time, this could be a cheaper and more powerful option. Support is there if you can use Google, however this is not the idea beginners’ Arduino board. So don’t be a sheep and rush out and buy one after reading the marketing blurb – do your own research first.

Personally I would say that if you have a need for the specific hardware interfaces of the Galileo, and have a full understanding of the board limitations – then it’s the board for you. Otherwise if you want to experiment with a full single-board computer with Arduino compatibility, get a pcDuino. Full-sized images are available on flickr.

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop”.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

[Note – Intel Galileo purchased for review by and not a promotional consideration]

The post Review – Intel Galileo Arduino-compatible Development Board appeared first on tronixstuff.

Tronixstuff 12 Feb 03:59