Tag Archive | "microSD"

Results – February 2012 Competition

Competition over.

Posted in competition

February 2012 Competition

Competition over

Posted in competition

Review – Freetronics EtherMega

In this review we take a look at what is possibly the most fully-featured Arduino compatible board on the market today – the Freetronics EtherMega. This board combines the functionality of an Arduino Mega2560, a microSD card shield, and an Ethernet shield that supports power over Ethernet with optional 802.3af standard. So instead of having these three mashed together at a great expense:

thelot

… you can have this:

Freetronics EtherMega Tronixlabs Australia

Which saves space, time and money. Firstly, the specifications:

  • 100% compatible with the Arduino Mega2560. So you have the ATmega2560 microcontroller, 54 digital I/O pins with 14 PWM-capable, 256KB of flash memory, 8KB of SRAM and 4KB of EEPROM to play with, the Atmel 16u2 micrcontroller taking care of the USB interface;
  • However unlike the original, the EtherMega contains a switchmode power supply that allows operation from a DC power supply of between 7 and 28VDC without overheating;
  • Complete c0mpatibility with the Arduino Ethernet shield, using the Wiznet W5100 controller just like the original;
  • Network status LEDs on both the socket and the PCB;
  • Fixed SPI behaviour on Ethernet chipset;
  • Complete microSD card compatibility with SD library, and chip-select is on digital pin 4 so Ethernet and microSD can work together on the same sketch;
  • optional 802.3af power over Ethernet support at up to 48V using the optional regulator board which mounts on the EtherMega;
  • mini USB connector instead of the larger standard USB socket which can interfere with shields – and a USB cable is included

Furthermore there are a few modifications to make using the EtherMega easier or simpler. The first of these is the onboard prototyping area allowing you to add your own circuitry:

Also notice that the I2C pins have been brought out alongside the 5V and GND pins on the right. The only difference to take note of are the jumpers that are used to select either USB or DC socket power:

However that is a small price to pay compared to the convenience of the wide voltage-handling capability. Finally, unlike the original Arduino Mega2560 the designers have placed the TX/RX indicators at the top-left of the EtherMega so they are still visible when extra shields have been mounted:

The overall design and quality of the EtherMega is top notch, with a thick PCB, rounded corners, descriptive silk-screening, and packaging that can be reused as Mega or other part storage.

If you are looking for an Arduino Mega2560 and could use Ethernet, power-over-Ethernet, a microSD card interface and full, 100% Arduino compatibility you could do a lot worse than getting yourself an EtherMega. If you are interested in learning how to use Arduino and Ethernet – check out our tutorial here. Or to get your Arduino tweeting, visit here.

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in 802.3af, arduino, ethermega, ethernet, freetronics, review, shield, tronixlabsComments (0)

May 2011 Competition Results

Competition over!

Posted in competitionComments (0)

May 2011 Competition

Competition over!

Posted in competitionComments (0)

Moving Forward with Arduino – Chapter 19 – GPS part II

Learn more about Arduino and GPS in chapter nineteen of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 24/01/2013

In this instalment we will continue to examine the use of our GPS system and Arduino through creating two more applications. Some of them may seem simple, but we will build on them later on to make more complex things. To review previous information, the first GPS instalment was chapter seventeen.

“Household official time”

At home we often have various discussions about what the actual time is. At first it sounds silly, but when you have clocks on the microwave, kitchen wall, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half has all her clocks ten minutes fast. Insanity may prevail! So let’s make a nice big LED-display reference clock – something that wouldn’t look out of place in a radio or television studio:

Then when people start arguing over the time, you can point at your new clock and smile. From a hardware perspective, we will combine three or four things: our Arduino board, our GPS system, and the MAX7219 display driver. We will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • Maxim MAX7219 display driver IC
  • two four-digit, seven-segment LED displays (common cathode). You could also rig up four separate digits with some patience;
  • one 1 kilo ohm resistor
  • one 10 kilo ohm resistor
  • one single pole, double-throw switch
  • a nice breadboard and some connecting wire
  • a separate 5V power supply – all those LED segments are thirsty, the completed clock uses under 350 milliamps with a brightness setting of 8:

