Wire Communication That Doesn’t Work

16. August 2016 Blog 0

It may seem silly to talk about things that didn’t work. But those are the things that you learn from, more than the things that do work. So here are a few things I tried recently in an attempt to log temperatures throughout my house, and which failed to work as expected.

I live in a townhouse with three levels and four rooms: two on the lower level, one large room on the main level, and one bedroom upstairs. The house was built in 2013, but they only wired it with old-school telephone wires and antenna cables.

My goal was to log temperatures in all four rooms using the existing wires. This is partly as an exercise to collect data, and partly because I eventually want to replace the thermostats with something I build myself.

So how hard can it be? Well…

Slow SPI

My first idea was to use the existing telephone wires for SPI. I figured that by running it at a slow enough clock, this should work even through long telephone wires. The phone outlets have six pins, and the other ends of the cables in the little wiring cabinet downstairs even had eight, so all I’d have to do is figure out which ones were wired up and I’d be good to go, right?

After a lot of trial and error, I decided to open up one of those wall boxes. And lo and behold, only four wires are actually connected to pins. SPI needs at least six wires for two-way communication. I would have had to replace the phone sockets, which I was reluctant to do since I didn’t know if this was even going to work.

1-Wire over Telephone Wires

But there are lots of other options, so on to the next one. I was going to use DS18B20 temperature sensors that use the 1-Wire protocol. The sensors have three pins, one for ground, one for power, and one for communication (hence 1-Wire). My phone wiring has four wires, so I should be good to go, right?

This didn’t work out either, and in hindsight it’s kind of obvious why. 1-Wire is a time-driven protocol without a clock. So it can’t be slowed down. And its signal is at roughly 1MHz, way too high to be transmitted clearly enough over any length of phone wire.

Slow I2C

Given four wires, surely I2C would work! It needs two wires for power and ground, and then one for the clock and one for the signal. And since it has a clock, I can slow that down as much as I want to make it work over long distances. Easy!

I bought some MC9808 I2C temperature sensor boards and went to work. Using a bus pirate, I was even able to make it work using the slowest data rate it supports (about 5kHz) when running it over the shortest connection in the house (the same room as the wiring cabinet). Unfortunately, I could never get it to talk to the sensor when it was on the third floor.

My plan had been to run this directly from a Raspberry Pi. It turns out that the slowest I2C speed you can set the Pi to is 3826Hz, which isn’t sufficiently different from 5kHz to make this worth trying.

1-Wire over Antenna Cables

I had tried the phone wires first, because it was much easier to buy phone cables to cut up to get to the connectors, and to just connect to the wires in the wiring cabinet. It seems like nobody uses regular antenna connectors for anything, all you can buy are crimp plugs (things are much better with SMA, but that’s not what I have).

But clearly, the problem was the frequencies at which the sensors were communicating. So the antenna cables would be the much better choice.

Of course, an antenna cable only has two “wires,” so what good can that be? Well, the DS18B20 has a parasitic power mode, where it only needs two wires total. And that ended up working beautifully! I will describe that solution in the next posting.

Leave a Reply