Tag Archives: Shield Library

Spark Core Weather Station

In my previous blog post I described my first encounter with the Spark Core. Today I want to demonstrate a first simple code example. For this I connected the Spark Core to a Weather Shield from Sparkfun. The shield offers sensors for light, humidity, temperature and pressure. It can even be extended with rain and wind sensors as well as GPS.
.Spark Core Weather
The shield comes with a nice set of libraries and examples that I used as a starting point. To keep things really simple, I combine the entire Weather Shield source with the sensor library functions and the setup() and loop() into a single file. This did not take long and compiled quickly. I also removed the wind and rain related functionality as I did not plan to use those. The source code below takes measurements every second and writes the them to the USB serial port.

For debugging I used the Serial Communication link over USB. Windows users have to install a COM driver. However, MAC and Linux support the Spark Core USB functionality out of the box.

I was really pleased to see how well the Spark Core supports Arduino libraries and well written legacy code. With only a few code modifications I had the sensors up and running.

The setup is now streaming values over a USB cable to a PC. There I captured the values with Tera Term and created a Weather Graph from the comma separated values (CVS). The example below shows the pressure curve of a Bay Area Storm passing by at end of February 2014.
CA Storm
This setup is a somewhat trivial example that a basic Arduino can also do. The project really does not take advantage of the Spak Core's connectivity to the internet. So stay tuned for my next blog post where I will add internet connectivity to the setup.

What shields are working with Galileo

In my last post I touched on Galileo's shield interface implementation. 010511_0750_0082_nsmsHaving experimented with a few shields sitting in my drawer, I realized that the implementation of the Arduino shield interface creates a bit of a challenge.  So before you assume that a shield is plug-and-play do your homework. Like with a vintage car they may need some tender loving care.

Here are a few key criteria that you want to check:

  • Hardware
    1. Does my shield draw a lot of current: the Cypress CY8C9540A 40-Bit I/O Expander is only capable of driving 15/25mA instead of 40/50mA
    2. Are you accessing some of the shield pins at a high rate? Without special tricks, the Galileo can only toggle an IO pin at 477 kHz (see also Galileo FAQ and Forum post on this subject).
  • Software
    1. Does the driver directly access Atmel's  registers? This can be either the IO-port registers, Interrupt, Pulse Width Modulator (PWM) or Timer registers.
    2. Does it use any  AVR libraries? These libraries are exposing the Atmel AVR hardware to the programmer and are therefore a sure sign that you are in for some work to port the Arduino software libraries to the Galileo platform. Search for "#include <avr/" to see how many AVR hardware specific libraries are used.

Well written software libraries only use the official Arduino application programmers Interface (API). However, many of the existing shield libraries directly manipulating AVR hardware registers. This is either done out of ignorance for software portability or out of necessity as to push the hardware to its limits. I expect that with the transition away from the 8-bit AVR (ATmega328) micro controller to the more powerfule 32-bit CPUs ( Arduino Due, Arduino TreGalileo and Olimex-STM32) this problem will gradually subside.

Also note that as of this writing the following Arduino Libraries are supported:

  • SPI
  • EEPROM
  • UART
  • GPIO
  • WiFi

Check the Release Notes on Intel's site for the latest status.