Need help with schoolwork, appreciated

need help.. today I got closer to my project, I have to be ready for 2 weeks I've got to make a presentation for the school about my school project, but I am a little stuck here.. the solenoid lock opens, then 1&3 relay wont work, after some seconds as programmed 2&4 relays work and dc motor moves in the one direction and then solenoid lock closes..
I've tested out with FLUKE multimeter in 1&3 relay when it has source then the voltage is 0.03-0.07v when I have given it 5V power supply why?

it's a project about a fingerprint door lock full automatically (unlocks and opens via dc motor, closes via dc motor and locks)

little explanation, first about the fingerprint it works fine, I have fingers enrolled and everything seems fine, then we hop up to relay for solenoid lock, it has NO contact and COM port has 12V PC Power supply because the Solenoid Lock works on 12V, GND on the solenoid lock is connected to GND port of PC power supply, that works fine, then we hop up to our 4 handmade relay which has 2 NO (5V from PC power supply) and 2 NC (GND from PC power supply), which are both connected with 1&3 port to pin 11, and 2&4 relay to pin10 and here's my code

#include <Adafruit_Fingerprint.h>

#if (defined(AVR) || defined(ESP8266)) && !defined(AVR_ATmega2560)
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
// Set up the serial port to use softwareserial..
SoftwareSerial mySerial(2, 3);

#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define mySerial Serial1

#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

int a=12;
int b=11;
int c=10;

void setup()
{
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nAdafruit finger detect test");

pinMode (a, OUTPUT);
pinMode (b, OUTPUT);
pinMode (c, OUTPUT);

// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1) { delay(1); }
}

Serial.println(F("Reading sensor parameters"));
finger.getParameters();
Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX);
Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX);
Serial.print(F("Capacity: ")); Serial.println(finger.capacity);
Serial.print(F("Security level: ")); Serial.println(finger.security_level);
Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX);
Serial.print(F("Packet len: ")); Serial.println(finger.packet_len);
Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);

finger.getTemplateCount();

if (finger.templateCount == 0) {
Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
}
else {
Serial.println("Waiting for valid finger...");
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
}
}

void loop() // run over and over again
{
getFingerprintID();
delay(150); //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
return p;
default:
Serial.println("Unknown error");
return p;
}

// OK success!

p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}

// OK converted!
p = finger.fingerSearch();
if (p == FINGERPRINT_OK) {
Serial.println("Found a print match!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_NOTFOUND) {
Serial.println("Did not find a match");
return p;
} else {
Serial.println("Unknown error");
return p;
}

// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
{
if (finger.fingerID == 3) {
digitalWrite(a, HIGH);
delay (3000);
digitalWrite(b, HIGH);
delay (2000);
digitalWrite(b, LOW);
delay (2000);
}
else if (finger.fingerID == 4) {
digitalWrite(c, HIGH);
delay (2000);
digitalWrite(c, LOW);
delay (3000);
digitalWrite(a, LOW);
delay (1);
}
return finger.fingerID;
}
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;

p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;

p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;

// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;
}

Hello
Well, you need to avoid using the delay() function.
This function blocks the continuous execution of your sketch. Some tasks within your sketch need to be executed "in parallel".

1 Like

but the light on the 1&3 relay and 2&4 relay seem fine?
although the multimeter on the first 1&3 gives output of 0.03v to 0.07v while the output of the 2&4 relay seems fine and it works?
but on the 1&3 relay it doesn’t gives the same output

Read the first topic telling how to get the best from this Forum, especially how to post code using code tags.

The 5 volt connection from controller +5 to a breadboard and then to the relays is the worst way to do it.
From where does the controller get its power?

1 Like

I've used a breadboard for an example here, I am doing it on those boards where you have to solder the wires inside those copper circles and the those 4 relays are connected like this actually.. and the controller is connected to the port for programming via laptop.

The tiny copper folie on the controller board is not designed to supply the current needed by motors. Computer USB are usually limited to 500 mA. Exceeding that things start to malfunction. Don't do like that!
Breadboards are also not designed for motor/relay current. Just don't do like that!
Loss of voltage, permanent damages are just waiting for You. Breadboards don't give reliable contact and intermittent or random faults are usual.

1 Like

not the copper foil on the controller board, but on this kind of tile of copper small circles !.. and I will powerup the ardunio via the PC power supply aswell..
image

I solder them on those kind of tiles with copper circles like the picture above.

Okey, my misunderstanding. That's a god way to make connections.
It looks like only the logic part of the relay modules are connected to that controller 5 volt. That's okey.
I wish You could make a conventional wiring diagram. Magnifying Your Fritzing blurrs out the text. Fritzings are stuff used by sails people and use less for engineering.
You write "use the Pc supply". What is that? Volt, Amps....

1 Like

