Introduction

The Spark Core is a Wi-Fi development kit for internet-connected hardware. The Core has a microcontroller, which runs a single application (often called firmware or an embedded application). Microcontrollers have a set of pins that are called GPIO (General Purpose Input and Output) pins, or I/O pins. They can be hooked to sensors or buttons to listen to the world, or they can be hooked to lights and motors to act upon the world. The pins labeled D0 to D7 and A0 to A7 are hooked directly to the microcontroller's GPIO pins.

The microcontroller can also communicate with other chips using common protocols like Serial (also called UART), SPI, or I2C (also called Wire). You can also connect the Core to special-purpose chips like motor drivers or shift registers. The Core also has a Wi-Fi module, which connects it to your local Wi-Fi network in the same way that your computer or smartphone might connect to a Wi-Fi network. The Core is programmed to stay connected to the internet by default, as long as it can find and connect to a network.

When the Core connects to the internet, it establishes a connection to the Spark Cloud. By connecting to the Cloud, the Core becomes accessible from anywhere through a simple REST API. This API is designed to make it very easy to interface with the Core through a web app or mobile app in a secure, private way, so that only you and those you trust can access the Core.

Serial (UART)

The Core features two serial ports. The first one is a CDC (Communications Device Class) available over the USB port. When configured, it will show up as a virtual COM port on the computer. The second one is a hardware USART available via the TX and RX pins on the Core. Both of these serial ports can be configured and used using the serial functions.
NOTE: Please take into account that the voltage levels on these pins runs at 0V to 3.3V and should not be connected directly to a computer’s RS232 serial port which operates at +/- 12V and can damage the Core.

SPI

The Serial Peripheral Interface is available on pins:
  • A2: SS (Slave Select)
  • A3: SCK (Serial Clock)
  • A4: MISO (Master In Slave Out)
  • A5: MOSI (Master Out Slave In)

I2C

I2C communication pins are multiplexed with the standard GPIO pins D0 and D1.
  • D0: SDA (Serial Data Line)
  • D1: SCL (Serial Clock)
Both of these pins run at 3.3V logic level but are tolerant to 5V inputs.



What's on the Board

The Buttons

  1. The RESET button (on the right)
  2. The MODE button (on the left).
The RESET button will put the Core in a hard reset, effectively depowering and repowering the microcontroller. This is a good way to restart the application that you’ve downloaded onto the Core.

The MODE button serves three functions:
  1. Hold down the MODE button for three seconds to put the Core into Smart Config mode to connect it to your local Wi-Fi network. The LED should start flashing blue.
  2. Hold down the MODE button for ten seconds to clear the Core’s memory of Wi-Fi networks.
  3. Hold down the MODE button, tap on the RESET button and wait for three seconds to enter Bootloader mode, where you can reprogram the Core over USB or JTAG. Release the MODE button when you see the LED flashing yellow. If you do this by accident, simply hit RESET button to leave Bootloader mode.
  4. Hold down the MODE button, tap on the RESET button and wait for ten seconds to do a Factory Reset, where the Core is reprogrammed with the software that was installed on the Core in the factory (the Tinker application). The LED should turn white for three seconds and begin flashing quickly; when the LED switches to another color the Core has been reset. This is useful if you encounter bugs with your firmware, or if you just want to get back to Tinker.




The LEDs

There are two LEDs on the Core. The one in the middle is a full-color RGB LED that shows you the status of the Core’s internet connection. The other small blue LED is the user LED; it's hooked up to D7, so when you turn the D7 pin HIGH or LOW, it turns on and off, respectively.

The RGB LED could show the following states:
  • Flashing blue: Listening mode, waiting for network information.
  • Solid blue: Smart Config complete, network information found.
  • Flashing green: Connecting to local Wi-Fi network.
  • Flashing cyan: Connecting to Spark Cloud.
  • Slow breathing cyan: Successfully connected to Spark Cloud.
  • Flashing yellow: Bootloader mode, waiting for new code via USB or JTAG.
  • Flashing white: Factory Reset initiated.
  • Solid white: Factory Reset complete; rebooting.
The RGB LED can also let you know if there were errors in establishing an internet connection. A red LED means an error has occurred. These errors might include:
  1. Two red flashes: Connection failure due to bad internet connection. Check your network connection.
  2. Three red flashes: The Cloud is inaccessible, but the internet connection is fine. Check our Twitter feed to see if there have been any reported outages; if not, visit our support page for help.
  3. Four red flashes: The Cloud was reached but the secure handshake failed. Visit our support page for help.
  4. Flashing yellow/red: Bad credentials for the Spark Cloud. Contact the Spark team (hello@spark.io).




Pins

The Core has 24 pins that you can connect a circuit to. These pins are:
  • VIN: Connect an unregulated power source here with a voltage between 3.6V and 6V. If you're powering the Core over USB, DO NOT USE THIS pin.

  • 3V3: This pin outputs a regulated 3.3V power rail that can be used to power components. (Also, if you have your own 3.3V regulated power source, you can plug it in here to power the Core).

  • 3V3*: This is a separate low-noise regulated 3.3V power rail designed for analog circuitry that may be susceptible to noise from the digital components. If you're using any sensitive analog sensors, power them from 3V3* instead of from 3V3.

  • !RST: You can reset the Core (same as pressing the RESET button) by connecting this pin to GND.

  • GND: ground pins.

  • D0 to D7: 8 GPIO (General Purpose Input/Output) pins. They’re labeled D because they are Digital pins, meaning they can't read the values of analog sensors. Some of these pins have additional peripherals (SPI, JTAG, etc.) available.

  • A0 to A7: These pins are just like D0 to D7, but they are Analog pins, which means they can read the values of analog sensors (technically speaking they have an ADC peripheral). As with the Digital pins, some of these pins have additional peripherals available.

  • TX and RX: These pins are for communicating over Serial/UART. TX represents the transmitting pin, and RX represents the receiving pin.

  • PWM pins:When you want to use the analogWrite() function, you need to use pins that have a timer peripheral. People often call these PWM pins, since what they do is called Pulse Width Modulation. The Core has 8 PWM pins: A0, A1, A4, A5, A6, A7, D0 and D1.





THE SPARK CLOUD

Generally speaking, when you work in an embedded system, networking happens when you send bytes over TCP sockets and UDP datagrams. Higher-level communications are generally difficult because microcontrollers have little memory and they can’t generally host a traditional HTTP web server. The Spark Cloud gives you the simplicity of the web server with the low cost and low power of a microcontroller by translating between web communications (HTTP requests) and embedded communications (in our case, encrypted CoAP messages).

The best part of the Cloud is that the difficult part of communication is abstracted, so you don’t need to know how it connects to the internet. And once it’s connected, you can make it do things quickly and easily, without dealing with sockets.

By default, if you connect a thing to your Wi-Fi network, it's only available from elsewhere on your local network. This is a result of the fact that we’ve run out of IP addresses, and it's also a security measure, since it means that people can't just reach into your home and mess with your stuff.

Making the stuff in your home available outside your home is generally a pain, and usually requires things like port mapping and static IP addresses. The Cloud lets you ignore this part. The Core connects to the Cloud when it hits your Wi-Fi network, and holds open a persistent connection. This means that it's available from anywhere in the world at any time.

Security is hard. It’s especially hard on an embedded system, because encryption is resource intensive. But it's also important, because you don't want just anyone turning on and off your lights.The Spark Core hand-picked a set of rock-solid security protocols that are secure and efficient, and work great on an embedded system. They're baked into the Spark Protocol, which is open source and ready to be extended to other products.