Electronics > Microcontrollers

Need help with a schematic

(1/14) > >>

gkraniske:
Hello All  :)

This is my first post so please be gentle.  For about a year I have been working on a garage door opener that works via bluetooth.  It actually works well but I found that it gets pretty toasty inside the box, so I added a small fan.  7 volts seems to run it well. However, when I integrated it into my design, it didn't turn on at all.  I checked the fan by applying 7 volts to it and it works fine.  There's the overview.

Now a little bit more in depth.  This garage door opener (GDO) has a MASTER unit, as well as a SLAVE unit.  Both are controlled by separate Arduino Uno's.  Here's my code;


--- Code: ---#include <TimerOne.h>
#include <SoftwareSerial.h>

#define pirPin 3
#define redLed 6
#define greenLed 9
#define blueLed 10
#define GarSwitch 4
#define GarRelay1 5
#define GarRelay2 11
#define Fan 12
#define ldrPin A0
#define tempPin A1

int garageState = 0;
int lastGarageState = 0;
int pirVal;
int LDRValue = 0;

char ch;
String HC05_Awake = "ON";

SoftwareSerial mySerial(7, 8);  // Rx | Tx

void setup() {

  Timer1.initialize(40000000);
  Timer1.attachInterrupt(KeepAlive);
  Serial.begin(115200);
  mySerial.begin(38400);
  mySerial.print('a');

  pinMode(GarSwitch, INPUT_PULLUP);
  lastGarageState = digitalRead(GarSwitch);

  pinMode(GarRelay1, OUTPUT);
  pinMode(GarRelay2, OUTPUT);
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(Fan, OUTPUT);
  pinMode(ldrPin, INPUT);
  pinMode(pirPin, INPUT);
  pinMode(tempPin, INPUT);
  digitalWrite(redLed, LOW);
  digitalWrite(greenLed, LOW);
  digitalWrite(blueLed, LOW);
  digitalWrite(GarRelay1, HIGH);
  digitalWrite(GarRelay2, HIGH);
  digitalWrite(greenLed, HIGH);
  digitalWrite(Fan, HIGH);
}

int counter;

void loop() {

  // Sending
  // read input once
 
  garageState = digitalRead(GarSwitch);  // LOW = pressed
  if (garageState != lastGarageState) {
    mySerial.print('a');
    if (garageState == LOW) {  // switch got pressed

      Serial.print(counter);
      counter++;
      Serial.println(" Print an 'a'");

      mySerial.print('a');

      digitalWrite(blueLed, LOW);
      digitalWrite(redLed, LOW);
      digitalWrite(greenLed, HIGH);
     } else {  // switch got released

      Serial.print(counter);
      counter++;
      Serial.println(" Print a 'c'");

      mySerial.print('c');

      digitalWrite(blueLed, LOW);
      digitalWrite(greenLed, LOW);
      digitalWrite(redLed, HIGH);
    }
  }
MotionDetection();
// LDR();

// Receiving
  if (mySerial.available()) {
    char ch = mySerial.read();
    Serial.write(ch);

    if (ch == 'b') {
      Serial.print(counter);
      counter++;
      Serial.println(" Print a 'b'");
      mySerial.print('b');
      digitalWrite(GarRelay1, LOW);
      digitalWrite(blueLed, HIGH);
      digitalWrite(redLed, LOW);
      digitalWrite(greenLed, LOW);
      delay(1000);
      } else if (ch == 'd') {
        Serial.print(counter);
        counter++;
        Serial.println(" Print a 'd'");
        mySerial.print('d');
        digitalWrite(blueLed, LOW);
        digitalWrite(redLed, HIGH);
        digitalWrite(greenLed, LOW);
        digitalWrite(GarRelay1, HIGH);
      }
    }
    lastGarageState = garageState;
    delay(20);  // poor man's debouncing
  }


void KeepAlive() {
  if (HC05_Awake = "ON") {
    mySerial.print('m');
    Serial.print('m');
  }
}

// void LDR() {
// LDRValue = analogRead(ldrPin);
// Serial.print("Light Value - ");
// Serial.println(LDRValue);
// // delay(1000;) 
// }

void MotionDetection() {
  pirVal = digitalRead(pirPin);
  if (pirVal == LOW) {
    //Serial.println("No Motion");
    digitalWrite(GarRelay1, LOW);
    digitalWrite(GarRelay2, LOW);
 } else {
    digitalWrite(GarRelay1, HIGH);
    digitalWrite(GarRelay2, HIGH);
    //Serial.println("MOTION!!");
 
 }
    //delay(1000);   
}
--- End code ---

So as you can see, the fan will go HIGH upon start up, which I plan to change once I get this issue resolved.  Also, I've attached a screenshot of my schematic (please don't beat me up too much as I have ZERO experience in this realm - but I am learning.).  I circled the area in question.  Another thing that happened is the other relays stopped working as well.  Please fire away with questions, as I'm sure I didn't cover everything that I'm supposed to.  Thanks in advance for your help.

pcprogrammer:
You need a resistor in the base line of the transistor. You will probably blow up Q4 as soon as you set the output D12 of the Arduino nano high.

Since it is a BJT and not a FET, you need to limit the current flowing through the base of the transistor. It depends on the current the relay needs to turn on, how large the resistor has to be.  The gain depends on the collector emitter voltage and current, but using a value of 40 will probably be ok. So if the relay needs 50mA the base emitter current needs to be 1.25mA. The resistor then needs to be (5V - 0.7V) / 0.00125A = 3440 ohm. This is not a common value so 3300 ohm is the nearest one to choose.

About your schematic, at least you used wires, but there is a lot of room for improvement. Make sure that texts are not on top of parts or power supply symbols. For instance the 5V supply symbol near the relay is very hard to see that it is 5V. Also try to work from left to right regarding to signal flow. So move your 5V power jack to the top left side of the schematic and work form there with the outputs of the system on the right side of the schematic.

The other transistors in your schematic have the same issue.

Another issue might be that the MT3608 step up module is not capable of supporting the extra load of the fan.

gkraniske:
Thanks very much for your help.  So it looks like I have some work to do.  Is there anything you would recommend instead of the MT3608?  I mean it's a really small fan.

pcprogrammer:
If you have a DMM you can check if the voltage remains on a stable 7 volt with the system running and the fan directly connected to the output of the MT3608 module. If not, you need something beefier, like this one https://www.aliexpress.com/item/1005007894995437.html for instance. It can deliver twice the current of the MT3608.

7 volt is the lower limit for the Arduino nano by the way, and if it drops due to load it might cause a reset on the Arduino nano.

gkraniske:
Perfect.  I just bought 10 of them off Amazon, thank you so much.  I use a company called JLCPCB where I order my PCB's from.  The part is cheap enough but shipping is $40 bucks or so.  Would you have any other places you use that might be cheaper?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod