Author Archives: Jeffrey Branson

APRS: Robust Wireless in an Age of IoT

via SparkFun: Commerce Blog

What is APRS?

APRS (Automatic Packet Reporting System) is data over a frequency-modulated bandwidth of 144.390, and has been around for 25 years – it's an early form of the cell phone and internet network structure as we know it today. Much of the structure of APRS can be traced back to Bob Bruninga, who is still working on it. Thanks Bob!

APRS can be delivered through any number of platforms. The most commonly recognized among these is amateur radio on 144.390 Mhz in the US. This radio signal can originate from a hand held transmitter, an Arduino with a radio unit or even a cellphone. There are numerical appends on your callsign to designate what platform you may be operating from. In my most recent case we are flying weather balloons, so my callsign on the balloon is KD0OTI-11 (the -11 indicates a balloon). The append is fairly flexible and it also builds an icon as your reports populate aprs.fi.

alt text

The APRS system is a huge network of amateur radio repeaters and digital gateways that are maintained and supported by people like you and me all over the world.

We are all well acquainted with the power of our cell phones, but cell service is bounded by towers, reception and of course, monthly billing. APRS gives a tremendous range of communication with no monthly bill. This got my attention.

What can I do with it?

High-altitude balloons

One of the most common applications of APRS is to transmit location coordinates(GPS). There is a robust stack for formatting your coordinates and getting them out. The tracking on the aprs.fi website is very good and it will give you a fairly accurate prediction based on your current speed and direction. Your waypoints are stored and you can get great data and time stamps from the received packets.

alt text

Weather stations

There are a host of resources online to help you build an APRS weather station. Given that Weather Underground has gone behind a paywall, this is a pretty attractive alternative for getting and working with weather data. Also, due to the network of repeaters and the relatively long broadcast distance of two-meter radio, this is a fantastic choice for logging in remote areas.

This project is an ideal classroom exercise and can really get students excited about building their own data logging equipment. The Raspberry Pi is an extremely popular choice and it makes for an ideal use of the early model A and B Pis you may have laying around.

alt text

As an extension of this, Google supports an API on the service and it can lead to a huge array of computer science topics and app development projects. When paired with the HX-1, the world is at your doorstep.

Text messages

Because APRS is parsed on the server side, you can send a wide range of data and service formats. SMS or text messages can be sent from any APRS transmitter by replacing the recipient callsign with the domain server address for the recipient and their phone number. Once again, a simple Google search will give you a tremendous amount of options.

Email

As with SMS, the formatting of APRS can be configured to send email as well as text. The gateway domain is formatted with the email address rather than the phone number and, voila, radio to email.

What APRS is not

APRS is a cousin to packet radio, the two share the same formatting AX.25 but the standard frequencies and the modes of application differ.

APRS is also relatively slow, running at 1200 baud, so video, audio and pictures would be better suited for another protocol.

73's

All of this cool stuff happens over the amateur radio (Ham) bands, so you will need a license and some radio gear. I recently bought an inexpensive set of radios to test things with online for about 30 dollars each, so the investment can be relatively painless. I think the time invested in digging into the Technician license is well worth it and there is no Morse Code requirement.

Let us know how you may be using APRS and happy trails.

comments | comment feed

Migrating a Project from Weather Underground to Open Weather Maps

via SparkFun: Commerce Blog

I am a really big fan of open and free tools; this shouldn’t surprise regular readers of this blog. As I started on a recent project I dug up an old piece of code that used the Weather Underground API. Much to my consternation and dismay, my code didn’t work. A little digging into the matter brought me to the sad fact that they had closed their API. The screenshot below will give you more detail with regard to this closure.

alt text

You get nothing!

I have several projects that have used the Weather Underground API in the past, and although you can still use the Weather Underground template - an excellent, citizen-built platform with many private weather stations reporting - access to downloads from the API is now behind a paywall.

I started digging around to see what else was available. I scrolled through a couple options on Google and settled on Open Weather Map.

alt text

The API documentation is reasonably good on this website and with a little digging I got a working example going in short order.

alt text

Oh, be joyful!

My test example uses an ESP8266, and populates temperature pressure and relative humidity into usable variables in the Arduino environment. My test code is linked via GitHub page in this Repository.

You’ll need to sign up to get a key from Open Weather Map.

alt text

There are a few other services also available, and here is an excellent Reddit discussion of some of the alternatives.

Let me know what you come up with and I would love to see folks using some of the other weather services available with whatever groovy hardware you choose!

comments | comment feed

The National Robotics Challenge

via SparkFun: Commerce Blog

Every year for the last seven years I’ve ventured to Ohio for the National Robotics Challenge. It has become one of my favorite events and I think it’s a unique and powerful example of an “open” event in American education.

alt text

Heavy sumo!

The challenge started over 25 years ago as a event put on by the Society for Manufacturing Engineers. The history is best related by the NRC website:

“National Robotics Challenge began as the Society of Manufacturing Engineers Robotic Technology and Engineering Challenge in 1986, under the guidance and inspiration of Tom Meravi, Associate Professor from Northern Michigan University and the late Dr. James Hannemann. The competitions developed into one of the premier robotics and engineering events in the nation. Tragically, Dr. Hannemann passed away suddenly in July 2001, and in 2003, SME announced that the organization was unable to continue sponsorship of the event.

Most thought that this was the end, but as with all things, every end can be a new beginning. This new beginning was realized by three educators from Marion, Ohio. On the bus ride from Rochester to Marion, Ed Goodwin, Ritch Ramey, and Tad Douce discussed the possibilities and support that existed in their community for this type of event. In 2004 the name was changed from SME/RTEC to the National Robotics Challenge. From its humble beginning, with two work cells and two pick and place competitions, the competition now offers twelve robotics contests. The best is yet to come!”

I met Tad Douce in Baltimore in 2010, and I became fascinated by what he was doing around open robotics and education. From my first visit in 2012 it became clear that this event was special. I was blown away by the range of platforms and application that was in evidence at NRC.

The first year there was a hacked datalogger from a total station survey instrument, running Windows CE next to a LEGO Robotics controller.

alt text

Like they say at Bonneville:“Run what you brung”.

Through the years, the contest has come to embrace an autonomous vehicle contest, which is based on SparkFun’s annual contest. The autonomous vehicle portion is attracting both university and high school teams and grows every year.

alt text

Also running at the event is an IoT challenge based on content SparkFun has worked on with the organizers.

alt text

There are game development and interactivity challenges for middle and high school students that SparkFun is also proud to have developed.

The NRC has seen huge growth in its combat robot contest, and this contest and the sumo robots, as well as Botball, are always a crowd favorites.

alt text

In addition, we usually offer an open wireless cryptography challenge with cool prizes and action-packed fun!

alt text

The manual for 2019’s contest, held April 11-13, is a fantastic place for educators to aim with their classes. I’m already planning for 2019 and looking forward to another great year of competition!

comments | comment feed

Fun with NASA’s Open Data Portal

via SparkFun: Commerce Blog

NASA Open Data

One of the most powerful tools available to tinkerers and prototypers is the Application Program Interface. An API is the structure by which two computer programs talk to each other – think of it as a traffic cop for information traveling between two applications.

In a workshop at SXSW EDU last year, I encountered NASA’s open data platform. My mind was blown by the fact that a good percentage of NASA’s projects reveal their data and code through an open API, and it’s all fairly well supported and reasonably easy to get started with.

To begin, I navigated to the cover page for the Open Data Portal. From there I selected the data catalog; I’m pretty into the asteroid thing these days, so I used the Near Earth Object database.

Asteroids section of the NeoWs API

From here I clicked on the API button:

API access button

This brought me to the opening page for the NeoWs.

alt text

If you go to the Getting Started documents, it will ask you to sign up for a development key. You don’t necessarily need one; you can browse the API catalog and pull out example URLs and use them at will without a key. I chose object 2018GG – there’s a nifty visual of this house-sized space rock here.

After pulling out the URL for the data on 2018GG, I put together a simple Python script that I ran in Trinket.

import urllib.request
contents = urllib.request.urlopen("https://api.nasa.gov/neo/rest/v1/neo/3542519?api_key=DEMO_KEY").read()
print(contents)

When I ran this, I actually got a return in the console matching all the data available for 2018GG:

data for object 2018GG

I called in the urllib library and used the request method. Next, I created a variable and stored the return coming from the URL connected to 2018GG. Finally, I printed out what’s stored in the variable. That’s a lot of data for this simple call. We can simplify things by loading everything into a Json object using the code below.

import urllib.request
import json
contents = urllib.request.urlopen("https://api.nasa.gov/neo/rest/v1/neo/3802394?api_key=DEMO_KEY").read()
varab = json.loads(contents)
print(varab)

This gave me a value and an object notation connected to the value, all comma-separated.

value and object notation

I wanted to find out what the key titles associated with each element of data are, so I wrote a short script that separates out and prints just the keys.

import urllib.request
import json
contents = urllib.request.urlopen("https://api.nasa.gov/neo/rest/v1/neo/3802394?api_key=DEMO_KEY").read()
varab = json.loads(contents)
print(varab.keys())

The printout now shows a whole list of the keys I can work with.

list of keys

Continuing to narrow things down, I picked out a single element from my list of keys and added some text to it and built a small, very specific printout. I separated out the element line I really wanted by a set of asterisks for readability.

import urllib.request
import json
contents = urllib.request.urlopen("https://api.nasa.gov/neo/rest/v1/neo/3802394?api_key=DEMO_KEY").read()
varab = json.loads(contents)
print(varab.keys())
print('*' * 79)
print(('object 3802394 is: ')+varab['close_approach_data'][0]['miss_distance']['miles']+(" miles away!!!"))
print('*' * 79)