exam19p1currss

Here is the schematic:

exam19p1schematicss

 

Although the sketch (download) may seem quite complex, it is just made up of things we have already examined in the past. The only unfamiliar part could be the MAX7219 display driver IC, which in itself is quite easy to use. There is a full part review and explanation here. It is most likely that everyone will have different LED display units, as the 4-digit modules can be hard to track for some people or too expensive –  so some more explanation is in order.

You will need common-cathode display modules. If you line the digits up from left to right, they will be numbered zero to nine with respect to the MAX7219 – so connect MAX7219 pin 2 to the cathode of your first display, and so on. With regards to the anodes (a~g and dp [decimal point]) – link each anode type together.

For example, if you have eight separate 7-segment display modules, connect each ‘a’ pin together, then to MAX pin 14. And so on. Here is the board layout – a real mess:

exam19p1boardss

And our action video:

An interesting twist you might find of interest is the function:

Which allows you to alter the brightness of the LED display(s). The range is 0 to 18 – in my examples it has been set to 8. You could then make your clock dim the display brightness between (for example) 11pm and 5am – so when you wake up in the middle of the night the display won’t act like a frickin’  laser-beam burning into your eyeballs. Furthermore, dropping the brightness reduces the power consumption.

gps_satellite_nasa_art-iif

 “You went… where?”

Now it is time for what most of you have been waiting for – making a GPS tracking device. Now before you get too excited, it would be proper to make sure you have the permission of someone before you track them. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

Download the Example 19.2 sketch from here.

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

Although the hardware wasn’t that interesting to plug together, what can be done with it and the data it captures is quite fascinating. To generate some sample data, I have taken the hardware for a walk to the post office. We will now open the file produced by our hardware and examine it further. If you would like to follow along, you can download the file from here.

The file is a typical, comma-delimited text file. You can examine it further using common spreadsheet software such as LibreOffice Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

import

You can see that the data delimits quite easily. Just click “OK” and the file will be presented to you.

gpslogcsv

So as you can see, there is time, date (remember – GMT), latitude and longitude, my speed (with a couple of anomalies) and random sensor data results (see the sketch). We can have this data converted into a much more useful form by using the GPS Visualiser website. Save the data as a .csv file. Then visit http://www.gpsvisualizer.com/, and use the Get Started Now box in the middle of the web page. Select Google Maps as the output format, then upload the file. This will result in the following:

gpswalk

Just like normal Google Maps there are many display options you can choose from, and the GPS Visualiser web site has many tutorials about making the most of their service. If you look in detail you will see some “jittering” along parts of the track that are not representative of my movements (though I had just taken my morning coffee). This could be the result of the receiver module moving about in all three axes during my walk, one would imagine it would be a lot smoother inside a motor vehicle. So have fun with that.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, COM-09622, DEV-09802, GPS, learning electronics, lesson, microcontrollers, RTL-10709, tronixstuff, tutorialComments (2)

Tutorial – Arduino and EM406A GPS

Learn how to use GPS and Arduino in chapter seventeen of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here. If you have a MediaTek 3329 GPS module, please visit the separate tutorial.

Updated 14/01/2014

In this instalment we will introduce and examine the use of the Global Positioning System receivers with Arduino systems. What is the GPS? In very simple terms, a fleet of satellites orbit the earth, transmitting signals from space. Your GPS receiver uses signals from these satellites to triangulate position, altitude, compass headings, etc.; and also receives a time and date signal from these satellites. The most popular GPS belongs to the USA, and was originally for military use – however it is now available for users in the free world.

Interestingly, the US can switch off or reduce accuracy of their GPS in various regions if necessary, however many people tell me this is not an issue unless you’re in a combat zone against the US forces. For more information, have a look at Wikipedia or the USAF Space Command GPS Ops Centre site. As expected,  other countries have their own GPS as well – such as Russia, China, and the EU is working on one as well.

So – how can us mere mortals take advantage of a multi-billion dollar space navigation system just with our simple Arduino? Easy – with an inexpensive GPS receiver and shield. When searching for some hardware to use, I took the easy way out and ordered this retail GPS packwhich includes the required Arduino shield and header sockets, short connecting cable and an EM-406A 20-channel GPS receiver with in-built antenna:

