Our products, Nanode, wireless, MCUs, electronics and more

Sketch Garden: Success and Fail videos

Posted: April 7th, 2012 | Author: | Filed under: Sketchgarden | Tags: | Comments Off

Here are two videos showing what a successful download looks like, and what happens when a download fails midway. By knowing the blink pattern of a failed download – two short blinks, pause, two short blinks – you can diagnose problems.
First the successful download:

And now what happens when a download fails halfway through.


Uploading a sketch in Sketch Garden

Posted: April 6th, 2012 | Author: | Filed under: Sketchgarden | Tags: | Comments Off

We have simplified how to upload sketches. Here is a video explaining the new steps. They are:
- Compile the sketch in Arduino
- Grab the .hex file and upload it to sketchgarden.co


Improvements to Sketch Garden

Posted: March 26th, 2012 | Author: | Filed under: Sketchgarden | Tags: | Comments Off
Some improvements to Sketch Garden:
  • We fixed a pretty big bug which was creating a lot of “Can’t communicate with device” errors. If you ever received this error, please try again.
  • You can now upload .hex files, which will be converted to binary automatically.
  • There is also a new upload progress bar, which is more informative.

Also, don’t forget to try the auto-upload library (previous blog post). I have this working routinely, and it works great.

I would say the system is significantly more robust now than it was a week ago. Once again a big thank you to all beta testers.


Auto uploading with Sketch Garden Example

Posted: March 25th, 2012 | Author: | Filed under: Sketchgarden | Tags: | Comments Off

By design, the Sketch Garden bootloader does not handle automatically uploading a new sketch – you have to manually push the reset button. Any auto reset must be handled from within the sketch. This post explains how to do this.

There are two parts to getting a new sketch:

  1. Timing a certain interval, and
  2. Checking back with sketchgarden.co once that interval has expired

Aside:
Resetting the Nanode is handled through the watchdog timer (WDT). This site has a pretty good explanation of how it works, but we basically take the canonical approach to soft-reset described by the avr-libc FAQ. Sketch Garden decides that it “Can’t Communicate with the Device” after about a minute of waiting for contact after Download Activation, so we set the Nanode polling interval to about 30 seconds.

Ok, back to the sketch. First, we need to get some libraries. In each case download the zip file, and unpack it in your Arduino libraries folder.
Ethercard: Basic Ethernet functions – chances are you are using this library anyway.
NanodeMAC: Reads you Nanode’s MAC chip to get the  unique MAC Address for your board. You can write in your own address into the sketch if you prefer.
SketchGarden: The auto reset library

The code itself instantiates a SketchGarden object, then services it whenever it times out.

Since this code does not do anything useful, a good first exercise would be to add in blink or fade – switching between the two is an easy way to make sure it is working. Don’t forget the Nanode built in LED is on pin 6, not pin 13 like Arduino.

The sample code is very simple.

/* Sketch Garden Nanode.ino
 For use with http://sketchgarden.co
  This sketch is released into the public domain by
  Wicked Device LLC
  Author: Vic Aprea, March 2012
  Change Log:
     - March 21, 2012, Initial Sketch, Vic Aprea
     - March 22, 2012, Minor changes, Dirk Swart
 */

// YOU MUST INCLUDE THESE HEADERS (you probably were going to anyway :)
#include <EtherCard.h>
#include <SketchGardenNanode.h>
#include <NanodeMAC.h> // Automatically reads your Nanode's MAC chip for you

// THE USUAL HELPERS FOR THE EtherCard LIBRARY
static uint8_t mymac[6] = { 0,0,0,0,0,0 };
NanodeMAC mac( mymac );
byte Ethernet::buffer[700];

// CREATE YOUR SketchGardenNanode OBJECT
SketchGardenNanode sgn;

void setup () {
  // SERIAL PRINTS CAN BE REMOVED IF YOU DON'T WANT THEM
  Serial.begin(57600);
  Serial.println("\n[webClient]");

  // INITIALIZE THE ETHERCARD LIBRARY AS YOU NORMALLY WOULD
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");

  // GET AN IP ADDRESS WITH DHCP (YOU CAN CHANGE THIS IF YOU WANT TO USE STATIC IP)
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");          

  // INITIALIZE THE SketchGardenNanode OBJECT
  if(!sgn.start()){
    Serial.println("Sketch Garden Initialization Failed");
  }

  ether.printIp("SketchGarden IP: ", ether.hisip);  

  // INSERT YOUR CUSTOM CODE HERE

}

void loop(){
  // SERVICE THE ETHERNET CONTROLLER PACKET LOOP
  ether.packetLoop(ether.packetReceive());

  // CALL THE SketchGardenNanode POLL METHOD
  // THIS INTERNALLY KEEPS TRACK OF TIME AND POLLS SKETCHGARDEN FOR STATUS EVERY 30 SECONDS
  // IF YOU ACTIVATE A SKETCH ON THE SKETCHGARDEN WEBSITE THE POLL METHOD WILL CAUSE A RESET!
  if(sgn.poll()){
    Serial.print(millis(), DEC);
    Serial.print(" ");
    Serial.println("Polled Sketch Garden");
  }

  // INSERT YOUR CUSTOM CODE HERE... YOU SHOULD TRY NOT TO BLOCK AS MUCH AS POSSIBLE
  // OR YOUR PACKET LOOP MIGHT FALL BEHIND AND YOU MIGHT START DROPPING PACKETS (NOTHING NEW HERE)  

}

Sketch Garden cranking it out

Posted: March 14th, 2012 | Author: | Filed under: Sketchgarden | Tags: | Comments Off

Many of you have been following our work on Sketch Garden, a way to upload sketches to your Nanode over the internet. We are starting to get successful uploads happening from some early beta testers, which is great. First upload goes to Jaren Havell who tweeted:

Jaren Havell@j_jwalrus

My nanode just updated its arduino sketch…over the Internet! Sketchgarden.co working like a charm!

Congratulations Jaren, and keep it up!