5VC on the power supply you know when the computer power supply has 3.3v , 5v and 12v
I use 12v from the computer power supply for the electromagnet and 5v for the output of the relay the input is from the arduino controller

Please use pen and paper and make a little drawing for the power lines. The poetry way is way to unclear, unprecise.
Feeding 12 volt to the controller and using the internal 5 volt converter is bad practise. Maybe You can pull 20 mA from that 5 volt pin, but not much more.

1 Like

okay, I will try to use pen and paper, and do it precisely.

Even though most PC's doesn't enforce it, that's actually with negotiation. 100mA what you should expect without.

1 Like

Using the computer USB power supply is a good way to do some permanent damage or at the very least, crash your computer, especially when tinkering around with high currents or potential shorts.
Don't rely on the computer innards to shut down gracefully.
If you can, supply external circuitry in the testing stage from a bench power supply where you can limit the current.
It's not just the limit on individual output pins, but take into consideration the maximum load on the MCU as a whole.
If you are lucky, you get to burn out some tracks and components on the Arduino board.
Ideally, keep Arduino board away from external stuff with higher currents or higher voltages.
Check out Ruggeduino to see how to protect your boards.

1 Like

let me explain first this part..

on the right side I have a power supply (from old computer 300-400W), I am taking a 12V output from the power supply and giving the supply to the relay COM port.. Then I am giving a NO contact to the VCC contact of the Solenoid Lock, after that I take GND from the power supply and connect it with the GND of the Solenoid Lock..

then I put the SOURCE on PIN 12, then I connect both GND's of the relay and the fingerprint scanner into a tile like the picture above with solder, then I solder also the 5V pins from the relay and the fingerprint scanner into a 5V pin from the arduino board, I connect RX pin on pin 3 and I connect TX pin on pin 2

so here's the full thing..

RELAY USED ON THE PICTURE..
COM PORT to 12V (COMPUTER POWER SUPPLY)
NO PORT to VCC (SOLENOID LOCK)
GND (SOLENOID LOCK) to GND (COMPUTER POWER SUPPLY)

VCC PORT (RELAY) SOLDERED WITH VCC PORT (FINGERPRINT) IN 5V ARDUINO PIN
GND PORT (RELAY) SOLDERED WITH GND PORT (FINGERPRINT) IN GND ARDUINO PIN
SOURCE PORT (RELAY) IN 12 ARDUINO PIN

FINGERPRINT RX IN 3 ARDUINO PIN
FINGERPRINT TX IN 2 ARDUINO PIN

going to do the rest of the drawing.


second part is this, when I connect only the relays for the motor..

I am combining relay 1 and relay 3 with soldering the wires and then they go to arduino pin 11
also combining relay 2 and relay 4 with soldering the wires and then they go to arduino pin 10
combining the VCC from all 4 relays into one wire with soldering then connecting the wire to the VCC arduino pin
combining the GND from all 4relays into one wire with soldering then connecting the wire to the GND arduino pin

RELAY 1&3
S -> ARDUINO PIN 11
VCC -> 5V ARDUINO PIN
GND -> GND ARDUINO PIN

RELAY 2&4
S -> ARDUINO PIN 10
VCC -> 5V ARDUINO PIN (COMBINED WITH VCC RELAY 1&3)
GND -> GND ARDUINO PIN (COMBINED WITH GND RELAY 1&3)

Thanks!
Pc supply was a scrapped/reused one... I would never guessed that.
I think You mixed up the +5 and GND from the controller out to the other stuff. Never mind.
Please don't write a lot of text, pins and voltages criss cross. It takes a lot of time and it forces me to make a drawing inside my head. How You use the stuff in the wiring, the logic, is secondary.
In my opinion the best is to wire all 5 volt lines from the power supply. Else You get "circles", unnecessary currents being on a sea side trip.
I guess that the controller gets 5 volt somewhere and that should be shown in the wiring.
Your second picture was hit by the knife at the lower end.
I don't find any obvious fault yet.
We'll keep on.

1 Like

You haven't shown a 5 V power supply connected to power the relays themselves and the Arduino. :astonished:

1 Like

the way the pencil drawing is laid out, it looks like the relays get power from the 5V of the Arduino.

a picture of the relays would reassure us that you don't have some 5v and some 12v relays.
also, you show relays, not relay modules.

your first schematic seems easier to follow with color lines, but that too shows the relay and 5v power from the Arduino.

this is dangerous as your Arduino could burn up from overload or kill a chip, or just not work.

the preferred ways is to use the external 5v from the power suppl to the relay board, power and ground.
then connect the Arduino ground and siganls to the relay modules.

1 Like

Look like relay modules to me - three wires!

But the Arduino cannot supply 5 V power for relays! That's why I asked - is he connecting 5 V power to the relays, and might as well use it to power the Arduino as well.

1 Like