├── Geiger.ino ├── LICENSE └── README.md /Geiger.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Geiger.ino 3 | * 4 | * This code interacts with the Alibaba RadiationD-v1.1 (CAJOE) Geiger counter board 5 | * and reports readings in CPM (Counts Per Minute). 6 | * 7 | * Author: Mark A. Heckler (@MkHeck, mark.heckler@gmail.com) 8 | * 9 | * License: MIT License 10 | * 11 | * Please use freely with attribution. Thank you! 12 | */ 13 | 14 | #include 15 | 16 | #define LOG_PERIOD 5000 //Logging period in milliseconds, recommended value 15000-60000. 17 | #define MAX_PERIOD 60000 //Maximum logging period 18 | 19 | volatile unsigned long counts = 0; // GM Tube events 20 | unsigned long cpm = 0; // CPM 21 | const unsigned int multiplier = MAX_PERIOD / LOG_PERIOD; // Calculates/stores CPM 22 | unsigned long previousMillis; // Time measurement 23 | const int pin = 3; 24 | 25 | void tube_impulse() { // Captures count of events from Geiger counter board 26 | counts++; 27 | } 28 | 29 | void setup() { 30 | Serial.begin(115200); // Start serial monitor 31 | pinMode(pin, INPUT); // Set pin to input for capturing GM Tube events 32 | interrupts(); // Enable interrupts (in case they were previously disabled) 33 | attachInterrupt(digitalPinToInterrupt(pin), tube_impulse, FALLING); // Define external interrupts 34 | } 35 | 36 | void loop() { 37 | unsigned long currentMillis = millis(); 38 | 39 | if(currentMillis - previousMillis > LOG_PERIOD) { 40 | previousMillis = currentMillis; 41 | cpm = counts * multiplier; 42 | Serial.println(cpm); 43 | counts = 0; 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mark Heckler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArduinoGeigerCounter 2 | 3 | ## Description 4 | 5 | Arduino code for use with Alibaba RadiationD-v1.1 (CAJOE) Geiger counter board, basic use case. 6 | 7 | ## Contact info 8 | 9 | Mark Heckler 10 | 11 | mark.heckler@gmail.com 12 | 13 | @MkHeck 14 | 15 | --------------------------------------------------------------------------------