WLAN

Google polls Spark Core

appsIn a previous blog post I was describing an example of how a Spark Core can be used to read weather sensors. The setup was really no different from any simple Arduino Uno setup. It only demonstrated how easy it is to port Arduino Sketches to a Spark Core.
With the integrated WLAN I was interested to connect the Spark Core to the internet cloud. One of the simplest ways I found, was using Google’s Spreadsheet service. I stumbled over this idea in this Spark forum post.
Here is how it works: a Google Script is periodically reading data from the Spark Core via the RESTful Spark API and then appends the data to a Spreadsheet. The code below is a minimalistic Spark code to test the such a setup:

int variable = 1634;
void setup() {
  Spark.variable("variable", &variable, INT);
}
void loop() {
  variable++;
  delay(5000);
}

It publishes a variable for cloud access and then increments it in regular intervals. Together with the following Google script I was able to quickly pull data from my core.

function collectData() {
  var  sheet = SpreadsheetApp.getActiveSheet();
  var sensor = UrlFetchApp.fetch("https://api.spark.io/v1/devices/<id>7/variable?access_token=<token>");
  // parse the JSON the Core API created
  var sensor = JSON.parse(sensor.getContentText());
  // you'll need to unescape before your parse as JSON
  var sensor_result = unescape(sensor.result);
  // create a time stamp
  var d = new Date();
  // append data to spreadsheet
  sheet.appendRow([d, sensor_result]);
}

However when I setup a time trigger to run the script in regular intervals I found the setup to be very unreliable. This is discussed and documented by several Spark Users and as of this writing I have not seen a fix for this problem.
One thing to note is, that this approach is pulling data from the Spark Core rather than the core pushing them to the cloud. This has a significant flaw as we cannot put the core into standby between the measurement intervals. Therefore this solution is anyway not a good choice for low power applications.
So stay tuned, I am experimenting with a better solution that I will blog about in my next post.

Another IoT Platform – WICED

Broadcom is also jumping on the IoT wagon with the WICED  platform.  The platform is targeting Bluetooth and WiFi applications. The WiFi modules feature the BCM43362 WiFi chip integrated into a System in a Package (SiP) module. The Image below shows a WiFI WICED PCB module with a Murata WiFi SiP Module and a STM32F205 microcontroller. Murata also offers SiP modules that have the ARM microcontroller built in.
wiced_BCM943362WCD4
On the software side the platform is supported by a feature rich SDK and support for OSs:

  • WICED Application Framework including bootloader, flash storage API, over-the-air (OTA) upgrades, factory reset, and system monitor.
  • An open source build system and toolchain based on GNU make (native IAR support coming soon!).
  • A GUI Development Environment based on Eclipse CDT that seamlessly integrates with a JTAG programmer and single-step, thread-aware debugger based on OpenOCD and gdb.
  • A software stack with a choice of several RTOS/TCP stack options including ThreadX/NetXThreadX/NetX Duo and FreeRTOS/LwIP.
  • Support for security and networking features such as SSL/TLS, IPv4/IPv6 networking, and mDNS (Bonjour) device discovery.
  • Simple out-of-box device setup using Apple-licensed MFi technology or via a web browser and softAP/web server.

Broadcom also make a set of software examples available that help getting started quickly:

  • Production ready sample applications.
  • Lots of application snippets demonstrating how to use the rich WICED API feature set.
  • Various test applications to aid manufacturing and certification.
  • All documentation included inside the WICED SDK.