Tuesday, February 26, 2013

Building a GPS, Temperature and Pressure Logger

Hello Everyone,

I feel like I am never working on with my Arduino or writing in this blog, but over the past two weekends, I built a GPS, temperature and pressure logger.
I ordered my stuff from Adafruit.com.  They sell a large range of microcontroller parts and goodies and as a bonus have a great forum and an excellent learning site that provides you with information on wiring your sensor to your Arduino, and even example code and project ideas.
I ordered an Adafruit Ultimate GPS Breakout Board (v3), an Adafruit MicroSD breakout board and an Bosch  BMP085 breakout board, and all this for $40, $15 and $20, respectively. I also ordered an external antenna for the GPS unit, you don't really need this but I thought that for $12, why not.

Skipping over many details, I wired the three boards up to my Arduino pretty quickly and then had to write the code to do the measurements, parse the data and write it to the SD card.  Luckily there are some great libraries out there and I ended up using the Adafruit BMP085 library and the TinyGPS library.
I made a few modifications to the TinyGPS library to parse the geoid height (height of the gravitational potential surface) above the ellipsoid. After alot of trial and error I finally got the GPS unit to spit out data each 0.5 seconds when it has a new position, and then also to record the temperature and pressure from the BMP085 sensor.


On the left is the breadboard with the BMP085 on the top, the GPS sensor in the middle and the MicroSD card on the bottom.  My Arduino Uno R3 is shown on the right.

A close up of the BMP085 (top), GPS (middle) and MicroSD card (bottom) breakout boards

At first, my code ran a bit slowly, but I figured out that was because I was writing out floating point precision values for latitude, longitude, altitude, geoid height and others.  Once I changed to writing out integer values (so latitude in 100000s of a degree, altitude in cm, etc), the code could run fast on the Arduino, making writing to the card faster.
Since taking these pictures I have also added a button and an LED that I use to stop writing data to the card, and properly closing the file on the card so that there are no issues when I then unplug the power and try to look at the data.  I lost one SD card because the files were open while I removed the card and the card was switch to a read only mode, and could not be changed back to read/write mode no matter what I tried.



On Friday night I went to get some groceries, so I thought I'd take my Arduino along for the ride. Below is a map that shows part of my journey between two grocery stores. When not hooked up to my computer I run the Arduino using 6 AA batteries which works pretty well and let me run the system for about 8 hours one night.

Sample GPS track. Produced using GPSVisualizer.com.

Close up of GPS track.  Performance is okay not perfect but well within what you would expect from a single frequency handheld GPS receiver.


Cool, well that is a brief summary.  Next I might try to add a thermistor circuit for a temperature measurement over a larger temperature range and with better accuracy and precision.  I may try to add a serial enabled character LCD to print out the location to, and then put the entire thing in an enclosure of some kind.

The next use for it will hopefully be for the course for which I am a teaching assistant.  We hope to launch a high altitude balloon up to 25+km and record some data on my Arduino, as well as take some cool pictures.

If you have any questions about the setup, my code, or otherwise, don't hesitate to comment below.

Sunday, September 9, 2012

And then I said let there be a way for you to see what I want

After  a short hiatus, I am back.  Fear not though, I have not been idle.
Over the past couple of weeks I have been struggling with the decision to either purchase an LCD display and keypad or to find one and use it. 

After much thought, I finally realized I had a keypad with a display from work and decided that since we had a couple of them I would use one, at least temporarily (will get back to this later).

Okay so I disassembled the keypad unit and removed the LCD and its board, luckily the LCD was plugged in to the keypad board in a simple manner.

Then I did some searching and some trial and error testing until I could determine which pins on the LCD board where supposed to be plugged in where on the Arduino.

I was mostly helped by the Arduino Graphical LCD (DLCD) display library and its webpage which had a nice wiring "Default" schematic to start from.

The video below shows a simple demo Arduino script provided by the GLCD library that listens for input from your keypad and displays it on the Arduino.


All well and good, the display works, the contrast is adjustable and based on other examples I've seen, we could do all kinds of fancy things, like measuring the light levels and/or the temperature and adjusting the contrast and backlight brightness.


The next video shows another demo Arduino script provided by the GLCD library to show some of the capabilities of the library and the display.



From the video you could guess that it wouldn't be too difficult to write other games (pong, asteroids) or other features such as a clock.


While I am extremely happy that I have got this display to work, there are some problems:

1) The display requires a heck of a lot of space/ports on my Arduino board, 15 to be precise (my board has not much more than this).



2) I still don't have a keypad that works, the one from the unit doesn't seem to interface to the Arduino in any simple manner.  I suspect the keypad board has its own micro controller which then just ouputs some serial data or something.

The first problem is the biggest one for me, I think.  I'm not sure how many ports my camera time-lapse project will require, but I think more than just a couple.  I'd like to have some fun and fancy features (GPS triggering, light triggering, sound triggering, etc) that will require inputs.

That, said, I'm not sure that I can't get around this. Will have to think about it a bit.

Next up will be getting a keypad that works.

Justin

Saturday, August 18, 2012

And After 7 days I decided...let there be coloured light

Hey Everyone,

Well today is Saturday so that means more Micro Controller FUN TIME!
Today we will be playing with my RGB LED and using various sensors to control the color.

Lets first start just with the RGB LED. I've written a simple for loop that loops through each color separately once, while the other colors are set off. The color simply gets brighter as the value sent to the LED varies from 0 to 255.  Then I use the same scale but increase RED from 0-255, decrease GREEN from 255 to 0 and leave BLUE set to 255.  Lastly I set RED to 255, increase GREEN from 0-255 and decrease BLUE from 255 to 0. All this takes is 5 simple for loops.  Simple.

