I am using an Uno with the SD shield as a stand alone data collection system.
The GM-10 is the actual Geiger counter or sensor, its readings compare with Background, a Cs-137 calibration source and Ra-226.
Its spending the night in my basement sniffing for Radon gas.
Here is the sketch.
// Geiger Counter Lib example
/* Adapted by Tracy Albert from programing for a frequecy counter by,
Martin Nawrath KHM LAB3
Kunsthochschule f¸r Medien Kˆln
Academy of Media Arts
http://www.khm.de
http://interface.khm.de/index.php/labor/experimente/
*/
#include <FreqCounter.h>
#include <SdFat.h>
#include <SdFatUtil.h>
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
void setup (void);
unsigned long frq;
int cnt;
int pinLed=13
// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))
void error_P(const char *str)
{
PgmPrint("error: ");
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
while(1);
}
void writeCRLF(SdFile &f)
{
f.write((uint8_t *)"\r\n", 2);
}
/*
* Write an unsigned number to a file
*/
void writeNumber(SdFile &f, uint32_t n)
{
uint8_t buf[10];
uint8_t i = 0;do {
i++;
buf[sizeof(buf) - i] = n%10 + '0';
n /= 10;
} while (n);
f.write(&buf[sizeof(buf) - i], i);
}
/*
* Write a string to a file
*/
void writeString(SdFile &f, char *str)
{
uint8_t n;
for (n = 0; str[n]; n++);
f.write((uint8_t *)str, n);
}
void setup(void){
pinMode(pinLed, OUTPUT);
Serial.begin(9600); // connect to the serial port
Serial.println("Geiger Counter");
// initialize the SD card
if (!card.init()) error("card.init");
// initialize a FAT volume
if (!volume.init(card)) error("volume.init");
// open the root directory
if (!root.openRoot(volume)) error("openRoot");
}
void loop(){
// create a new file
char name[] = "WRITE00.TXT";
// wait if any serial is going on
FreqCounter::f_comp=10; // Cal Value / Calibrate with professional Freq Counter
FreqCounter::start(60000); // 1 minuit Gate Time
while (FreqCounter::f_ready == 0)
frq=FreqCounter::f_freq;
Serial.print(cnt++);
Serial.print(" cpm: ");
Serial.println(frq);
delay(100);
digitalWrite(pinLed,!digitalRead(pinLed)); // blink Led
//-----------------------------------------------------
for (uint8_t i = 0; i< 1000; cnt++){
name[5] = i/10 + '0';
name[6] = i%10 + '0';
if (file.open(root, name, O_CREAT | O_APPEND | O_WRITE)) break;
if (!file.isOpen()) error ("file.create");}
// write 100 line to file
for (uint8_t i = 0; i < 100; i++){
writeNumber(file, cnt);
writeString(file, " cpm ");
writeNumber(file, frq);
writeCRLF(file);
// close file and force write of all data to the SD
card
file.close();}
}