May 12 2017

Let’s combine a cheap wireless doorbell with a century-old phone

By Max

We recently (ish) moved into a new place, a big old victorian in the Haight.   There was no doorbell for our unit, so we did what you do and bought whatever the first result was for ‘wireless doorbell’ on Amazon.   About the same time, the Rents were doing some spring cleaning and gave me the wall phone above, because I guess they didn’t need it anymore.  Which raises but does not answer the question of why they needed it in the first place.  So when I have a few drinks and buy random technological artifacts on eBay, there might be some precedent for that.  Anyway, the preset ringtones on the doorbell were pretty hideous, and I thought why not class it up and make the phone ring when someone presses the doorbell instead?

If you want the YouTube video version of this, that’s here.

The Phone: This is probably 1915 or so.  The case is oak, the metal parts are brass.  You would ‘dial’ by clicking the receiver hook up and down which would summon a human operator, who would connect your call for you.

In the upper compartment on the right is a hand crank you would use to generate the voltage to send your voice back to the phone company.  Unfortunately that dynamo part is long gone, but the hand crank is visible on the right side.  In the lower compartment, clockwise from bottom left, is the Arduino, the wireless receiver from the doorbell, the high voltage circuit, and some perfboard to tie everything together.

For the high voltage circuit, I found this circuit on the Sparkfun site, which they were nice enough to open-source.   There’s a boost converter that kicks the 5V up to about 55V, and an H-bridge that allows you to switch the direction of the voltage through the solenoid.  I built the circuit and it worked, although if I was doing it again I might have gone for something that did the full 90V–  The ring could be a little more musical, and I think that might be because the clapper doesn’t have enough oomph to strike the bell cleanly.  On the other hand, it’s plenty loud as it is.    Here’s the circuit:

I also wired up the handset piece to play a dialtone when you pick it up off the hook.   Which has a practical purpose in confirming the processor is up and running, but mainly for fun.

The Doorbell: I opened up the receiver unit.   I was expecting to have to kind of kludge together the entire doorbell with the ringer circuit, but I noticed that the RF part of the board is a separate unit and just soldered onto the main logic board (at top):

The receiver circuit appears to be a buyout, which is ideal assuming I can figure out what the communication protocol is.  I did a search for the IC number, PT4303, and found a datasheet which told me it’s just a heterodyne, i.e. it’s just amplifying the signal to be decoded elsewhere.  Also that the chip is 5V tolerant, which is very convenient as I wanted to run this whole thing off a USB charger.

I hooked the receiver up to the oscilloscope and started poking at the transmitter while pressing the doorbell switch.   And found a digital signal on one of the transmitter pins (yellow), which was also showing up on the receiver data line (blue).   Bingo:

On the left is random noise, but as soon as I hit that button there’s a repeated digital pattern.   The pattern is either long-short (0) or short-long (1), in my case as you can see above the code was 00010011110010000.

For power, I wanted to use the vintage-style cloth-wrapped cable, but I also wanted to power it off USB.   I grafted a USB cable onto it and used the charger for my prior phone.

The Code: I used this library (that link does a good job of explaining the signal), although my timings were different so I guess there are slight differences in model.   If you want my arduino sketch (which includes the code to ring the phone and also generate a dial tone signal when the receiver is up) and also my Eagle file that’s here.

Here’s a video walkthrough I did.   Sorry if the camera work/narration is not the best.

If you enjoyed this or found it useful, be sure to leave a comment below.  Thanks for reading!


Jun 1 2014

Breadboard-friendly i2c logic level converter

By Max

IMG_20140531_222803 (2)Lately I’ve been using my 5V Arduino in concert with 3.3V devices via i2c, and so I’ve found myself requiring an interface part to convert the two logic levels.

I had previously done this on the breadboard with two 2N7000 MOS-FETs according to this Philips application note AN97055:

i2c Logic Level Shifter Schematic

This worked, but it was a lot of parts to set up on the breadboard each time, and I wanted something hardwired so that I could focus on other things when it came time to troubleshoot.  So I cooked up this little guy:

IMG_20140601_134500~2

Testing the waveform with an oscilliscope, you can see some noise is introduced on Channel 1, but I always wonder in these cases how much of that is just because I have a bunch of probes stuck everywhere– the act of measuring changes the measured behavior and so on.  But, it should be perfectly adequate for prototyping purposes.

i2c SCL line

5V signal in blue (channel 2). Resulting 3.3V signal in yellow.

Downloads:

If you’d like my Eagle files to incorporate this into your file, 3V to 5V i2c Eagle Files.

A pdf ready to etch is here: 3V to 5V i2c Eagle Files Level Shifter Rev0.

One note: if you look at the pictures of the finished product, you’ll see that rather than the usual way of doing things where you put the PCB on the bottom plane, then drill through and put the components on top, I’ve instead mirrored the layout, and soldered the components on the top plane.

 I did that so that I could solder the pin headers on top, as you can’t solder them to the bottom traces because the plastic connectors get in the way.  If you download the pdf I linked to, it’s already been flipped and is ready to go.  If you download the eagle files, make sure you select “mirror” from the print options.

