Some time ago I bought a radiation sensor also known as a Geiger Counter. It can display the counts per minute on the built in display. The radiation sensor is based on an open-source board which is connected to a geiger muller tube. These small radiation sensors are very inexpensive and can be bought on many places online. I added a part list on the end of this post.

In the graphic below you can see the radiation in my hometown Venlo, The Netherlands for the last 7 days. The graphics are updated in real-time.

And below for the last 24 hours

And below for the last month

Everything is built in a battery powered 3D printed case so you can take it with you everywhere.

Connecting the board to a linux based system.

Now comes the interesting part. The board has a TTL-serial connector. This is a serial connector operates at Transistor to Transistor Voltage levels (3.3 Volt). It can be connected to the computer through a ttl-usb adapter (TTLSerial<>USB converter) which converts the signals to +15 volt serial voltage. When connected to a computer, the counter can be powered from usb and simultaneously output to the standard serial terminal. The output is written in Counts Per Minute or CPM in one minute intervals.

I had a FTDI cable laying around wich I connected to the 6 pins from the board. (see part list below).

For reading the values from the counter you first have to connect the FTDI TTL to Serial cable to a free usb port on your system. Now you have to find the port wich Ubuntu assigns to the adapter. If you use Ubuntu or some other linux based system, you can display the connected usb devices by running the following command:

sudo lsusb -v | grep 'idVendor\|idProduct\|iProduct\|iSerial'

All the connected usb ports are shown. Find the device wich says something like FT232 UART, FTDI or TTL to Serial adapter.

Now you have to make the new usb device persistent so that the assigned serial port is the same after every restart. Note down the values from the idVendor and idProduct. Use the following file to assign the ftdi cable to a named serial port:

sudo nano /etc/udev/rules.d/99-usb-serial.rules

enter the following line with the values shown in the previous output

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB-geiger"

save the file with CTRL-O and restart the system. After the restart the following serial port is assigned to the ftdi cable: “ttyUSB-geiger” You can check if it’s created using the following command:

ls -l /dev

The new “ttyUSB-geiger” device has to be listed. Now you have to add your user to the dialout usergroup to have rights to the new created port. Use the following command:

sudo adduser user dialout

change the user to the username you use. You are now ready to read the values from the counter and save them to a file.

Reading the values from the counter and save them to a file with a service

You have to use socat to read the values from the serial port and write them to a file. First install socat using the following command:

sudo apt-get update && sudo apt-get install socat

Now create the following file /etc/systemd/system/geiger-counter.service

[Unit]
Description=Geiger Counter Connected to ttyUSB-geiger
After=network-online.target

[Service]
Type=simple
user=root
ExecStart=/usr/bin/socat /dev/ttyUSB-geiger,raw,echo=0 \SYSTEM:'tee -a /~home/geiger.txt'
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Make the service file executable with the following command:

sudo chmod +x  /etc/systemd/system/geiger-counter.service

The file creates the file /~home/geiger.txt. The tee -a command adds a new line for every new reading.

now reload the newly created geiger counter service:

sudo systemctl reload-or-restart geiger-counter.service

The service is loaded every time you restart your machine.

The output from the geiger counter is saved to the file /~home/geiger.txt in your home directory. You can display the values by entering the following command:

tail -f /~home/geiger.txt

Adding the measurements to Home Assistant

Adding the Geiger Counter to Home Assistant is easy. You can add the following lines to your configuration.yaml file:

sensor:
  - platform: command_line
    name: Radiation
    command: "tail -n 1 ~/home/geiger.txt"
    unit_of_measurement: "CPM"

The tail -n 1 only reads the last value from the file and puts it in the Home Assistant database. To display the latest readings you have to create a new card on your dashboard. Click on the plus symbol and add the following data:

Click ons SAVE and you’re done.

Part List

Geiger Counter

https://tinyurl.com/yyv2htfq

TTL to USB cable

https://preview.tinyurl.com/y3cs4orn