Arduino shield pins and ICSP header mismatched height

I have noticed that arduino official shields, such as wifi and wireless shields, have mismatched ISCP header height with male pins. Both point down, but the male pins are 2mm or 0.1″ longer.

My first picture below shows me holding a PCB over a MEGA, showing that the female headers and at the same height as the ICSP male header on arduino.

Arduino header

My second picture below shows three shields, from left to right, official wifi shield, official wireless shield, and a third-party Ethernet shield. As you can see, both official shields have male pins about  2mm or maybe 0.1″ longer than the female ICSP header so the female header is not touch the table top. On the other hand, the third-party shield have same height.

Shield header and pins

This may create loose connection issues when you press the shield against another shield with pass-thru ICSP headers, which are thin pins, not square pins found on arduino. The additional 0.1″ travel on the female header makes the connection so much more trust-worthy. I have some issues with some shields I designed and built with wifi shields. I don’t know if it was caused by this “feature”. From what I understand, all pins should make perfect contact, not some doing it while others have ways to go.
What is your opinion?

To remedy this, I made a tool, by pulling all the pins in a row of female header, indicated in the third picture. Then I slip it over the male headers, and I just have to trip the protruding portion of the male header in half, effectively removing about 2mm length.trimming tool-1


trimming tool-2

After trimming, there is no more concerns with the connections. I am yet to see the problematic units with the wifi shield shipped back to me so I can apply this modification to it. BTW, there is no clearance issue trimming the male pins, thus dropping the wifi shield 2mm lower towards what’s below it. There is nothing on an arduino or my shield that will come in contact with the bottom of the wifi board. So the 2mm lost of clearance really doesn’t hurt anything.

Format SD card for Arduino projects

Recently I had a project that needed to tally the free and used space on the SD card and display that on an LCD. I have been using the SDFAT library instead of the SD library. The SdFat library is the basis of the SD library, so it has more functionality than SD and works faster in many cases. In the SdFat library, there are functions that count free blocks on the SD card, which is how free space is figured out: free blocks * block size (512 bytes)

Here is the function:

unsigned int sd_free_space_MB(SdFat* sdfp)
uint32_t freeMB = sdfp->vol()->freeClusterCount();
freeMB *= sdfp->vol()->blocksPerCluster();
return freeMB;

The freeClusterCount counts number of clusters, and then multiply that with number of blocks per cluster and then divide by 2048 to factor out the 512 byte per block and 1,048,576 bytes per MB, i.e. blocks * 512 / 1,048,576 = blocks / 2,048.

This code ran so slow that it took 10 seconds on a 2GB SD card. I was appalled thinking that is how fast they go. I even wrote a message on the LCD “calculating free space” so the user won’t wonder what’s going on during the 10 second delay. But later I posted my code asking for help on the Arduino forum. fat16lib, the author of the library, helped me greatly. It turned out that my SD card was not formatted optimally. I should have formatted it with the formatter tool that fat16lib pointed out (many many posts ago on the forum):

After formatting, I only experienced a split second delay before Arduino counts all the blocks. I recommend you to format all your SD cards with this tool. Original Arduino posts are below:

Install Arduino on Windows 8

There are several issues that surround installing Arduino and compatible hardware on windows 8 machines. If you find it impossible to install your Arduino on a new win 8 machine, I hope this post helps you.


You will need to disable driver digital signature on your PC in order to install Arduino’s driver, which are in Arduino/drivers folder. In previous versions of windows, you simply choose to install on a red dialog that looks like this:

In windows 8, you don’t even get to this dialog. You need to manually disable driver digital signature in a very complicated way and restart your machine twice to do it.

The following tutorial describes how to disable driver digital signature. Make sure you have a second computer or tablet open the page, or print it on paper, because you will be restarting your PC and won’t have access to this page when you are in start screen.

If your PC asks for your bitlock recovery key, follow the steps below under “Tablets”


Yes, we now have inexpensive win 8.1 tablets such as Dell Venue Pro 8 and Toshiba Encore etc. They cost $250 and occasionally are on sale for $200. But are they up for the Arduino tasks? Additional hurdles of course.

Many windows 8.1 tablets come with a drive with bitlocks. It is to prevent people from stealing your tablet and getting sensitive information from it. With the bitlock in place, your files are safe (#define safe //;)) even if you lose your tablet. On the other hand, to boot to advanced settings, windows needs you to enter the bitlock recovery key at boot time to verify you. It’s a long numerical code and here is a tutorial on how to get it from your tablet. I recommend printing the key on paper.

Once you are through entering the key, follow the same procedure as described in the tutorial to disable driver digital signatures, you are then allowed to install Arduino drivers. Congratulations!


How to use serial port pins as digital pins

If you are using Arduino MEGA 2560, you have 4 hardware serial ports (USART port to be precise). Not everyone needs to use all of them. You can, if you want, use Serial1,2,3 as regular digital pins, or GPIO (general purpose input and output). All you have to do is to call Serial1.end() before you set RX1 and TX1 with pinMode and digitalWrite/read.

What if you are in my situation: I have a few serial port sonic rangers. They have an enable pin that enables ranging if they are held high for over 20us. It also has a free running mode, with the enable pin internally pulled up. I was using the free running mode until some interference between two rangers were discovered. Now with my shield already designed and a few dozens in service, I need a way to retrofit them to work with a screw terminal block. Arduino header and jumper is not the solution when these units are deployed in the field. Fortunately I routed both TX and RX to the board’s edge and I can solder on some 2-pin block. But I still need RX to function so I can’t call Serial1.end().

This would need some register operation. If you are interested in the whole detail, the doc2549 from atmel has everything in chapter 22 (USART). There are example codes on P211. It’s pretty clear that the Transmit only functions when the TXEN1 bit of the UCSR1B register is set. The following is from that chapter:


The USART Transmitter is enabled by setting the Transmit Enable (TXEN) bit in the UCSRnB

Register. When the Transmitter is enabled, the normal port operation of the TxDn pin is overridden

by the USART and given the function as the Transmitter’s serial output. The baud rate,

mode of operation and frame format must be set up once before doing any transmissions. If synchronous

operation is used, the clock on the XCKn pin will be overridden and used as

transmission clock.


So all we need to do to get the GPIO function back is to reset that TXEN1 bit as such: cbi(UCSR1B,TXEN1);

I tested this and it worked. I was able to drive the sonic ranger with the TX1 pin and still receive data on the RX1 pin.