Saturday, October 16, 2010

Receiving X10 RF Transmissions (Updated 11/21/10)

For me, at least, this was the last piece of the open hardware X10 puzzle. In this blog you'll find open hardware projects that receive and transmit PLC (powerline) signals, as well as transmitting X10 RF signals (via the CM17A). Now sitting in front of me, is an off the shelf 315MHz receiver (detuned to 310Mhz), happily beeping away each time a warm body crosses an X10 motion detector.

The receiver is from Sparkfun, but any similar receiver should work. The key is to get one with a tuning slug as opposed to a crystal. The software that interfaces the receiver to the Arduino is from a suite of X10 libraries written by ThomasM. You can find the whole suite (PLC transmit & receive, RF receive, and IR receive) here. Having written an earlier version of PLC receive, I'd recommend his version for PLC receive and transmit as well.

So lets get started. Get a  315MHz receiver, wire it up per the data sheet, get Thomas's libraries and his example sketch, (or get the "test & calibrate" sketch I made here). Press a key on an X10 RF remote. It should work right away, but only at close range.

So the next step is to tune this receiver closer to 310MHz. You'll want to start by adding an antenna. This page gave me the following lengths (in inches) for a vertical wire antenna at 310MHz:

  • 1/4 wave - 9 1/16"
  • 1/2 wave - 18 1/8"
  • full wave - 36 1/4"
I started with 1/4 wave whip antenna, but the ultimate may be the "egg beater" antenna (Google for examples).

Now it's time to tune the receiver to 310Mhz. I don't have a scope, and I found that a sound card scope was of little help, since the signal is clipped to soundcard inputs, so I came up with two alternate methods.

The first method I tried was to simply connect the output (data pin) of the receiver to the Aux-in on my PC. You will hear a lot of noise! (This is due to the AGC built into the receiver.) However you will clearly hear the RF signal when you push a button on an X10 RF remote - as long as it's close and pointing at the antenna. Pointing the remote away from the antenna gave a fainter signal, and moving it further away made it even fainter. So with the faint signal, I simply turned the tuning slug until I got a clearer sound in the speakers when I pushed a button on the remote. Not very scientific, but it seemed to do the job. (I started by turning the slug CCW - this post said ~160° CCW.)

Later I used a different method which seemed to be more "real word". I made the "test & calibrate sketch" linked above. It simply beeps a piezo and outputs to serial whenever the receiver has a good read. Then I clamped a button down on an X10 RF Remote (HR12A) so it would continuously transmit,  and located it at varying distances from the receiver. While listening for the beeps, I adjusted the tuning slug for good reads at the furthest distance.

While using the second method, I also played around with antennas.  The 1/4 wave whip antenna really didn't seem to do much, and I couldn't pick up signals if the transmitter was outside my house. Then I tried a 36 1/4"  piece of twisted pair from a phone cable. One wire to the ANT pin on the receiver and the other to GND. This made a big difference, and the grounded lead contributed to the difference.

That's about where I am at this point. Interfaced to the example sketch I can receive RF signals from the motion sensors on my front and back doors. There's more about this in last half of this thread in the Arduino forum. [4-3-13] (There were changes to X10rf.h - here is the modified version I used.)

Not sure at this point where I want to go with this - perhaps a "whole house" X10 receiver with some other goodies, or some little dedicated device. We'll see.

Sunday, April 4, 2010

Geiger Counter - Part 2 (complete)

[Edit 4/10/11] This project is now available in kit form - with PCB and parts. Please click here for more information.

This post describes how I went about integrating the circuit described in the previous post with an Arduino and a LCD display.

I put it all into an old laptop power supply case - not my best work, but as we said in Arkansas, "it ain't no piano". It does have a nice sturdy feel though.

After experimenting with an LED bar graph and a Nokia 3310 cell phone display, I settled on a simple and cheap 8x2 LCD display from Sure Electronics.

First I moved the Geiger circuit off the breadboard and on to a proto board.
Add caption
I kept things fairly tight which left a little room for future expansion. The piezo is mounted on the bottom of the board. I cut an opening in the bottom of the case under the tube.

On the other side of the case, I added the batteries, display and a small board for the Arduino MCU. It's just a simple stand-alone Arduino circuit using a resonator.
There are also 2 slide switches on the bottom - one to turn off the piezo, and the other to turn off the Arduino and display to save batteries. A salvaged push button on top turns the whole thing on and off.

The code counts the interrupts from the tube for a period of time, and displays the counts / minute as a value on the 1st line and as a bar graph on the second. I adapted the code for the bar graph from DeFex . It's nice because it uses custom characters to make partial blocks.

I used two different counting periods - a longer period when the CPM is below 100 (counting background radiation) and a shorter period when there is more activity. You can download the code here.

Here is the obligatory short movie . . .


It was a nice surprise to find our bathroom tile was hot. (Should help kill the germs!) Since the house was built in the '20s, I imagine it's uranium green glaze.

Sunday, February 28, 2010

Geiger Counter - Part 1

[Edit 4/10/11] This project is now available in kit form - with PCB and parts. Please click here for more information.


I guess I'm a "metroholic".
I've always been fascinated with measurement tools, so building a Geiger counter seemed like a logical thing to do. I will describe the build process here - even though the Arduino only plays small part, and that only a truly sick person (which I guess I am) would consider a Geiger counter as part of a Home Automation project.

