Thursday, April 28, 2016

Solar Swiss Army Knife

Over the past month or so I built an  ESP-8266 based "Solar Swiss Army Knife".

It's primary purpose is to measure the soil moisture, and turn on a valve to water my garden when the soil is dry.

Since it's solar powered, the only connection needed is to the garden hose.

Soil moisture is detected by measuring the AC resistance across a probe stuck in the soil. An AC square wave is made with a 555 timer. Using AC eliminates the galvanic reaction a DC probe would have.

Watering is controlled by a pulse valve driven by an  H-bridge. A pulse valve uses no current when in the open or the closed position so it's perfect for a solar powered project.

A parameter file is read from a micro SD card and sets the watering parameters. Watering parameters include the soil moisture to trigger watering, minimum time watering, and watering hours. The file also provides the network credentials needed to connect to WiFi and the Sparkfun IOT site.

When the  device connects, it gets the time from the NTP server and sets the RTC. It then gets its readings and controls the valve if necessary. Finally, it sends watering and battery status to an IOT site where I can monitor its activity. You can see the data it sends here.

A MOSFET output is provided if I want to control something that needs high current.

A 2000 mAh LiPo is used. To save power, it sleeps for 4 minutes and wakes only to check if the soil needs water and send it's data.

In order to supply all the necessary I/Os, the board uses an I2C GPIO (PCF8574) for 8 additional I/O and I2C ADC/DAC (PCF8591) for 4 analog in and 1 analog out.

To make the build easier I used SMD components and off the shelf modules. The modules used are:
  • Adafruit solar charger - It's worth having a good solar charger. The solar cell is also from AdaFruit.
  • Pololu H-Bridge - Used to reverse polarity to turn pulse valve on and off.
  • LiPo Fuel Gauge - Measures battery voltage and state of charge (SOC). Knock-offs are also available on eBay.
  • Current Sensor - (eBay) Measures the current to and from the battery
  • SD card module - (eBay) 
  • RTC module - (eBay)  
  • Pulse Valve - (eBay) Garden hose in, drip watering system out.

Schematic of the board ...

Wiring diagram . . .

PCB board layout ...

I have some boards available for this project.If you're interested contact me.

Sunday, November 22, 2015

Network Control of X10 - take 2

I posted an earlier version of this, but it was based on the Atmega328 and an Ethernet module.

This version is based on the ESP8266 which provides the microprocessor and connection to the network via WiFi.

I've been having a ball with the ESP8266. It's cheap, programs with the Arduino IDE, and it just works. I've already created a product with it that connects my Geiger Kits to the internet.

So what is it?
The ESP8266 puts up a webpage (like the above) on your local network. The page has buttons for the X10 devices that you want to control. When a button is pressed the ESP8266 drives a CM17A and turns your device on or off. The page also displays any sensor readings that are connected to the ESP8266. So if you are into X10 home automation, this is a cool gadget.

Hardware-wise it's an ESP12 variant of the ESP8266. It's connected to the CM17A through a level shifter. The level shifter is needed because the ESP8266 is a 3.3V device and the CM17A requires 5V to operate. (Since the CM17A is powered by the difference between RTS and DTR strong pullup resistors must be used on the high side - 330Ω.)

You can also attach an I2C OLED display to the ESP8266 which will show the X10 commands that were received.

Here is the complete setup. I used the ESP8266 development board I created for the GK-WiFi kit (available here).