smaller printout with isolated element

The fun part of all this is that not only can this be implemented in the Trinket environment like I’ve used here, but it’s a great project for Python on the Raspberry Pi. Further steps might include a warning light or buzzer if an object got too close for comfort. This example would employ the GPIO pins on the Raspberry Pi and give a great overview of connected data through an API and physical computing.

I hope you have fun with this and happy hacking.

comments | comment feed

Getting started with Arduino cryptography

via SparkFun: Commerce Blog

I’m always looking for a way to teach difficult concepts in classroom settings, especially if I can lean on the confluence of my love of tinkering and my love of puzzles.

alt text

An Enigma code machine

I bought a new house several months ago and it has a garage. I don’t want to buy new garage remotes (that would be much too easy) when I can build them out of parts that SparkFun sells everyday. The thought occurred to me that it would be fun to do in encrypted wireless using an XBee module; that way I could program not only commands for the garage door, but for lights and the front door and anything else that I can put on electronic control.

alt text

A basic substitution cipher

At the heart of the way we do business on the web is RSA encryption. RSA is a brilliant and complicated way to encrypt information using large prime numbers. As many of us can remember from algebra, the prime factorization of large numbers can be very difficult. RSA relies on using this within a framework of modular exponentiation and totient equations to pass information safely.

All of this is very effective for secure banking transactions, but probably not necessary for turning on lights at my house.

alt text

alt text

An early puzzle box I built with BASIC STAMP.

When I started thinking about this problem I did, however, take some of the way we think about RSA encryption and applied it to a simple Arduino program. Here is how I thought about my problem:

  1. Using an Arduino base station to store an array of three-digit numbers.

  2. Use the random function in Arduino to generate a random number, store it in a variable and subtract it from a random place in the array.

  3. Pass the place in the array and difference generated to a client device as values separated by commas.

  4. If the client device has the matching array as the base station, it will subtract the number it received from the specific place in the array, and pass the difference back to the base station.

  5. The base station will add the answer it receives from the requesting device to the number stored in the variable. If the sum of these two things is equivalent to the place in the array that the base station has been working with, it will grant access to the client device.

Let’s look at this in action!

My array = {103,147,171,199}

My random number generated = 59

My random pace in the array = 2

So: 171-59 = 112

I pass to a device requesting access (2,112).

If that device has the same array stored on it as my key array on the base station, it will subtract what it received from the specified place in the array.

 171-112 = 59

I send back to the base station a request (like the character “r”) and 59, so the transmission would be (r,59).

The base station then adds the number it receives - if that number and the number it sent are equivalent to the value in that place in the array, it grants the request. In my Arduino code I have set it up so that our lights are red LEDs.

Here’s some Arduino code; test it with the serial terminal.

///////////////////////

int keys[]=

{117,161,173,187,199};

int arryPos=0;

char request;

int arrayPos;

int subtractNum;

int returnVal;

int red=0;

int blue=0;

int green=0;

void setup()

{
Serial.begin(9600);



pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11,OUTPUT);

pinMode(10,OUTPUT);

pinMode(9,OUTPUT);


}


void loop()

{


//subtractNum=10;




  if(Serial.available()!=0)

  {

request= Serial.read();

 digitalWrite(13, HIGH);

if(request=='a')

{

arrayPos=(random(0,4));

subtractNum=(random(1,100));



delay(10);

Serial.print(arrayPos);

Serial.print(",");

Serial.println(keys[arrayPos]-subtractNum);


}

if(request=='r')

{

 returnVal=Serial.parseInt();

Serial.print("array val =");

Serial.println(keys[arrayPos]);

Serial.print(returnVal + keys[arrayPos]-subtractNum);//subtractNum=10+ x = 117

delay(50);

if(returnVal + keys[arrayPos]-subtractNum==keys[arrayPos])

{

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

}

}


}

digitalWrite(13,LOW);

}

//////////////////////

When you get this code loaded to the Arduino, you can then follow these steps:

  1. Open a terminal in Arduino and send your board the character “a.”

alt text

  1. You will receive two values separated by commas. The first value is the place in the array, and the second value is what to subtract from the value in the array.

alt text

  1. Return the character “r,” separated from the difference with a comma.

alt text

  1. You should get a return equivalent to the array value and the sum of the two values. If you have an LED connected to pin 9, it should blink.

alt text

The next step is creating a device to send the serial commands. This could be another Arduino, and this is where it really opens up. The client could be a traditional remote with push-button function, or a keypad, or even a fingerprint reader.

I think the classroom applications of this project are particularly interesting. The idea I had was to let students “tune into” the traffic being passed back and forth, and try to figure out the key array based on the behavior of the packets – seems like a great hacking/cryptography prompt.

I am adding code to my GitHub page, so you are welcome to dig around there and take this further. Happy hacking!

comments | comment feed