"All work is derivative" and I owe the basic HV circuit to Jim Remington's Pololu article (where he mentions he derived the circuit from Tom Napier). To this, I contributed a nice "click" circuit, but more importantly, the sources, tips, and background that is helpful when building your own.

If you don't have a Geiger tube laying around in your junk drawer, you will have to order one. But the important thing is that you can build and test your circuit while you are waiting for that package from Russia.

The Geiger tube I settled on was the SBM-20. I ordered mine on eBay. You can also get it at the Electronic Goldmine (and even a whole kit). Later, I found this source for all tubes Russian, (and the best specs and prices on Geiger tubes). I am very happy with the SSBM-20. I originally tried a smaller glass tube - the CI-3BG - but found it much less sensitive - especially to beta particles.

There are 2 types of tubes. Those that have a mica window are the most sensitive. They will detect alpha and beta particles as well a gamma rays. Because of the mica, they are more fragile and generally are more expensive. The other type, like the SSBM-20 which I used, have only the metal jacket. They will detect gamma rays (the most penetrating) and some beta particles (more easily stopped). Considering the SSBM-20 is all metal, it does a good job with beta - as long as you put the sample right on the tube. Uranium is a big beta emitter, so some sensitivity to beta is a good thing.

As far as the circuit goes, you'll find several types on the internet. (One I also liked is here.) The first circuit I tried used a 1:1 transformer, but I preferred to go with a simple inductor instead. I also liked Jim's circuit because it works with a range supply voltages and uses very little current from the battery. Originally, I wanted the Arduino to be the oscillator instead of the 555, however, later I decided that I preferred the Geiger to run independently, and use the Arduino only for counting and display purposes. For the audio output, I had a good time designing my own based on what I learned on-line.

OK, you've been patient, here's the schematic . . .

You can download the image, and you can also get the Eagle files here.

On the left is pretty much Jim's circuit without the extra HV shutdown transistor. The 555 is used in an unusual way - it varies the duty cycle based on the input voltage. I tested 4-9V on input. The oscillator (~4KHz) is used with the inductor as a charge pump.

Q2 and D2 are the only critical type components. Q2 must be a high voltage transistor - the MPSA42 is a common type and works nicely. D2 is a "high efficency" or "ultra fast" diode. A regular diode will not work. On the schematic, I have listed some substitutions I've tried that worked. You might find a diode of this type in a PC switching power supply. R7 adjusts the high voltage, and seems to be pretty touchy about it's value - too low or too high and no HV. I bought most of the parts at Electronic Goldmine including the inductor.
[Edit 4/2/11] Also note that I used the CMOS version of the 555 timer - TLC555CP. If you use the bipolor version (uses more current) LM555 or NE555 you will need to adjust some values.

I labeled a HV Test Point. You want about 500VDC through the tube. But here's the rub, it's only a few micro amps, so most DMM's will load the circuit too much to measure it. If you measure around 200VDC you're doing fine. Don't even bother trying to measure across the tube - the 5.7M will drop everything.

Another tip is that the Geiger tube won't work if you leave your DMM connected to the HV test point. In short, you need a very good DMM or faith.

Finally, I wouldn't advise soldering leads directly to the ends of the tube. You run the risk of loosing the vacuum or otherwise damaging the tube. Use some sort of clip, or wrap several turns of wire around the ends.

While waiting for my tube, I tested by touching the wires that would go to it. (Two fingers on the same hand.) It's 500V but just a tiny amount of current. I could not even feel the voltage, but heard the click and got the interrupt. For obvious reasons, I can not recommend this procedure, and I'm just describing what I did. 


You will probably need to tweak the click circuit based on what type of "click" you like, and the resonant frequency of your particular piezo. R14/C7 controls the length of the click and R15/C6 controls the frequency of the click. The phase inverter (IC2B and IC2C) is used to get the most deflection out of the piezo and hence the loudest sound. For the inverters, be sure to use a logic family that provides enough current at the outputs. I had bad luck with the "LS" family and used the "ACT" family (i.e. SN74ACT14N) but the "HC" family should  also work (i.e. 74HC14N).

Once the circuit is built it's fun to play around with. With mine, I get around 35 CPM (Counts / Minute) background - a basement in Colorado, probably with Radon gas. Of course you will likely tear open a smoke detector and get the Am241 pellet out of it (600 CPM) and buy some Uraninite on eBay (350 CPM). [Edit 11/2010: Just tested some lantern mantles (Thorium-238) I got from this guy - got up to 6000 CPM.] The entire circuit consumes less than 3mA @ 5V in normal background.

The interrupt (before D3) goes low for about 150uS for each event. I made a simple Arduino sketch to count the events and calculate CPM. You can download it here. Later, I'll involve the Arduino more - building it into the case, and running a little 8x2 LCD display. Note that the Geiger counter module is totally standalone, so you can stop with that if you want.

For Home Automation, I picture it sitting on my roof with a CM17A periodically transmitting the current background radiation to the Nex10 box in my house (similar to the Wireless Temperature Transmitter). Then, if the radiation exceeds a threshold, I can dim the lights in the living room!



See Part II post above with added MCU board, display, and finished enclosure. But here is an intermediate step with just the Geiger circuit in a case . . .


A quick movie in it's intermediate state . . .