Geiger counter logger

i am trying to create a geiger counter logger so I can check the radiation levels in about a year's time however I want to log the data and at the same time still view my lcd display the thing is I'm almost there but the last bit won't quite work is there somebody out there who can help me the code is given below

// include the library code:
#include <Wire.h> 
#include <SPI.h>
#include <SD.h>  //is de sd kaart
#include <LiquidCrystal_I2C.h>
#define LOG_PERIOD 15000  //Logging period in milliseconds, recommended value 15000-60000.
#define MAX_PERIOD 60000  //Maximum logging period without modifying this sketch
#define PERIOD 60000.0 // (60 sec) one minute measure period
#define SD_CS 10
volatile unsigned long CNT; // variable for counting interrupts from dosimeter
unsigned long counts;     //variable for GM Tube events
unsigned long cpm;        //variable for CPM
unsigned int multiplier;  //variable for calculation CPM in this sketch
unsigned long previousMillis;  //variable for time measurement
unsigned long dispPeriod; // variable for measuring time
unsigned long CPM; // variable for measuring CPM
// initialize the library with the numbers of the interface pins

void meting(File &file);

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() { // setup
Serial.begin(9600);
lcd.init();
lcd.init();  
lcd.backlight();
CNT = 0;
CPM = 0;
dispPeriod = 0;
lcd.setCursor(0,0);
lcd.print(" Geiger Counter ");
delay(2000);
cleanDisplay();
attachInterrupt(0,GetEvent,FALLING); // Event on pin 2


  while (!Serial);

  Serial.print("Initializing SD card...");

  if (!SD.begin(SD_CS)) 
  {
    Serial.println("SD card fail");
  }
  Serial.println("initialization done.");
}
void loop() {
lcd.setCursor(0,0); // print text and CNT on the LCD
lcd.print("CPM:");
lcd.setCursor(0,1);
lcd.print("CNT:");
lcd.setCursor(5,1);
lcd.print(CNT);
if (millis() >=dispPeriod + PERIOD) { // If one minute is over
cleanDisplay(); // Clear LCD
// Do something about accumulated CNT events....
lcd.setCursor(5, 0);
CPM = CNT;
lcd.print(CPM); //Display CPM
CNT = 0;
dispPeriod = millis();
}
}
void GetEvent(){ // Get Event from Device
CNT++;
}
void cleanDisplay (){ // Clear LCD routine
lcd.clear();
lcd.setCursor(0,0);
lcd.setCursor(0,0);
}

file = SD. open("FILEDATA.CSV", FILE_WRITE);
if(file)
{
 file.print("CPM")
}
else{
  Serial.println("file faild")
  while(1);
}

void meting(File &file)
{
  double CPM2 = bme.readCPM();
}

void printDataln(File &file, double data)
{
  char number[12];
  dtostrf (data, 6, 3, number);
  file.println (number);
  file.flush();
  }

Must be a guessing game. What is the last thing that is a problem?
Paul

well the problem is that in the line file = SD. open("FILEDATA.CSV', FILE_WRITE); therepops and error geigerteller_test_1:73:1: error: 'file' does not name a type; did you mean 'Wire'?
file = SD. open("FILEDATA.CSV", FILE_WRITE); and I got no clue what I should adjust to make it work

I see a space between SD. and open. Try removing the space and see if that helps.
Paul

These lines are out of place, and not part of any function. The variable "file" is not declared.

file = SD. open("FILEDATA.CSV", FILE_WRITE);
if (file)
{
  file.print("CPM")
}
else {
  Serial.println("file faild")
  while (1);
}

i removed the space which had no effect
niels

i understand there is something wrong but what can I do to fix it do I have to move lines of code or rewrite some of the code
niels

Both, probably. Those lines do nothing useful, outside of any function.

It appears that you have started a project that will require you to learn C/C++ coding. Start small, and get one thing to work at time. Study examples in the Arduino IDE and that you find on the web. There are countless C/C++ coding tutorials on line!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.