Using Multiple Geiger Counters at Once

Hello,

I am using DFRobot's Gravity Geiger counter for a project. I'd like to use two of them at the same time. One will be used as a control to see what regular radiation levels are, and the other will be covered with a material to block radiation. I'd like to compare readings from both to see how well the material is working at blocking radiation.

I feel like it is probably a simple solution to read from both sensors at the same time, but I'm not sure what I need to change in the sketch to make this work. Also, I imagine that I'd have to plug each sensor into a separate pin on the Arduino. The default pin to use is D3. Based on the following code from DFRobot, what should I edit to make two Geiger sensors work at the same time.

#include <DFRobot_Geiger.h>
#if defined ESP32
#define detect_pin D3
#else
#define detect_pin 3
#endif
/*!
   @brief Constructor
   @param pin   External interrupt pin
*/
DFRobot_Geiger  geiger(detect_pin);

void setup()
{
  Serial.begin(115200);
  //Start counting, enable external interrupt
  geiger.start();
}

void loop() {
  //Start counting, enable external interrupt
  //geiger.start();
  delay(3000);
  //Pause the count, turn off the external interrupt trigger, the CPM and radiation intensity values remain in the state before the pause
  //geiger.pause();
  //Get the current CPM, if it has been paused, the CPM is the last value before the pause
  //Predict CPM by falling edge pulse within 3 seconds, the error is ±3CPM
  Serial.println(geiger.getCPM());
  //Get the current nSv/h, if it has been paused, nSv/h is the last value before the pause
  Serial.println(geiger.getnSvh());
  //Get the current μSv/h, if it has been paused, the μSv/h is the last value before the pause
  Serial.println(geiger.getuSvh());
}

You will have to edit the library as well as the code.

The library uses the external interrupts and at present, supports only one interrupt. On an Arduino Uno, only two external interrupts of that type are supported, on pins 2 and 3.

You could also use the external interrupt on pin 2, or modify the code to use the pin change interrupt on just about any pin you like.
Pin 2 is by far the simplest, though.
(Not sure why they chose pin 3 as the default)

I'm using a Nano Every. A commenter on Reddit suggested that all I needed to do was declare a second counter on another pin. It seems to be working, but correct me if this method is incorrect. Here is the edited code I made:

/*!
  @file geiger.ino
  @brief    Detect CPM radiation intensity, the readings may have a large deviation at first, and the data tends to be stable after 3 times
  @copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  @licence     The MIT License (MIT)
  @author [fengli](li.feng@dfrobot.com)
  @version  V1.0
  @date  2021-9-17
  @get from https://www.dfrobot.com
  @https://github.com/DFRobot/DFRobot_Geiger
*/

#include <DFRobot_Geiger.h>
#if defined ESP32
#define detect_pin D3
#define detect_pin_two D5
#else
#define detect_pin 3
#define detect_pin_two 5
#endif
/*!
   @brief Constructor
   @param pin   External interrupt pin
*/
DFRobot_Geiger  geiger(detect_pin);
DFRobot_Geiger  geiger_two(detect_pin_two);

void setup()
{
  Serial.begin(115200);
  //Start counting, enable external interrupt
  geiger.start();
  geiger_two.start();
}

void loop() {
  //Start counting, enable external interrupt
  //geiger.start();
  delay(3000);
  //Pause the count, turn off the external interrupt trigger, the CPM and radiation intensity values remain in the state before the pause
  //geiger.pause();
  //Get the current CPM, if it has been paused, the CPM is the last value before the pause
  //Predict CPM by falling edge pulse within 3 seconds, the error is ±3CPM
  Serial.println(geiger.getCPM());
  Serial.println(geiger_two.getCPM());
  //Get the current nSv/h, if it has been paused, nSv/h is the last value before the pause
  Serial.println(geiger.getnSvh());
  Serial.println(geiger_two.getnSvh());
  //Get the current μSv/h, if it has been paused, the μSv/h is the last value before the pause
  Serial.println(geiger.getuSvh());
  Serial.println(geiger_two.getuSvh());
}

Please mark the thread solved.

Isn't there a scope issue with the interrupt service routine?

I have no idea what that means. What is a scope issue? I am getting readings, I'm not sure that they are correct though.

Google "C/C++ scope". It is a fundamental feature of the programming language and is very important to understand.

I am getting readings, I'm not sure that they are correct though.

I'm not surprised. The library code has some rather odd features. Test it using a pushbutton on the inputs to make sure that it responds as expected.

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