Friday, January 11, 2013

Keeping tabs on my standby generator with Raspberry Pi (Part II)

This part will discuss the hardware setup. As I stated in Part I, the temperature sensors are Maxim DS18B20 1 wire variety, a part that has been around for many years. It looks like an old style transistor such as the PN2222, however, it is a good deal more sophisticated. When a device (such as a properly set up Raspberry Pi) issues a temperature request, the DS18B20 responds by sending back its unique serial number, along with the temperature it measured.

My first test setup was on a breadboard, to verify the circuit would work. In order to simplify doing the hardware connections, I purchased the Adafruit Cobbler breakout kit. This simple board makes hookups to the Pi so much easier, it is well worth the cost involved.

My intent was to use at least 3 sensors. I could have of course simply soldered all 3 directly onto a chunk of telephone wire and be done with it, but I decided to take a more modular approach. I ordered some RJ45 jacks, the type used for Ethernet networking. Then I devised my own little circuit board which would accommodate:

2 RJ45 jacks

1 DS18B20 temperature sensor

1 4.7K Ohm resistor

printed circuit wiring to connect 1 jack to the other side.

I had some left over copper clad circuit board sitting around, so I cut some pieces fitted to just the width of the RJ45 jack. Then, with a fine tipped magic marker I drew the circuit on by hand. Since I wanted 5 boards I had to do this 5 times, but that was not a big deal.

Next I needed to etch this board. For that I used this procure at instructables.com. In essence, all you need to etch copper is hydrogen peroxide and muriatic acid.

Above shows some boards already etched and others still in the bath getting very close. At the same time as the temperature sensor boards, I also etched a board for the LEDs, as well as a T junction board for another project in the future, where a line can branch off another line.

Once the boards were etched (+/- 10 minutes), I rinsed off with cold water and then let them dry. Next, I used some steel wool to sand off the felt tip marker to reveal the copper traces. I got 2 drill bits at the hardware store (1/32” in size) and drilled holes for the leads. Pretty tricky, as the drill bits are extremely thin and prone to breakage, but I managed to do just fine.

I then placed the components and soldered them on. The jacks are normally setup for 8 wires, but I only needed 3, so I cut off the ones that were surplus, foregoing the need to drill holes for them. It is a bit of a fiddle, but not too bad.

On the above picture you can see the components, as well as the two jumper wires necessary to connect the two jacks to one another. As you can plainly see, this is handiwork, not industrial production.

Once this step was finished, it was time to test. Connecting the first sensor with an RJ45 cable worked beautifully. Connecting the second one, however, gave me a temperature of 85 Celsius. I checked and rechecked all connections, and everything seemed right. As a last resort, I decided to flip around the board, which made it worked. Obviously, I must have used a crossover cable.

Then I ran the lines to the generator. The first temperature sensor unit sits right next to the Pi (I cut an RJ45 cable and hooked this up to the GPIO pins). Then I routed the line through the wall and placed the second sensor unit next to the generator. The third one as placed in the generator cabinet, where it is directly exposed to the temperature swings created by the generator.

I placed the second sensor unit underneath a hand made aluminum canopy and also in a see through plastic bag, with a small hole on the bottom for drainage and ventilation. I intend to improve on this once I think of a way to better weatherize this.