Introduction: IoT - Geiger-Muller Counter on Arduino Nano Using MQTT

Status: republished

.

New VERSION 1.2 (see Firmware upload section)

VERSION 1.1

This project provides a very affordable (25€) IoT for Radioactivity long term monitoring using the MQTT transmission protocol widely use in IoT environment. It can be integrated into Home automation applications or Node-RED environments. For keeping electro-smog in house as lower as possible, we made the choice to use wired network.

=> Check also my other DIY for help on how to build and calibrate the external probe.

C-GM Device Features :

  • —beta, gamma and X-ray radiation’s counter
  • —Max CPM : 65535 (430 µSv/h)
  • —Support GM tubes such as SBM-20/19, STS-5 (CTC-5), SI-29-BG, SBT-9/11A, SI-180G, LND-712/7312, etc.
  • —400V GM tube High Voltage
  • —Ethernet connection for control and data communication
  • Static IP address support only
  • The interface is basic and made of a LED and one button.
  • Returns current CPM and µSv/h, Max and Average values
  • —LED flash on discharges and report failure (steady or fast blinks)
  • —External 6V DC pack power (e.g. 6V/1A DC pack available from Amazon, eBay, Banggood, etc.) up to 9V with heat sink on voltage regulator.
  • —Low cost, few components
  • OPTIONAL : The module can be power from an external 6-9V DC pack or using PoE (power over Ethernet). The PoE voltage must be within the range 6-9V. (see IoT: Powering Arduino devices using PoE)


WARNING (risk of electrical shocks)

The device requires a 400 Volts power supply. 
Despite the current delivered will remain very low, I discourage people not accustomed dealing with electronics
and electricity to try building this device.


IMPORTANT: Keep the probe cable as short as possible. For example, with a 1.5 meter cable at 6 meters from a 5kW inverter, the measures are completely spoiled by the electromagnetic fields. A shielded cable didn't solve the problem because the cable capacitance filters the radioactivity spikes.

Supplies

See the Bill Of Material section for references and prices.

  • Arduino Nano V3.0 AVR ATmega328 P-20AU with USB cable
  • Moligh doll ENC28J60 Ethernet module for Nano 3
  • High Voltage DC-DC Boost Converter 3V-5V Step up to 200V-620V Power Regulator
  • G.M. Tube STS-5 / CTC-5 Soviet Army
  • LED 5mm
  • Push button red
  • Veroboard 10 x 20 cm
  • Resistors, Capacitors, Zener
  • Miscellaneous e.g. 2-wire cable 0.5mm²
  • Black plastic box 158 x 90 x 60mm (option)
  • 6V/1A DC pack with mini 5.5mm plug (option)
  • Arduino Nano 32 extension module (option)

Step 1: Building the Device

HARDWARE:

The schematic has been reduce to the minimum and can be easily wired on a perfboard.

Just follow the schematic.

   Arduino           ENC28J60 Shield    Components
---------------------------------------------------------------------
D3 (in) - GM tube (INT0)
D4 (out) - LED GM tube
D5 (in) - Push button (with internal pull-up)
D10 (out) CS -
D11 (out) MOSI -
D12 (in) MISO -
D13 (out) SCK -
D14/A0 (in) - HV divider (/455)
RST (out) RESET -
VIN - 5-9V
GND GND GND

—
There has been an additional 5V regulator (7805) added because the onboard Arduino Nano 5V regulator is not well dimensioned to support the voltage conversion from Vin to 5V required to power both the Ethernet shield and the Nano.

The device total consumption is 160mA (1W) and about 40mA is drained by the poor performance high voltage booster.

—NOTE: The 400V High Voltage depends on the internal 5V and must be adjusted with the attached DC pack running.

You shall calibrate the CPM of the tube (FAC) with comparison with an other GM counters or a calibrated radiation source if any. To do so, connect the USB port to a terminal and issue the new conversion factor using the FAC command (e.g. FAC=150.8).

The internal voltmeter shall also been calibrated. Place a high impedance multimeter on the outputs of the high voltage module and read the internal voltage (press the SEND button and read returned values in the terminal). Modify the HV conversion ratio using the HVL command such as HVL=155. Increase or decrease the HVL values until both values read on the multimeter and inside the terminal match.

.

SOFTWARE:

