ProMini - Find out Crystal frequency

It so happens that i have a bunch of Pro Minis from EBay.

I ordered the 5V/16MHz type as well as the 3.3V/8MHz type. Now being a typical E-Bay source, the modules arrived with no marking whatsoever and have been mixed up subsequently.

Now I want to know which board is which type ( these have some small crystal / resonator which has no marking on them.)

I happened to locate a simple code in this forum by Nick and that seems to return values around 8000 or 16000 .. is this the only way or there is another simpler method to find out ??

/*
 * This code returns the Crystal Frequency muiltiplied by 1000. 
 * ( By Nick Gammon through Arduino Forum ) 
 */

#include <avr/sleep.h>
#include <avr/wdt.h>

volatile bool wdtFired;

// watchdog interrupt
ISR (WDT_vect)
{
  wdt_disable();                       // disable watchdog
  wdtFired = true;
}                                      // end of WDT_vect

void setup ()
{
  noInterrupts ();                     // timed sequence follows
  MCUSR = 0;                             
  WDTCSR = bit (WDCE) | bit (WDE);     // allow changes, disable reset, and set interrupt mode and an interval
  WDTCSR = bit (WDIE);                 // set WDIE, and 16 ms seconds delay
  wdt_reset();                         // pat the dog
  wdtFired = false;
  interrupts ();

  unsigned long startTime = micros ();
  while (!wdtFired)
  { }                                  // wait for watchdog
  unsigned long endTime = micros ();

  Serial.begin (9600);
  Serial.println ();
  Serial.print (F("Time taken = "));
  Serial.println (endTime - startTime);
}

void loop ()  { }

Define "simpler"?
A simple "Blink" program will operate at "obviously the wrong speed" on boards which mis-match the board setting.
An oscilloscope or frequency counter probing the XOUT pin to the resonator should show it.
If the 8MHz minis are proper, VCC should measure 3.3V, and the 16MHz minis should have 5V, when powered from Vin with ~8V.
You could use a device programmer to read the bootloader and compare it against "known" copies.
You could write a sketch (like optiloader) that loads code (like what you quote) and shows the results without needing the serial console...

Would a simple baud rate test not work?

Just a simple serial print at a fixed baud rate in your sketch. Compile for e.g. 16MHz. Serial monitor set at fixed baud rate.

If you see correct.data in serial monitor, baud rates match and hence your Arduino is at the specified clock, if you don't see correct data, baud rates do not match and hence Arduino has 'wrong' clock.

Obviously observing the behaviour of a freshly loaded blink would even be easier.

Are the 8MHz versions using 3.3V and the 16MHz 5.0V ? If so and they have the blink sketch loaded as default then just measure the voltage of the LED as it flashes.

Thanks to all who responded.

This whole thing became a bit winded as regulators on two boards got fried when fed with 9V at Raw input ... not sure what kind of regulators were used.

So the following seem to be different ways :

  1. Measure Vcc
  2. Measure BuiltIn LED Volt when running blink
  3. Serial print
  4. Blink rate..

Buy from a source who marks it proper !!

Mogaraghu:
So the following seem to be different ways :

  1. Measure Vcc
  2. Measure BuiltIn LED Volt when running blink

Measuring those will not tell you what the crystal frequency is.

srnet:
Measuring those will not tell you what the crystal frequency is.

Good point. Technically.

Practically "maybe" it can help as the ProMini( that I bought ) have a fixed combination of 3.3V/8Mhz or 5V/16MHz.

Of course if the wrong resonator is on the wrong board, then measuring Vcc is pointless.

Can't you just read the case of the crystal?

But yeah, simplest way I think is just uploading blink with 16Mhz setting and see a factor 2 to slow blink on the 8Mhz chips.

Mogaraghu:
Practically "maybe" it can help as the ProMini( that I bought ) have a fixed combination of 3.3V/8Mhz or 5V/16MHz.

Practically "maybe" a plain guess can help.

You may have ordered them in 3.3V/8Mhz or 5V/16MHz types, but I have ordered 3.3V/8Mhz and had both 3.3V/16Mhz and 5V/16MHz delivered instead.