The software is finished (as far as I'm concerned) and is available here.

Friday, January 30, 2015

Life Clock - Redo

I created the Life Clock in 2008. Originally it was a "3 board stack"  with one being ATmega, RTC, and EEPROM and another with the MAX7221 chips that the bicolored matrix plugs into.

I really liked how it came out, but I thought I'd update it and add some features.

During that process I discovered a great little bicolor matrix kit from Jollifactory which provides the led matrix and a driver board. It's well priced, and really simplifies construction.

The matrix kit is available on Tindie here and shown below. It's  especially nice that multiple matrices can be chained together to make a larger display. If you're interested in led matrix projects it's a good way to go.

I then made a new PCB to hold the ATmega, RTC, EEPROM, piezo and IR sensor. It stacks on one of the Jollifactory matrix boards and provides a complete Life Clock. More matrices can be added if desired. The PCB looks like this:

A kit is now available here and also on Tindie .

Below is a video showing the current LifeClock software on 1-3 Jollifactory matrices.

The new software supports from 1 to at least, 4 Jollifactory matrices. The original LedControl library was modified to use hardware SPI instead of shiftout. This much faster lib is necessary if multiple matrices are used. As shown in the video, the LifeClock now has the following features:
  • Displays the time, hourly chime, alarm, and auto DST set.
  • Plays Conway's Game of Life in 3 colors.
  • Shows the phase of the moon, days to next full moon, and name of full moon.
  • Displays the time of sunrise and sunset.
  • Displays reminders for birthdays, etc.
  • Time setting controlled by a NEC mini-remote.
  • Optionally, a GPS can be added to sync the time automatically.
  • Fonts, messages, and reminders stored in external EEPROM.
[7/1/15 update] A more affordable "mini" version of the Life Clock is now available here.  It uses smaller single color matrix displays .

Saturday, January 24, 2015

Network Control of X10

I really love remote control!
This project allows you to control your X10 devices from any web browser.

The Arduino is used as a web server which puts up a page with controls for House Code, Unit Code, and Command. 

(click on screenshot of Gort to see the page)

The response is sent back to the Arduino which sends out the X10 commands wirelessly through the CM17A module.

So far it's just on my local network but it appears to be working pretty well.

Still a few things I'd like to change, but the current  Arduino source code is available here.

Wednesday, October 12, 2011

Solar Powered Wireless Radiation Monitor

Like the Geiger Kit in the previous post, this project is going to get too big to properly handle in a blog format.

So it's introduced here, but the function and build details are posted on this website.

Listening to what people want in the way of radiation detection, it appeared that there are 3 types of needs:
1.       a portable device that gives instant readings - the classic Geiger Counter
2.       a portable device that logs readings, and maybe location
3.       a stationary monitoring device that is always displaying, and logging readings

I think I’ve covered the first two with the Geiger Kit and the Geiger Logging Shield. So this project is intended to cover the 3rd need - a stationary monitoring device.

The idea is simple – a box outside with a Geiger counter and radio transceiver (solar powered as an option) talking wirelessly to a box inside with a display and an SD card.

the outside piece . . .

the outside piece outside . . .

the inside piece . . .

Again, you can find all the details on this website. However, I'd appreciate any comments you'd like to leave here.

Wednesday, March 23, 2011

Geiger Counter Kit - Part 3

Please visit this web site if you want to purchase or learn more about the Geiger kit I am offering. 

I'll leave the pics and video here, but you'll find all the details about the kit through the link above. However, you can leave a comment here if you like.

Geiger Kit PCB  . . .

The video below is a bit dated, but gives a pretty good introduction

Monday, February 14, 2011

Accelerometer & Compass

No, it's not a B/W TV from the 50's. However Felix the Cat was one of the very first images transmitted to a TV screen.

I wanted to mess around with an accelerometer and this is what I came up with - before getting waylaid making Geiger Counter Kits.

From the beginning, I have to say that this was one of the most frustrating projects I've ever worked on. I consider myself a "completer" but several times, I had the desire to just dump the damn thing in a box, and say to hell with it. I'll try to spare the details of that side of the project.

I had a few goals in mind:
  • to learn about accelerometer and compass modules
  • to make a LiPo battery operated project
  • to use a graphic LCD and a menu system
  • and maybe make something I could put in my car
Lets start with the battery side of the thing. I wanted to be able to charge the LiPo, and I also wanted a constant 3.3V for Vcc and the Aref voltage. For the LiPo charger I used a MAX1555 wired per the datasheet.

Since the voltage on a LiPo can vary on both sides of 3.3V (3.0-3.7V), I decided I needed a "buck-boost regulating charge pump". (It's possible I didn't need one, but the name was so cool . . ..) I discovered the MAX1759 and also wired it per the datasheet. Soldering the tiny uMax package to a piece of proto board was an exercise in tedium.

I didn't want a toggle or slide power switch. I wanted a push button On/Off and I also wanted to automatically power it off from the uC if there was no movement for awhile. And of course, I didn't want to use much power to monitor the switch when the power was off. The solution was the Pololu Pushbutton Power Switch - it does all those things. I am working on a homemade version of this switch using an ATtiny85 that I will post here soon.  I added an ATmega328, with all pins broken out, and LCD and FTDI connectors.

At last! A shield that actually looks like a shield! This round board fits over this square board. After cutting two notches in it to access the LCD and FTDI connectors it was actually fit for a Gladiator - at least until I added the HMC6352 compass (I2C), MMA7361 accelerometer (analog) and DS1621 temperature sensor (I2C).

Finally, the graphic LCD and joystick. After a few flaky Nokia cell phone faceplates, I got a less flaky version of the Nokia 5110 graphic LCD. For the joystick I used a neat trick I learned from nuelectronics that switches resistors with the joystick so the 5 positions can be sensed by only one analogue input.

A wise man once told me "a project is only as good as it's case". (Actually no one told me that.) Long ago, I made a faceplate out of copper clad PCB board. Why not a whole case? 3D soldering! I also had some vintage phenolic board and some copper foil. I cut the copper clad board and mitered the edges. I soldered the box up from the inside. It solders very well. (I cranked up the iron to 425C.) I used the copper foil to attach and solder the phenolic board on the bottom. In a lot of ways, the case was the most rewarding part of the project. If there's anything worth learning here, this technique might be it.

So that's the hardware side. I'm less proud of the software side. I discovered that coding for the accelerometer and compass quickly make you wish you didn't sleep on your desk during geometry. In addition there's the low pass filtering, running average and . . . the dreaded Kalman filter (actually I didn't use one). I'll post the code at the end here, but if your smart, you won't download it. The menu system is sorta nice though. I got the basis from nuelectronics. I also wrote some simple graphic utilities.

Functionally - well, it needs some work, but he's a rundown of the screens . . .

The main menu . . .
(The accelerometer screen is boring. So is Debug.) The calibrate screen calibrates the compass - 2 revolutions in 20sec.

The compass screen shows degrees and ordinals.
There is also a temperature display.

The performance screen shows acceleration (right of center) and deceleration (left of center.)
The line through the bar sticks at the max recorded.

The roll and pitch screen shows, you know what.

Here's the sketch.

Saturday, January 22, 2011

X10 Remote Temperature - Redo

I became interested in the ATtiny85 processor recently. Up till now, my projects were based on the ATmega328 or the ATmega644. The  ATtiny85 is just that, tiny - only 8 pins vs. 28 on the ATmega328. The photo on the left shows the new  X10 temperature transmitter, with the DS1621 temperature chip on the left and the ATtiny85 on the right.
(The CM17A X10 RF transmitter is not shown.)

This board replaces what I had in the original X10 Wireless Temperature Transmitter which I've been using for the past year and a half.  (post is here)

So why the redo? The rational part of the answer is that I wanted the batteries to last longer.

The original temperature transmitter drew a whopping 2.2mA while in sleep mode. It was powered by 2 NiMH AA batts stepped up to 5V with a boost inverter. I'd change the batteries every month or so.

The redo board draws about .07mA while in sleep mode. It's running directly on 4 NiMH AA batts.  I'm guessing I'll change the batteries every 1.5 years or so. I choose AA batts over a 3.7V LiPo because it's easier to replace the NiMH batts with fresh ones, and I wanted the higher voltage for better range on the X10 transmitter. However, it's worth noting that the processor draws less current at lower voltages.

Most of the power savings can not be attributed to using the ATtiny, however. Along the way, I discovered a few things.

The first had to do with how I was reading the temperature on the DS1621. I was using "continuous mode" (most examples use this mode) which would give me a reading as soon as I asked for it, but at the cost of almost 1mA! I switched to "one-shot" mode which makes me wait ~750ms for a reading, but at a huge savings.

The second thing I found is that the CM17A library I made left the RTS & DTR lines high after transmitting. Setting them low, results in about a .5mA savings. Note that if you are using this lib and want to try it, be sure to give a nice delay before transmitting after you set the lines high. (There's always a trade off!)

I always use sleep mode for the lowest power usage when not transmitting. It's set to transmit about once every 6 minutes. There are several sleep mode routines for the ATmega processors, but the ATtiny needs entirely different registers set. I found good info on sleep mode, and good tutorials for the ATtiny at and Inside Gadgets.

The way to do the things mentioned above will be much clearer when you look at the the example code, which will be provided later in this post. But now, I would like to describe how to go about using the Arduino environment to work with the ATtiny85 chip, and most of all, how to get I2C working on them so you can communicate with the DS1621, real time clocks, and even 2x16 displays - all with an 8 pin chip!

The first thing you must do is to get the ATtiny "core files" for the Arduino environment. There are several out there - each supporting more or less of the standard Arduino features. Core files, and instructions on how to get started with the Tiny85 can be found here, however, I prefer the core files from here.

You can use the ArduinoISP as a way of downloading the sketch into the ATtiny. I've used it and it works fine - just be sure to disable the automatic reboot after load! For me, an easy way to do that is to use a serial cable instead of the USB cable. However, there are other ways to do it. Keep in mind, you only need to hit reset when you load the ArduinoISP on to your Arduino. Once it's an ISP, change the Board type to ATTiny85, and just hit "Upload" (don't press "reset"). After you work with the ArduinoISP a while, I think you will want a real ISP Programmer to load the ATtiny. They are cheap and much easier!

Finally, get at least the TinyWireM "master" library for this project. I made a Playground article that explains this library and has a link to download it. The Playground article is here.

OK, almost done. To get the source code for the new X10 Remote Temperature Transmitter, you can download it here. (a new version as of 3/13/11)

 [1/18/15] You can get a schematic for this project here.

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 posted by Dave Houston.

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.
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 . . .

Wednesday, December 9, 2009

Telephone Interface (updated 12/30/09)

This project describes an Arduino/MCU interface to a telephone land-line. It's only been tested on a US version of the telephone system, but hopefully it will apply to the phone system in other countries.

The basic idea was to allow the MCU to make calls by transmitting DTMF tones, and to receive and decode DTMF tones (keystrokes) made on the phone that was called.

There are other possibilities however. Using the complete interface, it should be possible for the MCU to answer calls, and to transmit "room sounds" picked up by a microphone to the other phone.

If you're only interested in sending and receiving DTMF tones and not interfacing to a phone line, you can skip the next dozen or so paragraphs. The schematics and code samples will still apply. 

It all begins with the interface to the actual telephone line. Unfortunately this is trickiest part!

There are two reasons for this:
  1. Phone lines require a 600 Ohm "balanced line". You can't just slap any old circuit between your "TIP" and "Ring".
  2. It's illegal!

Lets start with #2. Here I'm speaking from a US and Canadian perspective, but I'm sure it's similar in many countries. In the US, it's FCC Part 68 that makes it illegal to connect any unapproved device across your phone lines. So what can they do? Well, I'm sure it's much worse than tearing off that tag on your mattress.  I've read that if you create a problem that must be investigated by the phone company, and it's due to a little circuit you whipped together - your financially liable to cover the cost of the phone companies time. And it's relatively easy to do horrible things to your phone line during the process of creating an interface, and that leads to point #1.

When you Google "phone interface" you'll be drinking from a fire hose of circuits, methods, and projects. I spent a lot of time researching them, and did indeed come up with an interface that "worked". However, what I ended up with, struck me as being sensitive to component values, and somewhat "fragile". By this I mean, for example, that the correct "polarity" for TIP and RING was required. Given that the line should be "balanced" I felt like I disturbed the balance of the force. In short, after all of my experience with electronics, I felt like I was over my head with the interface I came up with. Ironic considering you're dealing with a system that has been around for so long.

For those who want to ignore points 1 & 2 above, here are some of the best resources I found, as well as the schematic for the "working" interface I was using. Big disclaimer here! I do not recommend building your own unapproved interface. Furthermore, I am not responsible for anything you do with any information I am providing. Everything here you use at your own risk.

Some of the telephone interface links I found helpful are:
Just looking at the variety of this information should give you an idea what your up against when rolling your own POTS interface. The interface that I tried is here.

Not a very encouraging beginning is it?

Enter the "Direct Access ArrangementDAA. This little module is an FCC Part 68 approved interface. Does it make everything OK? I don't think so - it really just makes it a lot easier for you to get your device FCC approved. Will it give you peace of mind? You bet. After switching to a DAA, the TIP and RING polarity did not matter, and everything seems to be much more solid - calls go through 100% of the time. The DAA also saves you from buying an isolation transformer, relay, transistor, and a large capacitor.

The problem is getting your hands on one without having to special order 54 of them from Mouser, etc. After a lot of searching, the best deal I found, for my use, was for a Cermetek CH1817-LM (discontinued) on eBay - here. It will cost you $15-$18 shipped.

Note: If your interested in capturing caller ID, I don't think this is the DAA for you. However, while searching I did see some that will output CID. I also ran across the Holtek HT9032C which looks like an interesting CID chip, but they seem to be hard to find.

Sorry if the above was long and detailed. I wrote it in the interest of saving you a lot of time. However, as always, YMMV.

Once connected to the phone line, I wanted to do several things:
  • Have the Nex10 dial my cell when an event ("macro") was triggered.
  • Leave a message - a series of beeps.
  • Optionally be able to listen in on the room noise from the called phone. (work in progress)
  • Capture any key presses I made from my cell. (Not sure how I want to use this yet.)
Note that currently all the communication is initiated by the Nex10. In fact, it is possible to use the RI (ring indicator) on the DAA to answer calls with the Nex10. (No plans yet for this.)

To do the things above, I used 2 chips from Holtek - an HT9200B DTMF generator to dial the call, and a HT9170B DTMF receiver to read the key presses once connected. Both are less than 70¢ each at Futurlec.

I wired both chips per the datasheets and ran the HT9240B in serial mode. Here is my schematic and an Arduino example sketch for the project at that point.

I could have stopped there, but even with serial mode, the interface to the MCU required 8 pins + power. I also want the Nex10 to accept "plug-in modules" - so an I2C interface seemed like the way to go.

I picked the PCF8574 I2C GPIO chip to go between the MCU and the DTMF chips. It's also available at Futurlec and is also wired per the datasheet. (Note: the PCA8574 is a newer version and runs at the faster I2C speed but was not carried by Futurlec.)

Both the DTMF receiver and the I2C GPIO have a nice feature that sets an interrupt line when new data is received. I wanted to use the INT line on the GPIO. However, because the DTMF receiver latches it's output, there was no easy way to read multiple presses of the same key. So, I am currently using the interrupt on the DTMF receiver (DV). Either way an external interrupt is triggered when new tones are received. This saves me from having to poll for changes.

Using the I2C GPIO with the interrupt line saves 5 pins on the MCU. Here is the current schematic and Eagle files. And here is the current example sketch for the completed project using the DAA, DTMF, and GPIO.

The short movie below describes the state of the project before adding the GPIO. (Looks the same now - only less wires to the Arduino.)