Next I decided to use my photoresistor to change the color.  I set RED to 255, GREEN to be dependent on the light level and blue to be 0. I scaled the output from the photoresistor to be within 0-255.  As you can see in this video, when I shine the light from my iPhone onto the photoresistor, the color changes. Because the sensor is less resistive under more brighter light, the color switches from yellowy green to red.  You can see in the video below that the response is very very quick, and quite sensitive to the light  on the sensor.


Next is a quick video showing the use of the soft potentiometer.  As you can see as I move my finger along the softpot, the color of the LED changes! HORRAY!!!



After that I thought, well lets see if we can use the temperature to control the light color.  Using the map function I was able to get this work quite well, at least I think so. Here it goes from blue when less than 18 Celsius degrees to red when more than 25 degrees Celsius. I could have just as easily mapped this to be very sensitive to small changes in color. Or even a easier, a threshold value, but I wanted to do a gradient.

Okay, so I think you get the message that you can control many variables with many other variables.  This will most definitely come in handy during my quest to build a time lapse device as I believe I may also build a high-speed shot set up, whereby a flash going off triggers my camera to take a picture.  People have used this to dramatic effect to capture pictures of slashes, balloons bursting.


Next we will be trying to convince Nicole's old Canon A520 to become a time-lapse camera using CHDK (Canon Hack) and the Arduino.

Sunday, August 12, 2012

And then there was light, LED light that is.

On Friday afternoon my Arduino Inventors Kit from Spark Fun Electronics (purchased through RobotShop.ca) arrived in the mail. While I had originally planned on doing a video blog, I quickly realized that I am quite terrible at video blogging. So Instead I think I will write out my processes, thoughts and include some photographs and videos of the experiments.

The box the kit came in was a bit over stuffed and bulging on one side, but once I opened it up, I found this was due to the amount of protective padding they have placed around the actual kit box.
RobotShop Box containing my Kit

In the box was my beautifully packaged Inventors Kit from SparkFun Electronics.

My SparkFun Inventors Kit
 Everything inside was nicely organized and packaged.  The kit contains numerous jumper wires for connecting the Arduino Uno to the breadboard (pictured below), in addition to many 10K Ohm resistors and 330 Ohm resistors.

My Arduino Uno Rev 3 micro controller (right) and "breadboard" on the left.
Since I will invariably end up using many different types of resistors, I thought it might be interesting to present some information on the color codes that are used on resistors. A resistor always has 3 or four colored lines around it to indicate its resistance. A resistor with 4 color bands indicates the resistance  in the first two bands, the multiplier as the third band and the resistors tolerance value is the fourth band. A three band resistor does not report the tolerance. A 5 band resistor will have three resistance value bands, then the multiplier band and the tolerance band.
For more information I strongly urge you to just check Wikipedia or do a quick google search.


The Inventors Kit also contains 10 yellow LEDs, 10 red LEDs, one RGB LED (an LED that contains Red, Green and Blue components).   An RGB device can produce many colours.
Additionally the kit contains a piezo element that can be used to produce sounds, a temperature sensor, several push buttons, a servo, a DC motor, a soft potentiometer (a thin potentiometer whose resistance changes by pressing at different points along the potentiometer), a flex sensor (where the resistance of the device changes as the device is stretched/bent), a diode (basically a one way valve for electricity), a transistor (ampiflier/switch), a relay (a switch), a photoresistor (a resistor whose resistance changes with the amount of light that hits it), a regular potentiometer (an adjustable voltage divider (like a volume knob) , and a shift register (a type of integrated circuit).


Okay, well now to some of the fun that I had on the first day.
First I played with turning an LED ON and then OFF. Then using the kit instructuions I stepped it up and did this:



I modified the code slightly to bring the the side by side pairs on at the same time instead of following an order that went down the left side, then down the right side.All this took was modifying the codes for loops.

Next I played with the piezo element and following the instructions and sample code created the sample circuit and made it play the first line from Twinkle Twinkle Little Star. With more time/personaly interest, you could complete the full song and numerous other songs.  All you need to do is determine the notes that make up the song, the frequency of those notes, and thus the period and time to activate the piezo for.




Okay, well that is all for me from day 1. Next I think I"ll look at the RGB LED and the softpot (soft potentiometer), there is an example experiment showing how to use the softpot to change the color of the RGB LED.  After that example I think I'll start moving on to my ultimate goals, controlling my DSLR. First I'll start by controlling an old digital camera I have and then move up from there, as I really really don't want to fry my DSLR.


Until next time.... 0100100001100001011101100110010100100000011001100111010101101110001000000110110101101001011000110111001001101111001000000110001101101111011011100111010001110010011011110110110001101100011010010110111001100111001000000111100101101111011101010111001000100000011101110110111101110010011011000110010000101110.....


....hint convert from binary to ASCII.


Wednesday, August 8, 2012

Introduction

As you may have guessed this blog is going to be about my learning experience with micro-controllers.
I just ordered an Arduino Uno Rev 3 Inventors Kit from Spark Fun Electronics.

I thought it might be fun to post some pictures, videos and other things as I learn about this, maybe it will be useful to me in the future or perhaps other people who are just starting out with micro-controllers.

I am not an engineer, my electronics experience is somewhat limited. I have experience with Campbell Scientific data loggers and various environmental sensors, some wiring and soldering experience.  I also have a bit of programming experience, in MatLab, Python, IDL, HTML, and PHP.  However, most of my experience is with MatLab and Python.

My kit hasn't even arrived yet, but I'm so excited I thought I would start the blog today just by writing this introduction.

It will only be linked to my main blog (justinbeckers.blogspot.com) a few times (i.e. this post and maybe one or two more). I don't want to get the blogs crossed up too much and I use the other blog/pages for my research activities.