Monthly Archives: July 2019

Enginursday: Lightning Detector for the Trail

via SparkFun: Commerce Blog

The Idea ⚡

I feel quite lucky to live and work so close to the Rocky Mountains here in Colorado, and it’s a common hobby among us at SparkFun to be out hiking/biking/kayaking or climbing. The mountains contain numerous hazards, not the least of which is lighting strikes. The weather can change suddenly and drastically around these parts. There is a common Colorado saying, “If you don’t like the weather, wait 5 minutes." Unfortunately, this also applies to weather you are enjoying and it can be easy to find yourself suddenly looking at a stormfront that the weather station has assured you would pass to the south. Prevention is always ideal, but even a small amount of lightning prescience can allow you to find cover or start that rappel sooner.

Rooftop View from SparkFUn

View from the rooftop lunch table at SparkFun

SparkFun is releasing an updated version of our AS3935 Lightning Detector this week. We have had fun using it around the office to confirm that indeed it is raining, and there was strong desire to see this outdoors where it belongs. I decided to start something and get this idea into the prototype phase.

The Make ⚡

My goals for the outdoor detector were:

  • portable and sturdy enough it could be clipped onto a harness
  • report out how close the approaching lighting is
  • give easy-to-understand indicators of a nearby strike

The new Lightning Detector goes live tomorrow, and luckily I have one that "fell off" the initial run.

To start, I wanted to pick a microcontroller that fit my needs: the RedBoard Turbo. This was an easy choice. It is battery powered, can communicate over SPI to the AS3935 Lightning Detector, uses 3.3V for its I/O, and even has a Qwiic connector! This is my go-to prototyping with a battery board.

SparkFun RedBoard Turbo - SAMD21 Development Board

SparkFun RedBoard Turbo - SAMD21 Development Board


Enter the Qwiic Micro OLED

Next, I needed a way to display the data the detector was receiving and sending back to the RedBoard Turbo. The Qwiic Micro OLED was a perfect choice.

SparkFun Micro OLED Breakout (Qwiic)

SparkFun Micro OLED Breakout (Qwiic)


With a simple Qwiic Cable, this board connected over I2C and, using example code from the hookup guide, it was displaying data in minutes.

Data Displayed via the Qwiic micro OLED screen

I used a small buzzer from the SIK, some jumper cables for hookup and a lipo battery for power.

Code ⚡

Below is the code used with the SAMD21 RedBoard Turbo, Lightning Detector and Qwiic Micro OLED.

This example demonstrates the code used on the Outdoor Lighting Warning Prototype
License: This code is public domain


#include <SPI.h>
#include <Wire.h>
#include "SparkFun_AS3935.h"
#include <SFE_MicroOLED.h>  // Include the SFE_MicroOLED library
#define INDOOR 0x12
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

SparkFun_AS3935 lightning;

const int lightningInt = 3;// Interrupt pin for lightning detection
int spiCS = 4; //SPI chip select pin

// This variable holds the number representing the lightning or non-lightning
// event issued by the lightning detector.
int intVal = 0;
int noise = 2; // Value between 1-7
int disturber = 2; // Value between 1-10

//The library assumes a reset pin is necessary. The Qwiic OLED has RST hard-wired, so pick an arbitrarty IO pin that is not     being used
#define PIN_RESET 9
//The DC_JUMPER is the I2C Address Select jumper. Set to 1 if the jumper is open (Default), or set to 0 if it's closed.
#define DC_JUMPER 1

bool warmedup = false;
int distanceview = 3;
const int buzzerPin = 9;
const int songLength = 18;
char notes[] = "cdfda ag cdfdg gf "; // a space represents a rest
int beats[] = {1, 1, 1, 1, 1, 1, 4, 4, 2, 1, 1, 1, 1, 1, 1, 4, 4, 2};
int tempo = 113;

// MicroOLED Object Declaration //
MicroOLED oled(PIN_RESET, DC_JUMPER);    // I2C declaration