There are two versions of the Firmware : one with the bootloader and one without. In order to enable and have the watchdog running correctly, you must flash the Optiboot bootloader into your Arduino Nano. The Atmega328p bootloader (usually available with the chinese Arduini Nano devices) does not handle correctly the watchdog and crash.

NOTE : For flashing a new bootloader, browse the Internet. there are plenty of website explaining how to proceed. You will need a second Arduino for this and connect the device to be flashed using the SPI wiring (ISP).

IMPORTANT : To configure the firmware with the correct IP address and other parameters, use a console (Arduino IDE or Termite) and keep depressed the SEND button during power-up until the serial connection display "CONFIG Mode" instead of "MQTT mode". This disable the network and avoid the firmware to hang while trying to connect to a wrong server.

When the broker ( MQTT server) is outside your LAN, don't forget to set the DNS (e.g. your F.A.I. DNS) and the Gateway (your box or router) IPs.

SERIAL COMMANDS:
================
Connect using a baudrate of 115 200 Bauds and LF suffix to send command.

? Display help
WDG=[0,1] Enable/disable watchdog (8secs delay)
FAC=xxx.x Conversion ratio CPM to µSv/h for Gm tube (e.g. SBM-20/STS-5 = 153.8)
HVC=xxx Conversion level to voltage x 100 (e.g. ~1.4 -> 140) in range [0-255]
RESET Clear counters (current, average, total, max and elapsed time)

MAC=xx:xx:xx:xx:xx:xx Set the C-GM Counter device MAC address (enter decimal values)
IP =xxx.xxx.xxx.xxx Set IP address
DNS=xxx.xxx.xxx.xxx Set IP address
GWY=xxx.xxx.xxx.xxx Set IP address
MSK=xxx.xxx.xxx.xxx Set IP address
SVR=xxx.xxx.xxx.xxx Set MQTT server/broker IP

CID= Set client ID (5 chars max)
USR= Set user name (8 chars max)
PWD= Set password (8 chars max)

OPTIONS Show parameters values
SAVE Save parameters into EEPROM
MEMORY Show free memory
VERSION Show firmware version

NOTE: Keep SEND button depressed during start-up to disable network and ease configuration through USB connection using a terminal such as Termite.

Step 2: Firmware Upload

XLoader is the simplest tool for uploading the HEX firmware file.

  1. Connect the Arduino to your PC first (in order to detect the port COM).
  2. Start the XLoader application.
  3. Select the HEX file to upload into the Arduino Nano.
  4. Select the Device =Duemilanove/Nano (ATmega328)
  5. Select the correct COM port.
  6. Set the baudrate to:
    • 57600 for Arduino Nano with Old bootloader (mainly those from China)
    • 115200 for Arduino Nano with Optiboot Bootloader
  7. Press Upload

The firmware upload is very fast. If the XLoader application hangs up, may be you have selected the wrong bootloader type.

Step 3: The Web Interface in Node-RED

You can add this device to your existing home automation by creating a MQTT device input.

For those having a Node-RED environment available, you may import the JSON file below into your Node-RED Dashboard (requires MQTT broker and SQlite for a permanent database).

.

NOTE: This JSON flow is still under development. If you intend to build this device, check back the project for latest updates.

.

The messages are send every minutes where the topic is made of the CID/ and the payload. (e.g. CGM/CMP gives the current radiation measure in count per minute)

  IOT:
=============
"MQTT messages":
CMP Cout per minutes. Radiations detected within the last minute
MAX Maximum CPM since startup/reset
AVG Average CPM since startup/reset
TOT Total counts since startup/reset
ELP Time elapsed since startup/reset
FAC CPM to µSv/h conversion factor

"MQTT command":
RST Reset all device counters (e.g. CGM/RST to clear measures)

==> You have to change the path of the DB nodes in the Node-RED dashboard to match your system.

The "CLEAR DATA" button erases all data store into the database and reset the CGM MQTT device counters (Average CPM, Max CPM and elapsed time).

Press the "SEND" button on the device to output values.

The database is updated every minutes with the new values.

The plot displays either the last hour or the last 24 hours. The two curves will be identical after power-up during the first hour.

Step 4: Bill of Materials (BOM)

You will find here above the list of components I used and theirs respective prices. This list is given for information only and it is not required to cope with the list above, therefore alternative components can be used as long as they match the characteristics of the listed components.