0
\$\begingroup\$

I build a standalone board for my ATMEGA328P-U chip according to this tutorial (which should be the same as this).

My schematic should look like this

enter image description here

On my real perfboard I have 2 GND lines and 2 5V lines (one pair on each side). I verified that these are 5.02 V.

Pin - Voltage

7 - 5.02V

20 - 5.02V

21 - 5.02V

19 - 0.558V

3 - 1.15V

4 - 1.15V

5 - LOW

All Pins that should connect to GND read a voltage near 0V.

Using the following code

int relayp1 = 1;  // LED on Pin 13 of Arduino
int relayp2 = 2;  // LED on Pin 13 of Arduino
int pirPin = 3; // Input for HC-S501
int LED = 19; // Input for HC-S501

int pirValue; // Place to store read PIR Value


void setup() {

  pinMode(relayp1, OUTPUT);
  pinMode(relayp2, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(pirPin, INPUT);

  digitalWrite(LED, HIGH);
  digitalWrite(relayp1, HIGH);
  digitalWrite(relayp2, HIGH);



}

void loop() {
  pirValue = digitalRead(pirPin);

  if (pirValue == HIGH)
{
  digitalWrite(relayp1, LOW);
  digitalWrite(relayp2, LOW);

  delay(120000);

  digitalWrite(relayp1, HIGH);
  digitalWrite(relayp2, HIGH);
}
else
{
  //Safe! Continue usual tasks...
}

}

Not shown in the schematic, I use a HC-SR501 PIR motion detector which is connected to Pin 5 (D3). Pin 3 and 4 are connected to a relay.

The setup does work on the breadboard, using power directly from my arduino uno clone.

The standalone board is powered by a 12V, 1.5A power supply.

As you can see, the output voltages are too low. Besides that, the LED is not powered. I uploaded another sketch, that should switch Pin 3 and 4 HIGH for 5s and LOW for 5s.

int relayp1 = 1;  // LED on Pin 13 of Arduino
int relayp2 = 2;  // LED on Pin 13 of Arduino
int pirPin = 3; // Input for HC-S501
int LED = 19; // Input for HC-S501

int pirValue; // Place to store read PIR Value


void setup() {

  pinMode(relayp1, OUTPUT);
  pinMode(relayp2, OUTPUT);



}

void loop() {

  digitalWrite(relayp1, LOW);
  digitalWrite(relayp2, LOW);

  delay(5000);

  digitalWrite(relayp1, HIGH);
  digitalWrite(relayp2, HIGH);
  delay(5000);
}

Ignore the female PIN headers.

enter image description here enter image description here

I measure 1.15V still. So I assume the chip is not properly working on the breadboard. Any ideas what to check next?

\$\endgroup\$
  • 1
    \$\begingroup\$ It's likely that the lack of a flyback diode made the relay fry the microcontroller. \$\endgroup\$ – CL. Feb 25 '18 at 14:38
  • 1
    \$\begingroup\$ What voltage do you read if relay (relays) disconnected? In other words, perhaps the relay is loading down the output pins. \$\endgroup\$ – Marla Feb 25 '18 at 14:50
  • 2
    \$\begingroup\$ In this circuit, the 1N4001 is not a flyback diode. And the µC is quite robust; it's possible to fry only the output drivers of a single pin. \$\endgroup\$ – CL. Feb 25 '18 at 14:54
  • 1
    \$\begingroup\$ According to your schematic the 7805 GND pin is not connected to ground? You should also include the PIR sensor and the relay for completeness. The map should match the terrain. Have you checked the current requirement of the relay and compared it to the current capacity of the ATMega pins? \$\endgroup\$ – Dampmaskin Feb 25 '18 at 15:02
  • 2
    \$\begingroup\$ "Google says the pins supply 40mA" - That's a misinterpretation. The 328P datasheets lists 40mA as the absolute maximum rating for GPIO DC current. That doesn't mean it can provide 40mA or that it is limited at 40mA. Instead, it means that you as a designer must ensure the current stays below 40mA at all times. If you mis-design and allow currents above 40mA to flow, the chip may break. \$\endgroup\$ – marcelm Feb 25 '18 at 19:46
0
\$\begingroup\$

I finally figured out why the circuit did not work. At least I got my LED flashing, I'll have to see how it handles the relay.

The crystal was not connected to the µC, see the picture. I have no idea how this got past me as I created the schematic with the board at hand and not from the tutorial.

enter image description here

I am still very grateful for the inputs regarding:

Flyback Diodes

ULN2x03 (To my understanding this should also solve the problem of the output current of the atmega, I already purchased one and will use it on my next project)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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