void setup()
// When lightning is detected the interrupt pin goes HIGH.
 pinMode(lightningInt, INPUT);

 SerialUSB.println("AS3935 Franklin Lightning Detector");

 pinMode(buzzerPin, OUTPUT);


void loop()

if (warmedup == false)

if (digitalRead(lightningInt) == HIGH)

intVal = lightning.readInterruptReg();

if (intVal == NOISE_INT) {
  // Too much noise? Uncomment the code below, a higher number means better
  // noise rejection.
else if (intVal == DISTURBER_INT) {
  // Too many disturbers? Uncomment the code below, a higher number means better
  // disturber rejection.
else if (intVal == LIGHTNING_INT) {
  SerialUSB.println("Lightning Strike Detected!");
  // Lightning! Now how far away is it? Distance estimation takes into
  // account any previously seen events in the last 15 seconds.
  byte distance = lightning.distanceToStorm();
  SerialUSB.print("Approximately: ");
  SerialUSB.println("km away!");
  distanceview = distance;

delay(100); // Slow it down.


void warmup()

if ( !lightning.beginSPI(spiCS, 2000000) ) {
    SerialUSB.println ("Lightning Detector did not start up, freezing!");
 while (1);
    SerialUSB.println("Schmow-ZoW, Lightning Detector Ready!");
 warmedup = true;


int enviVal = lightning.readIndoorOutdoor();
SerialUSB.print("Are we set for indoor or outdoor: ");
if ( enviVal == INDOOR )
else if ( enviVal == OUTDOOR )
    SerialUSB.println(enviVal, BIN);


void lightningData()
oled.begin();    // Initialize the OLED
oled.clear(ALL); // Clear the display's internal memory
oled.display();  // Display what's in the buffer (splashscreen)
delay(1000);     // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.

  printTitle("Storm!", 0);

  oled.clear(PAGE);     // Clear the screen
  oled.setFontType(0);  // Set font to type 0
  oled.setCursor(0, 0); // Set cursor to top-left

  delay(50);  // Wait 500ms before next example

  oled.clear(PAGE);            // Clear the display
  oled.setCursor(0, 0);        // Set cursor to top-left
  oled.setFontType(0);         // Smallest font
  oled.print("Distance: ");
  oled.setCursor(16, 12);// Print "A0"
  oled.setCursor(0, 34);
  oled.print("Km Away!");


void printTitle(String title, int font)
  int middleX = oled.getLCDWidth() / 2;
  int middleY = oled.getLCDHeight() / 2;

  // Try to set the cursor in the middle of the screen
  oled.setCursor(middleX - (oled.getFontWidth() * (title.length() / 2)),
                 middleY - (oled.getFontHeight() / 2));
  // Print the title:

int frequency(char note)
  // This function takes a note character (a-g), and returns the
  // corresponding frequency in Hz for the tone() function.

int i;
const int numNotes = 8;  // number of notes we're storing

// The following arrays hold the note characters and their
 // corresponding frequencies. The last "C" note is uppercase
// to separate it from the first lowercase "c". If you want to
// add more notes, you'll need to use unique characters.

// For the "char" (character) type, we put single characters
// in single quotes.

  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};

  // Now we'll search through the letters in the array, and if
  // we find it, we'll return the frequency for that note.

  for (i = 0; i < numNotes; i++)  // Step through the notes
    if (names[i] == note)         // Is this the one?
      return (frequencies[i]);    // Yes! Return the frequency
  return (0); // We looked through everything and didn't find it,
  // but we still need to return a value, so return 0.

void buzzing()
  int i, duration;

  for (i = 0; i < songLength; i++) // step through the song arrays
 duration = beats[i] * tempo;  // length of note/rest in ms

if (notes[i] == ' ')          // is this a rest?
  delay(duration);            // then pause for a moment
else                          // otherwise, play the note
  tone(buzzerPin, frequency(notes[i]), duration);
  delay(duration);            // wait for tone to finish
delay(tempo / 10);            // brief pause between notes



Next was to create an enclosure for the project. Luckily we have a CO2 laser cutter and plenty of clear acrylic! I tossed together a box design with some 0.8-inch spaced standoff holes to mount the sensor, display and microcontroller.

Enclosure Design

Time to put the assembly together in the enclosure.

I later added large 0.75-inch holes to pass a sling through.

Laser Cut Enclosure

And Finally, Does It Fit on a Harness?

Here are a few pictures of the enclosure being used with a harness.

Harness View 1

Harness View 2 Harness View 3

Click on the images for a closer view.

Final Thoughts ⚡ ⚡ ⚡

I had a lightning emulator, which helped greatly in the development process, but there was a large amount of disturbance events here at SparkFun and the real test will be bringing it outside with me. With everything hooked up, we get both a auditory indication of a lightning strike being detected and a display of distance on the OLED. When all the screws, standoffs, lipo battery and sling were added, the total enclosure weighed about 5 oz or 0.3 lbs. Although this a tolerable weight to bring backpacking or climbing, I feel like there is a lot of room to decrease the weight of the project. I am very excited to bring this into the woods and the on the rocks with me, update the design and report back to you all with my findings.

comments | comment feed

RPi’s Greatest Hits: Using RealVNC

via SparkFun: Commerce Blog

Recently, there have been a lot of things Raspberry Pi related at SparkFun. While we are all eagerly anticipating the incoming stock of the new Pi 4 (the Pi of your dreams), we like to make sure everyone on our team who needs access to a Pi for testing and regular use has access to it.

For me, using the VNC (Virtual Network Computing) functionality built into the recent Pis provides that solution. The best bike in the world is the one you are riding, the best camera in the world is the one you have with you, and the best RPi in the world is the one I can access when I need it. VNC allows us to work and share no matter where you are in the building, and minimizes the number of changes I need to make to my normal screen and keyboard layout routine.

This tutorial originally written by Shawn Hymel (shout-out!!) covers everything you need to access your Pi over a local network or remotely over the internet. The remote functionality is very helpful when you need to access your desktop Pi at home or your personal Pi while at work. If you don't have a newer version of the Raspberry Pi, this tutorial will still get you up and running with a download of the "real-vnc" program in the section on "Enabling VNC."

We also love how this lets new users of Raspberry Pi learn to be more comfortable using the terminal window and other features, since you can copy/paste direct from a SparkFun tutorial or SparkFun forum post on your computer into the RPi environment!

How to Use Remote Desktop on the Raspberry Pi with VNC

July 9, 2018

Use RealVNC to connect to your Raspberry Pi to control the graphical desktop remotely across the network.

comments | comment feed

A New Artemis Guide is Here

via SparkFun: Commerce Blog

We affectionately refer to the BlackBoard Artemis ATP as the "All The Pins!" board, since it breaks out every single one of the SparkFun Artemis Module's 48 GPIO pins into a familiar, Mega-like form factor. On top of the BlackBoard's improved power conditioning and USB-to-serial, we've added a slew of features to help you take full advantage of the Artemis module's unique features.

Now there is a new guide for the SparkFun Artemis ATP board! Read about it here!


Hookup Guide for the BlackBoard Artemis ATP

July 15, 2019

Get started with the BlackBoard Artemis ATP - all the functionality of the SparkFun Artemis module wrapped in the Mega Arduino Footprint

You can check out all these features in our newsletter. Feel free to poke at the code as well! We've included examples for all the features of the Artemis in our Arduino Core.

comments | comment feed

Friday Product Post: Enjoy the Ambience

via SparkFun: Commerce Blog

Hello and welcome! We only have a couple products to show off today, because we're getting Artemis ready for a full production run (let's be honest, everything looks better in red), and we have a mid-week release next Wednesday! This week, we have a new Qwiic-enabled Ambient Light Sensor along with an updated LilyPad LED board.

Before we get into new products, we wanted to give you an early heads-up that we are having a sale tomorrow (Saturday, July 20th) in celebration of the 50th anniversary of the Apollo 11 moon walk. From 12:00 a.m. MT through 11:59 p.m. MT, use the promo code APOLLO11 to receive $50 off our SparkFun Inventor's Kit for RedBot and the Arduino Engineering Kit. Please be aware that this sale is for in-stock items only, some exclusions do apply, and it's only while supplies last.

Do you see what I see?

SparkFun Ambient Light Sensor - VEML6030 (Qwiic)

SparkFun Ambient Light Sensor - VEML6030 (Qwiic)


Looking for an option to sense ambient light? The SparkFun VEML6030 Ambient Light Sensor is a great starter option. The VEML6030 is a high accuracy ambient light sensor with 16-bit resolution. Even more impressive is that it can detect light similarly to the way the human eye does. Utilizing our handy Qwiic system, no soldering is required to connect it to the rest of your system. However, we still have broken out 0.1"-spaced pins in case you prefer to use a breadboard.




Blink any color you need! Use the LilyPad RGB LED board as a simple indicator or, by pulsing the red, green and blue channels, you can produce a broad variety of colors. Each of the colors in the RGB LED is connected to one of the sew tabs on the board labeled R, G and B.

That's it for this week! As always, we can't wait to see what you make! Shoot us a tweet @sparkfun, or let us know on Instagram or Facebook. We’d love to see what projects you’ve made!

comments | comment feed

Enginursday: Building a Wireless EL Wire Dance Suit, Part 2

via SparkFun: Commerce Blog

We're back! There were a lot of steps to consider when completing the project, most of which had to be repeated for each of the seven dancers.

EL Hoodie and Pants Worn on Dancers

The most time consuming part of making seven wireless EL wire dance suits was actually sewing the 42 meters (~1,653.5 inches) by hand. I'm not an expert at sewing, so adding EL wire along a hoodie's arms made out of stretchy material was not the easiest. I had to put together a jig made out of cardboard to help sew into the arms.

Sewing EL to a Hoodie made out of Stretchy Material

Hoodie Arm Clipped to Cardboard Jig to Sew EL Wire Down

Adding EL wire along the side of polyester pants was easier, since the material did not move around.

EL Wire Sewn on Pants

The kids aren't all the same size, so I decided to make a few custom EL wire extension cables rather then tailoring the suits for each dancer. This also made it easier to quickly disconnect the hoodie or pants from the inverter.

EL Wire Extension Cable

I decided to use a 12V inverter to power the EL wires. To make it run off a single power supply with the EL Sequencer and XBee, the wires for the inverter's input had to be switched out. Instead of a barrel jack, a 2-pin JST connector was used.

Reworking 12V Inverter

How Do You Build Such a Thing?

In addition to making a wireless glove controller, here are a few more tutorials needed to complete this project.

EL Wire Hoodie

In this tutorial, we will sew standard electroluminescent (EL) wire to a hoodie.

EL Wire Pants

In this tutorial, we will sew standard electroluminescent (EL) wire to a pair of pants.

How to Make a Custom EL Wire Extension Cable

In this tutorial, we will make a custom EL Wire extension cable as an alternative to splicing wire.

Modifying Your EL Wire Inverter

In this tutorial, we will modify the 12V EL wire inverter to power the EL Sequencer/EL Escudo Dos off a single power supply.

Tune in some time in the future when I broadcast a signal from the wireless glove controller to remotely trigger each EL Sequencer. ;D

comments | comment feed

The Latest from Artemis

via SparkFun: Commerce Blog

Last week we gave you an update on everything that we have added to the SparkFun Artemis Module since its release. We want to keep you updated on all the Artemis news, even if they aren't as exciting as a BLE Mesh update (we're working on it), so let's quickly go over the two new updates for Artemis!

  • ShiftIn, ShiftOut, PulseIn - Admittedly, not the most exciting new update, but one that is often overlooked. We're making it as easy as possible to switch architectures! When you don't need to change your code, you'll know it's working.

  • Tone - Beep boop beep! Buzzers and other tone creators now function with the Artemis running the show!

The Artemis family!

You can check out all these features in our newsletter. Feel free to poke at the code as well! We've included examples for all the features of the Artemis in our Arduino Core.

comments | comment feed