packcontentsss

For reference now and in the future, here is the data book for the GPS receiver: EM-406 manual.pdf. All you will need is an Arduino Uno or 100% compatible board, and the usual odds and ends. When it comes time to solder up your shield, if possible try and sit it into another shield or board – this keeps the pins in line and saves a lot of trouble later on:

howtosolderss

And we’re done:

readyfor-workss

Please notice in the photo above the cable is a lot longer between the shield and the GPS receiver. This was an extra cable, which makes things a lot more convenient, and it never hurts to have a spare. Finally, on the shield please take note of the following  two switches – the shield/GPS power switch:

shieldonoffss

and the UART/DLINE switch:

uartdliness

For now, leave this set to UART while a sketch is running. When uploading a sketch to the board, this needs to be on DLINE. Always turn off your GPS shield board before changing  this switch to avoid damage.

Is anyone out there?

Now, let’s get some of that juicy GPS data from outer space. You will need:

Once you have your hardware assembled, upload the following sketch:

Now for desk jockeys such as myself, there is a catch – as a GPS receives signals from satellites the receiver will need to be in line of sight with the open sky. If you have your desk next to a window, or a portable computer you’re in luck.  Look at the LED on your GPS receiver – if it is blinking, it has a lock (this is what you want); on – it is searching for satellites; off – it is off (!). The first time you power up your receiver, it may take a  minute or so to lock onto the available satellites, this period of time is the cold start time.

This will be in ideal conditions – i.e. with a clear line of sight from the unit to the sky (clouds excepted!). Once this has been done, the next time you power it up, the searching time is reduced somewhat as our receiver stores some energy in a supercap (very high-value capacitor) to remember the satellite data, which it will use the next time to reduce the search time (as it already has a “fair idea” where the satellites are). Now open the serial monitor box, sit back and wait a moment or two, and you should be presented with something very similar to this:

example17p1data

What a mess. What on earth does all that mean? For one thing the hardware is working correctly. Excellent! Now how do we decode these space-signals… They are called NMEA codes. Let’s break down one and see what it means. For example, the line: $GPRMC,165307.000,A,2728.9620,S,15259.5159,E,0.20,48.84,140910,,*27 Each field represents:

  • $GPRMC tells us the following data is essential point-velocity-time data;
  • 165307.000 is the universal time constant (Greenwich Mean Time) – 16:53:07 (hours, minutes, seconds). So you now have a clock as well.
  • A is status – A for active and data is valid, V for void and data is not valid.
  • 2728.9620 is degrees latitude position data = 27 degrees, 28.962′
  • S for south (south is negative, north is positive)
  • 15259.5159 is degrees longitude position data = 152 degrees, 59.5159′
  • E for east (east is positive, west is negative)
  • 0.20 is my speed in knots over ground. This shows the inaccuracy  that can be caused by not having a clear view of the sky
  • 48.84 – course over ground (0 is north, 180 is south, 270 is west, 90 is east)
  • 140910 is the date – 14th September, 2010
  • the next is magnetic variation for which we don’t have a value
  • checksum number

Thankfully the data is separated by commas. This will be useful if you are logging the data to a text file using a microSD shield, you will then be able to use the data in a spreadsheet very easily. Later on we will work with data from other codes, but if you can’t wait, here is the NMEA Reference Manual that explains them all. In the meanwhile, how can we convert the location data (longitude and latitude) received into a position on a map?

  • Visit this website
  • In the box that says “paste your data here”, enter (for example, using my data above)

For example:

visualiser

Then click “Draw the Map”, and you will be presented with a Google map in a new window that you can zoom around in, change views and so on. Interestingly enough the coordinates returned in the test above were accurate down to around three meters. Later on that website will be of great use, as you can import text files of coordinates, and it will plot them out for you. If you use this mapping site a lot, please consider making a donation to help them out. Now as always, there is an easier way. The purpose of the previous demonstrations were to see the raw data that comes from a receiver, and understand how to work with it.

gps_satellite_nasa_art-iif