Hope it comes in useful for you!

 


Nov 18 2012

Interfacing the Arduino to the Taos TCS3414 via I2C, continued

By Max

Taos TCS3414

November, so soon!  I kind of had to put this one down for awhile and work on things that were not laptop-centric, I just was spending too much time in front of a computer screen.  Luckily, Tiuri De Jong was on the case, and he has developed the proof-of-concept code I posted earlier into a fully-working demonstration.

I uploaded it to my Arduino, and I’m getting stable results with an apparently linear response, although the specific numerical values themselves aren’t particularly meaningful.    For example, under my workbench lamp that I metered at about 40fc and has a CCT of 5000K, it measured 290fc at 3500K.  I get that the part would require calibration before it would be useful, but it’s strange to me that it would be off by 1500K color temperature and a factor of 5 for illuminance, out of the box?  I’d be interested to know if anyone else has a similar experience.

What I’m working on now is measuring the values given by the TCS3414 vs. a known accurate illuminance and color temperature meter, to tell if the deviation from true value is a constant, or a linear function, or what.  I’ve verified that the calculations are done correctly in the code per the datasheet.

But in the meantime, it seems like a shame to deprive everyone else of Tiuri De Jong’s complete and, might I add, lucidly written code, so it may be downloaded here:

2012-11-18 Light Meter Code Rev5

I’ve also posted the code in full after the jump.

Continue reading “Interfacing the Arduino to the Taos TCS3414 via I2C, continued” »


Jun 7 2012

Interfacing the Arduino to the Taos TCS3414 via I2C

By Max

Well, this was a productive night:  I’ve been working with the Taos TCS3414, which is a light and RGB color sensor.  It’s a tiny little guy, about 2.5 x 3.5 mm I would guess, and shown above is mounted on breakout boards.  I just had a breakthrough night with it, getting it to correctly return values from the sensors, so I thought I’d share my preliminary code for the benefit of all.

Update: better code here!

Helpful tips:

  • The TCS3414 is I2C, whereas the TCS3404 uses the similar SMBus.  The Atmega 328 can do both, but I2C is easier for reasons of both hardware and libraries, so get the TCS3414.
  • I2C is on analog pins 4 and 5, not digital pins 4 and 5.
  • It’s a 3.3V device, so make sure you power it via the 3V output on the Arduino, not the 5V output.  It draws 9ma max, so the 50ma capacity via Arduino is plenty.
  • Similarly, you’ll need to level shift 5V bidirectionally to 3V from the Arduino to the sensor, so google logic level converters.  I used a pair of NTE491 MOSFETs.

Here’s what my hardware looks like (note, my breakout board pins aren’t the same layout as the sensor):

That all being said, here’s my (working concept only) code!:

// 6 June 2012

#include

int ledPin = 13; // LED connected to digital pin 13

byte receivedVal = 0x00;

unsigned int clearLow = 0;
unsigned int clearHigh = 0;

void setup()
{
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);

// join i2c bus (address optional for master)
Wire.begin();

Serial.begin(9600);
Serial.write("Serial started" "\n");

digitalWrite(ledPin, HIGH); // set the LED on

Wire.beginTransmission(0x39);
Wire.write(0x80);
Wire.write(0x03); // Turn the device on and enable ADC
Wire.endTransmission();

Wire.beginTransmission(0x39); // Request confirmation
Wire.requestFrom(0x39,1);
receivedVal = Wire.read();
Wire.endTransmission();

if (receivedVal == 0x03) {
Serial.write("ADC Started" "\n");
}
else {
Serial.write("Connect to sensor failed with code: ");
Serial.println(receivedVal, DEC);
}

delay(50); // wait for a moment to allow ADC to initialize
digitalWrite(ledPin, LOW); // set the LED off
}

void loop() {
Wire.beginTransmission(0x39);
Wire.write(0xB8);
Wire.endTransmission();

Wire.beginTransmission(0x39); // Request confirmation
Wire.requestFrom(0x39,2);
clearLow = Wire.read();
clearHigh = Wire.read();
Wire.endTransmission();

clearHigh = (clearHigh * 256) + clearLow;

Serial.println(clearHigh, DEC);

delay(500);
}

If you’ve done it right, it should start spitting out meaningless numbers, that decrease when you hold your hand over the sensor!  More to come on this topic soon!


Jun 15 2011

Electricity Quick Reference Cards

By Max

These are some quick reference guides I made for my dad, for Christmas.  I am posting it now because June is the next month after December, clearly.  So my dad has been hampered in working on his classic cars and rental properties with their myriad electrical problems because he’s never been exposed to the fundamentals of electricity.  I figured that what he needed in lieu of a formal physics course was a quick reference that he could refer to as needed. Continue reading “Electricity Quick Reference Cards” »