About a year ago I decided it would be a good idea to monitor the temperature in different rooms in the house and outside. The motivation was that, later, I might start controlling the heating by computer and the data would be useful.
When we moved in I had already devoted some time and energy to installing CAT5e cabling and RJ45 sockets in each room. With the WiFi there were plenty of free sockets and every socket goes to a central patch panel. I decided that a some of the sockets could be used for temperature sensors.

The sensors I chose are 1-Wire sensors. 1-Wire is a data bus developed and controlled by Dallas Semiconductor. There is one bus controller and the bus can have multiple devices. You can also have switches that can connect, under computer control, one of two downstream buses to the bus going back to the controller. Each device needs to be connected only to signal and ground. When activated the device uses an internal capacitor charged off the signal line as a power source. You can also supply a dedicated power line as well.

I purchased a USB bus controller, a 6 port 1-Wire switch and some DS18S20 temperature sensors. Using 4 conductor telephone wire crimped to RJ45 plugs and soldered to the sensors via a small piece of verostrip I assembled a sensor network. With a small ABS box and a heap of hot glue I also placed a sensor outside.
One tip when drilling a hole for the wire in a window frame is to make the outside hole lower than the one on the inside. This ensures the water doesn’t flow in during wet weather.

I attached the bus controller to my server and installed the owlfs software. Owlfs is an open source application for the USB bus controller that includes several interfaces including a web server and FUSE filesystem. I used the server interface that provides a network server with a custom protocol. There are command line tools to query the server. I used these commands from a munin script to graph the output.
Later I wrote a general purpose Java server that that averages the readings over time and presents the data through a text based network server. This Java server is extensible so that I can use it for energy monitoring and capture to a database. These developments are the topics for future posts.

1-Wire, electronics, project, temperature
Here is the parts list for the relay board, since I forgot to include it in my last post.
I could control the mains using a Triac and will probably try an experiment with that later. But using only components that I understand means a relay. So, following the excellent description on SparkFun you end up with a simple circuit with a NPN transistor that switches on the coil of a relay. The description on the SparkFun page also includes a LED so you can see when the relay is closed. I left that in on my copy.
The other feature to note is the diode that faces the wrong way across the coil of the relay. You’ll see this on a lot of designs. When the current across the coil is turned off the magnetic field collapses a very short time later and the switch springs back to the normally closed position. However as the magnetic field collapses the changing field causes a potential to be generated in the coil, in the opposite direction to the driving current. The diode ensures that this potential is harmlessly shorted out rather than frying the micro-controller.
So the schematic, copied from the SparkFun design is below.

Which can be nicely made into a little singe sided board like the one below.

I used one of the PCB track width calculators online and asked what width was required for 10 Amps. The answer 3.6mm so that’s what size the tracks are on the right. Another design feature is that the board has a low voltage side and a high voltage side. This is, after all, the whole point of using a relay and will be a feature of all the boards involving high voltage in this or any other project.
The coil seems to use about 135mW but only drawing a handful of milli-watts from the signal pin. Below is a (slightly moody) photo of the finished board.

electronics, mains control, project
The approach I’m going to take with this project is to design and build each part of the mains controller as independent circuits and evaluate / play with them. When I have them all hooked up in a way that works and that I’m happy with, then I can draw a schematic and board layout that beings them all together.
In order that my plug in mains controller doesn’t need an extra socket for the power supply I will need to design and build a power supply. Also the invasive power measurement technique that I intend to try out requires two independent power supplies.
As I mentioned in my previous post, a quick look online gives my a simple power supply circuit. Also transformers with two secondary windings are easy to find. This will mean that I have to build the same circuit twice attached to each of the secondary windings.
Below you can see a schematic. You can see that it’s actually two identical schematics. I’ve also added a little LED to each one as a power indicator.

The parts used for this are listed below (Linked numbers are Farnell part numbers).
- 1 × 9531297 Mini Toroidal Transformer, 1.6VA, 2 × 9V Secondary Windings.
- 2 × 1621776 Bridge Rectifier 1.5A.
- 4 × 9451200 470µF Capacitor 25V.
- 2 × 9666095 5V Voltage Regulator.
- 1 × 1357320 Screw Terminal Block, 4 Way.
- 2 × 1142517 3mm Red LED
- 2 × 9341102 1K Resistor
Next we lay out a board, print, etch, drill it and mount the components. The board layout is below.

A quick check with a multimeter shows that it’s producing 5 volts on both the outputs and that there is no shared ground since no potential difference is reported between 5 volts on DC1 and GND on DC2.
electronics, project
I’ve thought of a new project. I’m going to build a plugin controller for a mains power socket. This will replace the cheap ones that I have for the telly/AV gear in the living room, that turns off the playstation, mythTV PC, amp, sub-woofer and telly so nothing is on standby and the ones that are used in the study to stop the PCs on our desks using power when off.
So where to start? Let’s start with some requirements.
- It must be able to turn the mains on and off to a socket.
- It must be remote controlled
- It could measure the power used (Watt meter)
So I will need a relay or triac, radio, some controller and possibly some way of measuring power.
I’m going to tackle this project in 5 parts (which might change as I go along)
- Power supply. The controlling electronics is going to need a 5 volt supply. Rather than use another socket for a wall-wart I’ll need to build one from scratch.
- Micro-controller. It’ll need some brains. Since I have a bunch of Arduino Nano clones knocking around I’ll use them to start with and probably have an embedded Arduino compatible circuit in the end.
- Radio. There will need to be a radio for control and to report readings about power usage.
- Relay. To switch the mains on and off.
- Power sense. There are two ways I could do this, that I have found. More about that in a later post.
So I’m ready to start. First thing is to look on the Internet and find out what people have done before.
For controlling a relay the tutorial at SparkFun is excellent so that part should be easy. I found a site I’d bookmarked a long time ago called OpenEnergyMonitor that has done the sensing technology. They have two methods documented on their site for measuring power. The invasive method involves using a current sensing resistor and a potential divider directly across the mains and the non-invasive method uses a current transformer.
For the radio I could use XBee transceivers which are excellent but they’re expensive. I found what look to be nice FM transceivers on Farnell and will be trying those out. I also found a page that appears to detail somebodies attempt to use them with an Arduino (I’ll know more when I translate it into English).
The power supply should be simple. A transoformer, a bridge-recifier, a couple of caps and a voltage regulator should do the trick. Designs for these are all over the Internet such as this one on discovercircuits.com. For the invasive power meassurement design I will need two independent power supplies. I can do this easily enough by getting a transformer with two secondary windings and building the power supply circuit twice. More on that in a later post.
Well I’ve got a lot to be getting on with. So the next stage to make an order for components and start building.
electronics, mains control, project