Moving on… now we can receive GPS signals – and in the past we have used LCD modules – so we can make our own variations of portable (!) GPS modules and other devices. At this point you will need to install another Arduino library – TinyGPSSo download and install that before moving forward.

“My First GPS”

Using various pieces of hardware from the past, we will build a simple, portable unit to display our data.

You will need:

  • Arduino Uno or compatible board
  • a suitable GPS setup – for example the GPS shield bundle
  • An LCD with HD44780 interface that has the ability to connect to your Arduino system. The size is up to you, we’re using a 20 x 4 character unit. If you have dropped in or are a bit rusty on LCDs, please read chapter twenty-four;
  • An external power supply for your setup (if you want to walk up and down the street at midnight like I did) – for example, a 9V battery snap soldered to a DC plug is a quick and dirty solution!

Luckily I have made an LCD shield in the past which works nicely, and doesn’t use digital pins D0 and D1 – these are used by the GPS shield to get the data back to the Arduino. Therefore the whole lot just plugged in together as shields do. Here is the sketch for your consideration:

Before uploading the sketch, turn off the GPS shield, set the DLINE/UART switch on the GPS shield to DLINE, upload the sketch, then set it back again, then back on with the GPS shield. So here it is all thrown together in my lunch box:

exam17p2boxss

And a close-up view of the LCD. There was not room for the course data, but you can modify the sketch accordingly. The data will be a little off due to the photo being taken indoors:

exam17p2lcdss

Now for some outdoor fun. In the video clip below, we take a ride on the bus and see our GPS in action. I had to take an old bus that wasn’t full of security cameras, so the ride is bumpy:

sl250ss

As we have a lot of electronics in this setup, it would be interesting to know the current draw – to help plan for an appropriate power supply. The trusty meter gives us:

exam17p2currentss

Wow – a maximum of 122 milliamps even with that LCD backlight blazing away. So when we make some GPS logging devices without such a monstrous LCD, we should be able to get the current draw down a lot more. The purpose of this example was to show how you can manipulate the data from the GPS receiver.

“Household official time”

At home we often have various discussions about what the actual time is. At first it sounds silly, but when you have clocks on the microwave, kitchen wall, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half has all her clocks ten minutes fast. Insanity may prevail! So let’s make a nice big LED-display reference clock – something that wouldn’t look out of place in a radio or television studio:

Then when people start arguing over the time, you can point at your new clock and smile. From a hardware perspective, we will combine three or four things: our Arduino board, our GPS system, and the MAX7219 display driver. We will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • Maxim MAX7219 display driver IC
  • two four-digit, seven-segment LED displays (common cathode). You could also rig up four separate digits with some patience;
  • one 1 kilo ohm resistor
  • one 10 kilo ohm resistor
  • one single pole, double-throw switch
  • a nice breadboard and some connecting wire
  • a separate 5V power supply – all those LED segments are thirsty, the completed clock uses under 350 milliamps with a brightness setting of 8:

 

Here is the schematic:

And the sketch:

Although the sketch may seem quite complex, it is just made up of things we have already examined in the past. The only unfamiliar part could be the MAX7219 display driver IC, which in itself is quite easy to use. There is a full part review and explanation here. It is most likely that everyone will have different LED display units, as the 4-digit modules can be hard to track for some people or too expensive –  so some more explanation is in order.

You will need common-cathode display modules. If you line the digits up from left to right, they will be numbered zero to nine with respect to the MAX7219 – so connect MAX7219 pin 2 to the cathode of your first display, and so on. With regards to the anodes (a~g and dp [decimal point]) – link each anode type together.

For example, if you have eight separate 7-segment display modules, connect each ‘a’ pin together, then to MAX pin 14. And so on. Here is the board layout – a real mess:

And our action video:

An interesting twist you might find of interest is the function:


Which allows you to alter the brightness of the LED display(s). The range is 0 to 18 – in my examples it has been set to 8. You could then make your clock dim the display brightness between (for example) 11pm and 5am – so when you wake up in the middle of the night the display won’t act like a frickin’  laser-beam burning into your eyeballs. Furthermore, dropping the brightness reduces the power consumption.

”You went… where?”

