I have a fairly simple circuit that works perfectly on the breadboard, but I am having a lot of trouble transferring it to a PCB. I am seeing very strange behavior which lies outside of my current experience, so I hope to get some advice.

The circuit implements a wifi motion sensor, although the problem I am having happens waaay before I get to the RF part, or even the uC part of the diagram: enter image description here

I have circled the part that is having trouble.

R3 is a pull-down resistor, which is required b/c AMN42121 drives the output HIGH when motion is detected, but leaves it hanging for no motion, so pull-down is needed.

I used C1 to smooth out the transition between motion and no motion. C1 makes the output level go to LOW slowly and smoothly, so "no motion" state is achieved after a few seconds of no motion.

Inverter is there b/c attiny's external interrupts are triggered by LOW level, so I need to invert the logic. It is unfortunate that I had to use such a large DIP package for one inverter, but I couldn't find anything else.

I have made a double-sided PCB for this circuit, which looks like this: enter image description here

Again, I have only assembled the circled area so far.

After soldering S1, R3 and C1, I get the following signal from sensor output: enter image description here

This is exactly what I want to see, so everything is fine up until this point.

Next I soldered in a socket for IC2 and plugged in the inverter. This is where mysteries begin. At first everything was fine, but after a while of messing with the board the circuit suddenly stopped working. When I place a probe on the sensor output, instead of the nice signal we saw above, I see variations on the following two examples:

Example 1: enter image description here

Example 2: enter image description here

Note that unlike the first example, the signal in the second example is not generated by motion - that saw tooth shape just emerges on it's own w/o any action from me.

After a lot of testing, I was able to establish the following:

  1. Unplugging the inverter from the socket makes the sensor work properly again.
  2. Cutting power to the inverter while leaving it plugged in makes the sensor work.
  3. Using a different inverter has no effect.
  4. Dousing the board with flux remover or acetone and scrubbing with a brush sometimes makes the sensor work again, but very briefly. At one point I was able to make the signal look like this by aggressively scrubbing with a toothbrush: enter image description here

Note that even in this last picture the signal is not returning to LOW level all the way. The effect went away almost as soon as I stopped brushing.

So far this points to some soldering defect, except that I really can't see the problem. I have gone over the board carefully with powerful magnification and tested all spots I could think of for continuity - everything checks out. Here is a closeup of the solder job on the IC socket and the sensor: enter image description here

I am now out of ideas, so any advice would be greatly appreciated. Thank you.


I have just discovered something interesting. A closer examination of example #2 (the saw-tooth shape signal) reveals that the downward slope is a segment of the expected C1 discharge curve. When voltage level gets close to the threshold of the inverter and spends too much time there, the inverter seems to be getting confused! It's generating that little burst of noise and then does something to kick the input back to HIGH, or simply hangs out in that "indeterminate" noisy state indefinitely until sensor output goes HIGH again b/c of motion (Example #1).

To test this theory I replaced C1 with a cap that is 10 times smaller, thus making the discharge curve much steeper and "voila!" - the inverter is no longer getting confused and the circuit works!

Of course, this defeats the purpose of C1, since it is now not providing as much delay as I want. I am not sure why I did not have this problem with the inverter on the breadboard, but it does suggest that there could be a very easy fix that can address this problem. I read that breadboards have a large "stray" capacitance, so perhaps I just need to strategically add some more capacitors somewhere? Any ideas?

EDIT 2: Providing a top view since some commenters asked for it: enter image description here

  • 1
    \$\begingroup\$ Holy bananas, those solder joints look terrible. You desperately need some flux there. \$\endgroup\$ Apr 17, 2013 at 6:13
  • \$\begingroup\$ @Connor Wolf: Are you referring to the IC pins that are not connected to anything? Those are barely soldered at all, b/c I saw no reason to solder them. Or are you talking about the other solder joints? \$\endgroup\$
    – Val Blant
    Apr 17, 2013 at 6:25
  • \$\begingroup\$ Why are you using an inverter at all? Connect the output of the sensor to PB2 with a series resistor of 220-470 ohms, and you are OK to go. You can add a pull down resistor, but 10Meg is way too high. Change it with a 10k. Also, you do not need to connect C1. You can do the filtering in the software with a simple delay routine. In addition to that, C1 may be adding load to the sensor so that when the inverter IC is connected, the load is too much that sensor cannot drive, perhaps? \$\endgroup\$ Apr 17, 2013 at 6:41
  • \$\begingroup\$ I have checked now and the sensor can give a maximum output of 100uA! Inverter demands about 1mA of input current! So, the above pull-down resistor I have suggested, which is 10k, is too much. Change it with a 330k or 470k \$\endgroup\$ Apr 17, 2013 at 6:44
  • \$\begingroup\$ @abdullah kahraman: I am sorry - I don't understand your idea. INT0 on attiny is triggered on transition to LOW, so "no motion" must be represented by HIGH input. Is that not right? Could you please explain your idea in more detail? \$\endgroup\$
    – Val Blant
    Apr 17, 2013 at 6:59

