1553

A system to remotely measure and report the residual activation level of dried mushroooms after the Tjernobyl accident.

Radiomush, radiology of mushrooms, 30+ years after Tjernobyl
a system to remotely measure and report the residual activation level of dried mushroooms after the Tjernobyl accident.

I live in Sweden, which was severely exposed to the radioactive fallout (mostly Cs137, a beta-emitter with half-life of about 30 years) after the Tjernobyl accident in 1986 and my home-university in Uppsala this year conducts a citizen-science project ("Stralande jord") with secondary schools all over Sweden to collect and send in mushroom samples to analyze in a lab at the university. Mushrooms with their large underground mycelium are expected to be a good indicator of anything that accumulates in the ground. For the high-school students to understand what goes on in the lab, they should also build a pin-diode based radiation detector, place it together with the dried mushrooms in a tin can, and record beta radiation in their schools. My idea was to measure the count rate with an ESP32 and automatically report it via MQTT to a server/broker at the University where another process subscribes to the MQTT-feed and stores the counts in a MySQL data base. Building the ESP32-based MQTT sensor-node was considered too complex and expensive, and also possibly too frustrating due to the long counting periods. Instead, they will optionally build a much simpler click-based system, similar to the one published in Elektor in 2011. On the other hand, having the ESP32 board in my hands, I built a prototype system anyway, and describe here the design and implementation on a breadboard. The functionality to control via MQTT, and funnel data directly into a data base was a cool challenge in any case.

The task-list for the electronics and software comprises of the pin-diode with op-amp based amplifier, a comparator with adjustable trigger-level to adapt to different signal levels, an ESP32 to control the trigger level, count the pulses and report the count-rate via MQTT, a MQTT broker, and a python script that listens to MQTT and stores the count rates in a MySQL database. Most parts are rather generic and should be easily adaptable to other measurement tasks.

Amplifier Ā 

The very small current that the pin-diode generates when struck by an electron needs to be amplifiedĀ  by a very large factor and I use the simple amplifier that is described on the web-page http://www.elektronik-labor.de/Projekte/Alpha5.html. It is based on a dual operational amplifier TLC272. In the attached zip file I include a figure and a photo that shows my realization on an experiment-board. Care needs to be taken to have as short as possible connections between components and op-amp in order to reduce the sensitivity to noise, especially of the signal from the pin-diode. The amplifier with the pin-diode inside should be placed in a metallic box, I use a tin can, which will shield any electro-magnetic perturbations, for example, the 50 Hz hum from the power grid. Moreover, the box should also be adequately tight to shield ambient light. Ā 

ESP32 and Comparator

I placed the ESP32 on a breadboard and added a LM311N comparator, which has its (open-collector) output connected to GPIO22 (with pullup enabled) and the negative input terminal of the comparator to GPIO25 that doubles up as output for one of the on-board digital-to-analog converter (DAC) of the ESP32. I also hooked up a button to GPIO21 in order to manually start the data acquisition. GPIO05 is used as a simple pulse generator to test and debug the functionality. I used the Arduino-IDE, with ESP32-support added, to program the ESP32, and I base the sketch on the code from the MQTT chapter of (caution: shameless advertisement!) my book (https://www.crcpress.com/9780815393603). The sketch starts with declarations of network credentials, pin assignments, and a number of variables, some of which are declared volatile, because they change in interrupt routines. I then include support for WiFi, hardware support for the ESP32, and MQTT via the PubSubClient header file. Next, I define the on_message() function that is called once a subscribed-to MQTT message arrives. It writes status info to the Serial line and then checks the MQTT-topic and branches to handle requests to set the DAC, start the data aqcuisition, and to set the pulse duration. The function intr_action() is connected to a pin-change interrupt and only increments a counter. In the setup() function the initialization of IO pins, Serial and Wifi is taken care of. Then the connection to the broker is established and the callback to the on_message() function is created before setting the DAC to some default values. In the loop() function I make sure that the ESP32 is connected to the broker and then subscribes to a number of topics. The call to the client.loop() function handles all MQTT background activities. Then follows a check whether the variable pulse is positive and it is used to produce a 100 micro-second long pulse on GPIO05 if a certain time since its last invocation has elapsed. Since all activities have rather relaxed timing requirements, I use this way to handle timing, rather than using timer interrupts. In the next part, a heartbeat is published via MQTT every 5 seconds, before a switch-case construct forms a simple state-machine. Normally the variable start_counting is zero and nothing happens, but once it is set to unity, either because a start request arrived via MQTT or the button was pressed, the variable start_counting is set to two. In the case 1: stanza the interrupt service routine that counts pulses on the RISING edge is attached to GPIO22 and the start time is remembered in the variable startedCounting. If start_counting is two, the elapsed time is checked and if it exceeds ms_to_count, which is set in the on_message() function, it detaches the interrupt and publishes the counts via MQTT.

The receiving end

On another computer, I use a Raspberry Pi, I installed the mosquitto broker, Python, and MySQL. For testing the MQTT connection I used the mosquitto_sub and mosquitto_pub command-line clients. See the README file in the zip-file that accompanies this project for examples. Once that worked, as MySQL administrator, I created a MySQL database called esp32node1 and then, as normal MySQL user, I created a table called rates, which only contains a timestamp and an integer called count. All commands are included and documented in the zip-file. Finally I wrote a very short python script that includes support for MySQL and the Paho MQTT library. The script mqtt2mysql2.py is also included in the zip file. After connecting to the broker, the script subscribes to the counter variable published by the ESP32. In the on_message() callback function, the received message is displayed, and then stored in the database with the SQL insert command. As long as this script runs, either started by hand, or by automatically starting it a boot time with a cron job, every time a measurment on the ESP32 completes, it is added to the database with the current time stamp. The measurements can be either started by pushing the button, or via MQTT.

Famous last words

My colleague Marek tested the amplifier with a Cs137 radioactive sample from the nuclear physics lab and the measured pulses after the amplifier only had an amplitude of about 70 mV on an oscilloscope. A Sr90 probe (another beta emitter) showed similar signal amplitudes. Of course I can adjust the threshold of the DAC to that level, but a higher amplification is better, if we mainly intend to sense Cs137 from Tjernobyl from mushrooms placed in the tin can. Moreover, the low activation of the mushrooms and the very small sensistive area of the pin diode requires very long counting periods. Maybe bring your recent copy of Elektor to read while waiting...

The system described here is only a proof-of-concept system and for public deployment, some security level, such as MQTT provides, must be added. Also each sensor node must be identified. I just used the MQTT topic for this, but other, more elaborate ways, are certainly possible. My vision was to have students take the tin-can to the field and use the tethering-capability of their smart phones to directly report measurements to the Raspi with the database. Adding a process that reads the database and creates a web page with a map of Sweden to display the most recent measurement, would be cool to have, but this must wait until the coming summer vacation. I also wanted to use the Bluetooth feature of the ESP32 to connect to a phone, but did not have time to explore this further due to lack of time. Again, maybe next summer.

There is additional information in the README file in the zip file. Also the 'figure captions' for all images are included. Moreover all sources are in the zip file.

Have fun and mogrify this project into something that YOU can use.
Ā