Now it is time for what most of you have been waiting for – making a GPS tracking device. Now before you get too excited, it would be proper to make sure you have the permission of someone before you track them. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

And here is the sketch:

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

Although the hardware wasn’t that interesting to plug together, what can be done with it and the data it captures is quite fascinating. To generate some sample data, I have taken the hardware for a walk to the post office. We will now open the file produced by our hardware and examine it further. If you would like to follow along, you can download the file from here.

The file is a typical, comma-delimited text file. You can examine it further using common spreadsheet software such as LibreOffice Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

You can see that the data delimits quite easily. Just click “OK” and the file will be presented to you.

So as you can see, there is time, date (remember – GMT), latitude and longitude, my speed (with a couple of anomalies) and random sensor data results (see the sketch). We can have this data converted into a much more useful form by using the GPS Visualiser website. Save the data as a .csv file. Then visit http://www.gpsvisualizer.com/, and use the Get Started Now box in the middle of the web page. SelectGoogle Maps as the output format, then upload the file. This will result in the following:

Just like normal Google Maps there are many display options you can choose from, and the GPS Visualiser web site has many tutorials about making the most of their service. If you look in detail you will see some “jittering” along parts of the track that are not representative of my movements (though I had just taken my morning coffee). This could be the result of the receiver module moving about in all three axes during my walk, one would imagine it would be a lot smoother inside a motor vehicle. So have fun with that.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, beginnner, education, GPS, GPS-09123, learning electronics, lesson, microcontrollers, RTL-10709, tutorialComments (13)

Moving Forward with Arduino – Chapter 15 – RFID Introduction

Learn how to use RFID readers with your Arduino. In this instalment we use an RDM630 or RDM6300 RFID reader. If you have an Innovations ID-12 or ID-20 RFID reader, we have a different tutorial.

This is part of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 21/02/2013

RFID – radio frequency identification. Some of us have already used these things, and they have become part of everyday life. For example, with electronic vehicle tolling, door access control, public transport fare systems and so on. It sounds complex – but isn’t.

To explain RFID for the layperson, we can use a key and lock analogy. Instead of the key having a unique pattern, RFID keys hold a series of unique numbers which are read by the lock. It is up to our software (sketch) to determine what happens when the number is read by the lock.  The key is the tag, card or other small device we carry around or have in our vehicles. We will be using a passive key, which is an integrated circuit and a small aerial. This uses power from a magnetic field associated with the lock. Here are some key or tag examples:

In this tutorial we’ll be using 125 kHz tags – for example. To continue with the analogy our lock is a small circuit board and a loop aerial. This has the capability to read the data on the IC of our key, and some locks can even write data to keys. Here is our reader (lock) example:

readerss

As you can see from the 5mm graph paper, the circuitry is quite small, and the loop is somewhat fragile. For installation and use, it would be wise to mount the loop aerial inside something strong and protective.

Our use for the RFID equipment is to have our sketch make a decision based on the unique tag number. For example, it could be used as a switch to turn on and off something, perhaps an alarm system or a computer. It could control an electric door strike (lock), or activate a series of lights to one’s personal preference. The possibilities are only limited by your imagination. I hope that with your existing knowledge you can implement this RFID equipment into your next prototype or product.

First of all, let’s do a basic test – what happens when we read a tag?  To do this we need to connect our reader to the Arduino or compatible board, and see what comes out when we read a card. The connections are quite simple:

 

exam15p1ss

Note that all the GND pins are connected together. Now upload the following sketch:

You may need to remove the wire from the RFID reader to Arduino before uploading the sketch, then replacing it after the upload. From the reader data sheet.pdf (our version is the TTL model), the reader sends out serial data from the TX pin at 9600 bps. We will read that data using the serial input (digital pin zero on the board) and display it on the serial monitor box to see what it looks like. The LED activates (rather dimly) when reading is taking place. Here is the sketch to use.

Once the sketch has been uploaded, open your serial monitor box, and wave a tag over the antenna. You should have a reading similar to the video below, however your tag number will be different.

