dxalxmur.com

Exploring Raspberry Pi and Geiger Counters: A Unique DIY Journey

Written on

Chapter 1: The Beginning of an Unconventional Hobby

When I excitedly shared my latest gadget, a "RadiationD-v1.1(CAJOE)" Geiger counter, many responded with disbelief, including my mother’s classic, “You bought a what?!” My interest in this device sparked during a weekend when all Danes were advised to stock up on emergency supplies and iodine tablets. As I ordered those iodine pills, I thought, “Why not go all out and get a Geiger counter too?”

Cables, Connections, and a Minor Mistake

In the images provided, you'll see I've chosen an interesting color scheme for the cables. Sarcastically, the white cable is linked to the GND connector, the light-gray cable to the 5V, and the purple cable to the VIN connector.

![](img/cable-configuration)
width:800
alt:Colorful cable configuration for the Geiger counter setup

It’s important to note that the VIN connector appears to be mislabeled. Typically, this should serve as an input, yet here it functions as an output. If anyone has insights on this, please leave a comment!

The following image illustrates the connections to the Raspberry Pi 5. The red and black cables are intended for a display linked to the RPi, which can be overlooked for now.

![](img/raspberry-pi-connection)
width:800
alt:Raspberry Pi 5 connection layout

The white cable connects to 5V, the gray to GND, and the purple to pin 7 (GPIO 4). A detailed pinout of the Raspberry Pi 5 can be found in the subsequent chapter.

Understanding the Proof of Concept

As outlined in the README of the GitHub project, the first step involves setting up the Python environment. The outdated GPIO library must be uninstalled, as it no longer applies to the Raspberry Pi 5:

sudo apt remove python3-rpi.gpio

Next, we install the two necessary libraries for this project:

python3 -m pip install rpi-lgpio flask

We’ll begin by importing the essential external modules:

import time

import RPi.GPIO as GPIO

Next, we define the global variables we'll utilize:

# Counts Per Minute. Anything below ~270 (give or take)

# is considered acceptable [citation needed].

cpm = -1

counts = 0

current_time = int(time.time())

avg_over = 10 # seconds - can choose from 5, 10, 15, 30, 60

The core of the code consists of three crucial lines:

GPIO.setmode(GPIO.BOARD)

GPIO.setup(7, GPIO.IN)

GPIO.add_event_detect(7, GPIO.FALLING, callback=on_event)

You can choose between GPIO.BOARD and GPIO.BCM for the GPIO mode. I opted for BOARD since I had already designated pin number 7; however, I could have just as easily chosen BCM and set the pin to 4. Refer to the following diagram for a comprehensive view of the Raspberry Pi 5 pinout.

![](img/raspberry-pi-pinout)
width:800
alt:Pinout diagram for Raspberry Pi 5

By using BOARD pin 7, we can see that this correlates with GPIO 4, which is the BCM number. For clarity, I decided to stick with the BOARD reference.

Finally, we assign a callback function that executes each time the Geiger counter detects an event. The following simple counter updates the counts-per-minute variable:

def on_event(channel):

global counts, cpm, current_time

counts += 1

if current_time + avg_over < int(time.time()):

current_time = int(time.time())

cpm = counts * (60 // avg_over)

counts = 0

That’s essentially the overview. If we replace the body of the on_event function with a print statement, we’ll receive a new line each time the Geiger ticks:

def on_event(channel):

print('Tick!')

Understanding CPM Thresholds: What's Safe?

Determining what specific counts per minute signify is complex as it varies by instrument [Wikipedia]. Some sources indicate 5–60 CPM is typical [U.S.NRC], while others warn that anything over 100 is concerning [SOEKS]. Yet another source [ECOTEST] suggests that 7–30 CPM is standard, with anything below 150 considered safe.

In my tests, I consistently recorded readings between 20 and 30 CPM, which I believe is "normal." To my knowledge, there haven't been any notable events that could influence these measurements.

I've categorized the following thresholds for my setup:

  • Safe levels: 0–100 CPM
  • Worrisome levels: 101–150 CPM
  • Dangerous levels: 151+ CPM

While I lack a scientific foundation for these values beyond the aforementioned sources, I remain vigilant if the CPM levels surpass, say, 120 CPM.

Future Developments

Initially, I configured this setup as a Grafana dashboard that scrapes the CPM data using Prometheus. This is easily achieved by incorporating a small web server within the Python script that presents the latest CPM metric. In the proof of concept, the following code is all that’s necessary (along with the Flask configuration):

@app.route("/metrics")

def cpm_metric():

return f'''

# HELP radiationd_counts_per_min Ambient temperature in Celsius

# TYPE radiationd_counts_per_min gauge

radiationd_counts_per_min {cpm}'''

This setup allows Grafana to visualize the data from the radiationd_counts_per_min metric, reflecting the current CPM measured from the RadiationD device, extrapolated from the past 10 seconds. Setting up Grafana and Prometheus is beyond the scope of this article, but there are numerous resources available online for guidance.

Additionally, the project could be expanded to display the CPM reading on a small screen attached to the RadiationD Geiger counter, so users can see the CPM while using the device as a portable, battery-operated tool.

Conclusion: Thank You for Joining Me

Thank you for following along with this project. If you found this article informative, please consider liking it or leaving a comment. For those interested in enhancing their Python skills to better understand this guide, I recommend checking out my educational series on Python.

Until next time!

— Birb

Chapter 2: Engaging Video Tutorials

In order to enhance your understanding of building a Raspberry Pi-powered Geiger counter, check out the following videos.

The first video, titled Raspberry Pi-powered steampunk-inspired Geiger counter, dives into the creative process of constructing a Geiger counter with a unique design.

The second video, Hak5 1817 - Open Source Hardware Geiger Counters and Linux Tools for the Forgetful, discusses various open-source hardware options and Linux tools for managing Geiger counters effectively.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

The Essential Signs It's Time to Move On: A Guide to Quitting

Understanding when to quit can be crucial for your success. Here are five signs that indicate it's time to move on.

Think Carefully Before Investing in a Mac

Consider essential factors before purchasing a Mac to ensure a wise investment.

Apple's iPhone 15: Embracing USB-C and Exciting Features

Discover the new features of the iPhone 15, including USB-C ports, enhanced cameras, and design upgrades.

The Time I Tried and Failed to Break the Internet

A humorous reflection on a past video attempt and the lessons learned about sharing ourselves online.

The Incredible Journey of Jane Todd Crawford: A Medical Milestone

A remarkable tale of Jane Todd Crawford's 60-mile ride for surgery, which transformed the field of medicine and saved countless lives.

COP28: Big Oil's Influence on Climate Action Unveiled

Examining the significant impact of Big Oil on the COP28 conference and climate action efforts.

# Transforming Resistance into Gratitude: Navigating Change in the Workplace

Discover strategies to help employees overcome their fear of change and embrace new initiatives in the workplace.

# Strategies for a Healthier, Longer Life: Insights and Practices

Explore effective strategies from longevity experts to enhance health and increase lifespan through diet, fasting, and lifestyle changes.