Geiger counter + temp.sensors



  • Greetings from Switzerland!

    Let me share with you a small project I did to monitor the radio-activity and temperature (2 sensors).

    IMG_6808.jpg

    The device is installed in my garage and one or the temp. probe is installed in the laundry.

    It is built around the following Geiger counter module : https://www.ebay.com/itm/Geiger-counter-dosimeter-kit-assembled-w-SBT11A-tube-iR-USB-Arduino-compat/162946293010

    Since I have a RFM69 based network, I got the 3.3V module version.

    The tube is an SBT-11a detecting the alpha, beta & gamma radiations and the temp sensors are 2 x 1 wire Dallas DS18B20.

    Here the output (Domoticz)

    Capture d’écran 2020-05-07 à 10.06.21.jpg

    The script is really simple. I used the temp sample https://www.mysensors.org/build/temp
    and modified it to push the data to the controller when the geiger counter sends the value to the serial port. To get it working, I had to place the geiger counter in RADLOGGER mode using the IR remote control. Then by adjusting the LOG PERIOD parameters I have defined the frequency at which the counter is pushing the data to the serial port, thus triggering the transmission to the controller (every 5 mn here).

    //------------------
    
    #define CHILD_ID_RADIATION 90   // Id of the Geiger child
    #include <SPI.h>
    #include <MySensors.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
    #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
    #define MAX_ATTACHED_DS18B20 2
    
     //unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors = 0;
    bool receivedConfig = false;
    bool metric = true;
    
      // Initialize temperature message and geiger
      MyMessage msg(0, V_TEMP);
      MyMessage msg_rad(CHILD_ID_RADIATION, V_LEVEL);
    void before()
    {
      // Startup up the OneWire library
      sensors.begin();
    }
    
    void setup()
    {
      // requestTemperatures() will not block current thread
      sensors.setWaitForConversion(false);
    
      // initialize the serial communications (must be 9600 for the geiger counter):
      Serial.begin(9600);
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Geiger & Temperature Sensors", "2.0");
    
      // Fetch the number of attached temperature sensors
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
        present(i, S_TEMP);
      }
      present(CHILD_ID_RADIATION, S_DUST);
    }
    
    void loop()
    {
    
     if (Serial.available()) {
        delay(200);
        String str_cpm = Serial.readStringUntil("\n"); //update str_cpm with serial entry
        send(msg_rad.set(str_cpm.toInt()));    // Send to gateway wiLL BE TRIGGERED WHEN VALUE IS RECEIVED FROM THE COUNTER.ADJUST THE TIMEFRAME FROM THE COUNTER WITH IR REMOTE CONTROL.
    
      
      // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
    
      // query conversion time and sleep until conversion completed
      int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      wait(conversionTime);
    
      // Read temperatures and send them to controller
      for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
    
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
    
        // Only send data if temperature has changed and no error
    #if COMPARE_TEMP == 1
        if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
    #else
        if (temperature != -127.00 && temperature != 85.00) {
    #endif
    
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature, 1));
          // Save new temperatures for next compare
          lastTemperature[i] = temperature;
        }
      }
      //sleep(SLEEP_TIME);
    
       }
    }
    
    

    To code is really not optimised but it works at least :)) Feel free to optimise / share 🙂

    There is another possible approach to work with this counter. It is possible to generate an impulse on an output pin at every tube discharge. This is then possible to read these impulses from the arduino then convert them to the right value (CPM, µSv/h...).

    Stay safe !

    All the best !

    Jef


Log in to reply
 

Suggested Topics

  • 81
  • 1845
  • 4
  • 7
  • 3
  • 6
  • 2
  • 59

183
Online

9.7k
Users

10.3k
Topics

106.4k
Posts