Excellent – simple numbers that we can work with. For example, one of my tags returns: 2,51,69,48,48,49,65,51,53,70,50,69,51,3 and another returns 2,51,67,48,48,67,69,49,48,68,53,51,55,3. Note that both start with 2 and end with 3, so the unique tag details are the 12 integers between the 2 and 3. One could read the data as characters or hexadecimal numbers by altering the data type in the sketch from int to byte, but for simplicity I am working in integers. Now all we need to do is fashion sketches to recognise the tag number(s) we want to use, and perform an action based on which tag number is used (or do something when a tag is read, but not the tag you want).

In the following example, (download) the sketch reads the 14 integers returned from the card reader when a tag is swiped. These integers are placed into a fourteen element array, which is then compared against arrays holding the numbers my “allowed” tags. If an allowed tag is read, the green LED comes on, if a disallowed tag is read, the red LED comes on. Of course you could have the digital outputs controlling other things using a switching transistor or a relay. Below is the schematic:

example15p2schematicss

And a short video in action:

Excellent – now we are getting close to something useful. The example above could make a simple door control, or an over-engineered cookie jar.

Now for some more practical uses of RFID and Arduino. In the past we have worked with real time in many chapters, and also have stored data using a microSD card shield

We will build on our previous example by adding time and date logging for all accesses to the system, successful or not. This could be used again for door access, payroll calculations as a modern-day punch-clock, or even a simple logging device to see what time the children arrive home when you aren’t around to check. So we will need a microSD shield, and some sort of DS1307 breakout board or shield.

When using more than one shield together, be mindful of the pins you will need to use. For example, my DS1307 shield uses analogue 4 and 5 (for I2C interface), and the microSD shield uses digital 10 to 13.

The sketch for this example is quite simple – the good thing about programming for Arduino is that just like the hardware shields, sketch procedures and functions can be very modular and reused quite easily. If you are unsure about the microSD shield, please read my instructional review. Most of the code can be copied from that microSD shield article’s demonstration sketch, which I have done for this example. The sketch writes the time, date, tag number, and read status (accepted/rejected).

However there is one caveat when using the microSD shield – the file needs to be closed before the card can be removed for examination. In practical use, our RFID system would be usually on most of the time, so a method will needed to activate the card write function. This has been implemented with a function bossMode() that is called when a certain tag is read – one may call this the supervisor’s card. Once this particular tag is read, the file is annotated as closed, reading stops, and the LEDs blink alternately when it is safe to remove the card. A simple reset after the card is reinserted will start the reading again.

Here is the sketch. The schematic is the same as Example 15.2, with a few simple additions – the use of the microSD card shield, and the DS1307 real time clock shield. If you are using a DS1307 breakout board wired in separately, please use the following schematic as a guide:

ds1307shield2

Now here is a short video clip, with the addition of the ‘boss mode’ shutdown sequence:

And finally, here is an example of the text file that was produced from a recent test run:

example15p3datalog

As you can see, it is easy to reproduce expensive time-keeping systems with our own equipment and some time. We have some RFID projects in … the project section.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in 125 kHz, arduino, ELB149C5M, lesson, microcontrollers, RDM630, RDM6300, rfid, RFR101A1M, RFR103B2B, sensor, tronixstuff, tutorialComments (8)

Part review – microSD card Arduino shield

Hello readers

Today we are going to look at a micro SD card Arduino shield. The reason to use such a thing is to have a storage dump for any data that you generate with your Arduino project that can accept a very large amount of data – up to several gigabytes if you have a large enough micro SD card. With the appropriate sketch it is also possible to read from the card, navigate file directories and so on, but to keep it simple I am just going to examine the most popular aspect – writing our data to the card. However if enough people ask me I will spend the time to figure out the rest.

Initially I imagined this project would be quite difficult, but after some research it was fine. You’re lucky to not have to do the work completed by myself 🙂

Anyhow, moving on. The shield is shipped in the usual minimalist packaging, a plastic bag and the shield:

shield

You will need to supply your own header sockets or pins and fit them  yourself. Then solder away. Before you know it, your shield is complete:

soldered

