archieroques
Posts: 26
Joined: Sun Mar 16, 2014 8:13 pm

How to use Sparkfun Geiger Counter with Pi?

Sat May 23, 2015 2:21 pm

Hi,

I recently bought a Sparkfun Geiger Counter board (https://www.sparkfun.com/products/11345), to use in a robotics project with a Raspberry Pi A+ (although I'm doing the development with a B+ for practicality). I think that the best way to connect it is over USB, as the Pi and the Geiger Counter have different logic levels (3V3 vs 5V). The main issue is how should I go about connecting it? I think I need FTDI drivers, but the documentation and tutorials about this particular product are very thin on the ground.

I'd be really grateful if anyone could shed any light on how to get this set up with the Pi, ideally giving me information each time it senses radiation, so I can deduce counts per minute/second/milisecond.

Thanks in advance,
ARCHIE

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to use Sparkfun Geiger Counter with Pi?

Sat May 23, 2015 4:08 pm

Hi Archie,

SparkFun's website is not very helpful. It looks like there are two versions of the firmware: one that prints 0 or 1 when a pulse is received (v1.2), and one that outputs a CPM value every now and again (v1.3). It looks like SparkFun ships with v1.2, perhaps.

The good news is that you won't need a driver, as FTDI USB serial comes enabled by default. So if you plug the thing in and run a simple terminal at 9600 baud, it should work. I'd do something like this:

Code: Select all

screen /dev/ttyUSB0 9600
and you might get some zeroes and ones crawling across the screen.

That kit has quite a nice tube, but I'm not super keen on the lack of a case (nasty voltages around a G-M tube) or the lack of isolation between the HV tube circuit and logic.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

archieroques
Posts: 26
Joined: Sun Mar 16, 2014 8:13 pm

Re: How to use Sparkfun Geiger Counter with Pi?

Mon May 25, 2015 3:52 pm

Hi,

Thanks for your help. I've done what you said, and indeed many 0s and 1s begin to crawl across the screen. However, I'm not sure what a 0 or a 1 should signify - as far as I can tell whenever the counter LED on the board flashes, a 0 or a 1 comes up, but I don't know the difference between them.

Where did you get the info about the firmware? I couldn't find any on the website. How could I change the firmware to v1.3, or edit it to change what it defines as a 'count'?

I've researched using FTDI in a python script, and it seems that PyUSB is the way to go. Are there any precautions I should take, or anything I should be aware of, before attempting to embed this into a python script?

Thank you,
Archie

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to use Sparkfun Geiger Counter with Pi?

Tue May 26, 2015 1:22 am

Yay! I'm glad it seems to be working for you.

The 0 or 1 appear whenever there's a discharge. It seems to implement a half-baked Random Number Generator (linked to the tutorial there) where it records the time between each pulse, and outputs:
  • 0 if the time is less than the previous gap, or
  • 1, if it's greater.
Background radiation is a source of true randomness, but you will need to filter it a bit to get something cryptographically useful. It will also take forever to generate a useful amount of data. Use the Raspberry Pi's built-in HWRNG if you need a faster source.

To get your CPM values, you'll need to count how many characters you receive in a minute. You can use PySerial (not PyUSB) to read the characters. The timing isn't going to be that accurate, as serial ports have buffering that tends to get in the way.

It wouldn't be incredibly hard to rig up a tiny bit of circuitry and a level converter that would read pulses meant for the LED on the board, and read them directly using the Raspberry Pi's GPIO. But try the serial link for now.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

archieroques
Posts: 26
Joined: Sun Mar 16, 2014 8:13 pm

Re: How to use Sparkfun Geiger Counter with Pi?

Wed May 27, 2015 9:51 pm

Right. I had a look around on the product page and then the Github repo for the product, and I found this page:
https://github.com/sparkfun/Geiger_Coun ... nter_board

From the description, this does pretty much exactly what I want - gives a counts per second value, instead of a per minute value. This is much more useful to me, although counts per tenth-of-a-second would be better. I clicked on the 'main.c' file, and this looks like something I could possibly work with, although I don't have any experience of C (just a bit of Arduino, which is close but not identical).

Quite why the product doesn't ship with this version I don't know - after all, the product is a Geiger counter, not a random binary box.

How would I put this firmware on the board - do I need any special equipment/software? Then I'll just use Pyserial (lots of internet tutorials available for that, and probably divide the value by ten in the python script, to avoid messing around with C, where I don't know what I'm doing.

I think that I'll need to do some further research on the topic of Geiger Counters, because I really want to change what a count is, and set it up to detect certain types of radiation. Whether that can be altered using software or not remains to be seen.

Thanks,
Archie

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to use Sparkfun Geiger Counter with Pi?

Sat May 30, 2015 1:32 am

I'm sure you could ask on the SparkFun product page. I see that the 1.3 firmware only supports a particular hardware revision, so you might be out of luck.

With the right wiring, you can use an Arduino as an ICSP to reprogram another µc.

Stewart
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Automation, sensing and robotics”