3 Answers 3


EDIT - because of my misinterpretation of the circuit I'm editing the answer to focus on the output of the sensor - are you using the analogue output to feed into the inverter - if you are maybe you should try a Schmitt trigger like a 74HC14

  • 1
    \$\begingroup\$ @ValBlant I'm no expert on the ATtiny dude - if you have established it has to be that polarity than so be it - what are the input signal levels into the inverter - could you but not applying proper logic levels - might you also need a schmidtt trigger inverter like 74HC14? \$\endgroup\$
    – Andy aka
    Apr 17, 2013 at 8:08
  • 1
    \$\begingroup\$ Maybe if you remove the cap and see what that looks like then, if necessary you can do something in the ATtiny code that keeps the circuit alive between transients? Did you put a 10n decoupler on the inverter as was suggested by someone earlier? \$\endgroup\$
    – Andy aka
    Apr 17, 2013 at 8:44
  • 1
    \$\begingroup\$ I think you'll need a Schmitt trigger dude - they can handle sloppy analogue slow rise times and fall times - that's what they are intended to do. Maybe your original circuit worked because of a fluke although there is always a good reason!! \$\endgroup\$
    – Andy aka
    Apr 17, 2013 at 9:00
  • 1
    \$\begingroup\$ @ValBlant Note the "input rise and fall time" specification on the TC74HC04 datasheet -- which specify the slowest input signals that are recommended (500ns rise/fall times at Vcc=4.5V). This is an easy spec to miss, especially as the Toshiba datasheet doesn't explicitly specify it as a maximum. \$\endgroup\$ Apr 17, 2013 at 14:04
  • 1
    \$\begingroup\$ Using an inverter with a Schmitt trigger solved my problem. \$\endgroup\$
    – Val Blant
    Apr 19, 2013 at 18:44

Without studying your circuit in great detail, the obvious thing is you have no decoupling capacitors.

Solder one across the power pins of each chip.

Also, your 'scrubbing makes it work' comment suggests you have a dry joint or intermittent connection somewhere. Inspect all your soldering carefully.

Regarding a DIL chip being overkill, you could have just used a transistor, and put the time delay stuff in software.

  • \$\begingroup\$ ok, just did some reading about what decoupling capacitors are. I am surprised that I'd need something like that to power an inverter, which is not a high speed device, but I'll definitely give it a try. Most sources suggest a ceramic 0.1uF cap across the power pins of the IC. I do not have any ceramic caps in that range, but I do have some electrolytics. Will that work, or do I absolutely need a ceramic for this? \$\endgroup\$
    – Val Blant
    Apr 17, 2013 at 6:35
  • \$\begingroup\$ In regards to the inverter, I actually started with a transistor at first, but later realized that a transistor inverter draws way too much power when it's open. My circuit must function at around 60uA (when not transmitting), which I was not able to achieve with a transistor, but the inverter IC seemed to do the job. \$\endgroup\$
    – Val Blant
    Apr 17, 2013 at 6:56
  • \$\begingroup\$ Just tried 0.1uF and 1uF electrolytics as decoupling caps with no change at all. However, I descovered something interesting which I think may be a hint. I'll update the main post with the new info. \$\endgroup\$
    – Val Blant
    Apr 17, 2013 at 7:01

Your main concern seems to be reducing power consumption.

The AMN42121 consumes about 50uA continuously. The 74HC04 consumes about 20uA continuously. The ATTINY85 consumes about 300uA intermittently, i.e.when woken up. The radio will use milliamps when it transmits.

How often will the sensor be triggered ?. Have you done any power calculations to estimate battery life ?.

I suggest you discard the invertor and 'slowing down' capacitor, wire the sensor direct to the MCU with a 10K pulldown as per the sensor datasheet, and write the time delay logic in the MCU.

[EDIT] Although you have got things a bit wrong, I am glad to see that you are testing your circuit a stage at a time. It's so much easier than trying to faultfind a completed project.

  • 1
    \$\begingroup\$ I don't see the need for an inverter either. The AVR has PCI - Pin Change Interrupts in addition to INT0/1. PCI detects a change in pin state whether it's HIGH or LOW. You can trigger on that and then add debouncing code. \$\endgroup\$
    – lyndon
    Apr 17, 2013 at 12:26
  • \$\begingroup\$ I think 74HC04 consumes a lot more than that. \$\endgroup\$ Apr 17, 2013 at 15:56
  • \$\begingroup\$ Doing a detailed battery life calculation and some algorithm analysis of the code in my uC shows that you guys are right - I am not winning much at all by using the inverter instead of the Pin Change interrupt. Was I to do it again, I'd do as you suggest. However, my battery life with the current circuit will be 270 days in the worst case, so I think I'll leave the design as is, use a Schmitt trigger on my inverter and move on to the next project. Thank you all! \$\endgroup\$
    – Val Blant
    Apr 18, 2013 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.