The red board colour is a nice contrast with the blue of my Eleven. Now of course you will need a micro SD card to write your data to. Contrary to popular belief you can use SDHC micro SD cards that are larger than two gigabytes in size. First of all, you will need to format your micro SD card. Check the instructions or help system of your computer’s operating system to determine how to do this. However ensure that the format type is either FAT32 or FAT 16, not MacOS or ext3 or NTFS, etc. Next we need to prepare the Arduino IDE to work with the shield. There is a library of functions that needs to be installed for the project to work. Bill Greman has written an excellent library to use, download it from here.

On the software side of things, please note that the shield requires exclusive use of digital pins 10, 11, 12 and 13 for the SPI interface to the card reader. The next thing to do is test our new shield. Plug the shield into your Arduino Duemilanove or compatible board, then the micro SD card into the slot. It will need a small amount of pressure, as it “clicks” in. Also note that in order to remove the card, you push it and it pops out a little. Don’t try to just pull it out with your thumbnail. It is also wise to only insert and remove the card when the power is off.

Assuming you have installed your library correctly, fire up the Arduino IDE and select File menu > examples > SDFat > SDFatinfo. Plug in your shield, upload the sketch, then hit the serial monitor button. Enter a character and press enter – you should be presented with something like:

sdfatinfosketchscreendump

This display shows various data about the card, the formatting type and so on. If it did not work, check your soldering on the shield, re-format the card with FAT16 or FAT32, reseat the shield into the Arduino, reconnect to the PC and try again.

Next it is time to write something to the card, to get a feel for how things work. Run the “SDFatwrite” example, open the serial monitor box, enter a character and press enter. Now open the resulting text file found on your micro SD on your computer. You should have something that looks like:

sdafatwrite

There really is a lot of code in the demonstration sketch, but to make things easier to adapt, have a look at line 90 to 94 of the sketch.

The writeString() function writes text to the file, just like Serial.write() would to the screen. The writeNumber() function writes integers, or unsigned integers to the file. And the writeCRLF() function starts a new line in the file. You can basically copy and paste the code into your own sketch and use these functions, as long as your variable types are suitable for the functions.

In saying that, I have made a demonstration sketch to prove this. Using the real time clock shield from a previous article, an Analog Devices TMP36, and a 560 ohm resistor/LED on digital pin 2, we can make a temperature logger with time and date. This involves a nice stack of Arduino goodness:

triplestack

and a solderless breadboard with the temperature sensor and the LED setup. If you had a really small breadboard, you could plonk it into the micro SD shield and save space. Alas, mine did not fit.

demosetup

But it worked. Now for the sketch – you can download it here: demonstationsketch.pdf. If you examine the sketch I have filled it with comments and points of interest. If you are unsure of how the real time clock code works, please visit here. Fore more information about the temperature sensor, please visit here. There was no need to compute Fahnrenheit in the sketch, as this can be done later on in a spreadsheet, saving you sketch memory and storage space.

The purpose of the LED is to let you know when the sketch is about to start, and when it has finished. Once the blinking starts at the end of the sketch, you can power off and remove the micro SD card as the program has written and closed the file. If you do this before the sketch has finished, you may corrupt the file and lose your data. Here is an example of the file from the demonstration sketch:

tempdemoscreenshot

Notice how there are distinct columns between the data. This is important as later you may want to import the text file into a spreadsheet to analyse your data. For example, if you use the Insert > Sheet from file… command in the Openoffice.org spreadsheet, you can select which columns of data to import, like this:

ooossimport

Which will leave you with nicely delimited data that you can twist around to your heart’s content:

ssresult

In this spreadsheet I have calculated the minimum, maximum and average temperature – and in Fahrenheit as well. By just capturing the raw data using the micro SD shield you can offload a lot of processing work from the Arduino and onto your personal computer  – a much more efficient solution. The spreadsheet has been placed in the files section of our Google Group.

So there you have it. You now have the tool and an understanding of how to capture data from the real world, and bring it home to analyse and make decisions from it. The possibilities are almost limitless, using a wide range of sensors, user inputs, even GPS modules, you can get a better understanding of the world around you. High resolution photos are available on flickr.

So have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, DEV-09802, lesson, part review, PRT-10007, sd card, tutorialComments (18)


Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: