Multiple Rfid sensors interfering?

Hey everyone! Thank you for advance if you are reading this and can maybe give some insight what is happening (or is not) with this project.

I am new to electronics and coding in general. Have been building this project almost a year now and learning step by step. Trying to keep genie smoke inside components.:slight_smile:

This is also my first topic in here. Trying to use code tags correctly and be as informative as possible. I made bread board view drawing about wiring with Fritzing and later read that it is not recommended.

Hardware used:
Arduino uno wifi rev.2 (with latest WifiNINA 1.4.8 update) + screwshield for secure connections

Two Velleman VMA405 rfid-sensors: Two sensors share same 3.3V,RST-pin(RST_PIN 8), GND, MISO, MOSI and CLK. NSS are separate from both sensors. They go to D2 and D3 on arduino. (Board is based on MFRC522 chip) MISO, MOSI and CLK are soldered to arduinos ICSP pins. Other wires are connected with wire ferrules and screwterminals to arduino. All wires are soldered to rfid-sensors.
Two sensors are side by side because space limitations (Foreshadowing for trouble)

PC atx power supply: gives 12V to project. there are 5A fuses on the board. 12V is distributed separately to two DC-DC converters (LM2596S). First converter converts 12V to 9V and that powers Arduino and connected Rfid-sensors and Hall-sensor. Second converter converts 12V to 5V and that powers 2 channel relay module (HW-279) (there are optoisolation on input side and protection diodes)

12V magnetic lock: with protection diode (1N5408). Lock is driven trough relays normaly open. When lock is open arduinos A1 is driven HIGH.

Allegro A1324 Linear Hall-sensor: Sensor is driven with 5V and gives 2,5V (numerical 512) output when idle. There are 100nF ceramic capasitor smoothing the signal.


What should be happening:

When first and second puzzle pieces with embedded rfid-tags are bringed to sensors we check if they are right ones. It dont matter which sensor pick witch piece. We also want that puzzle state and opening the lock happens only when pieces are at the sensor.

This will open the magnetic lock

This will activate the hall-sensor and player can now put piece with embedded magnet to right place. We check if threshold is been low enough and enough time has passed so we can be sure that magnet is on the spot. This will end the puzzle and we send sendsolve() trough wifi to admin.

Code below:

</>[code]

// Puzzle logic:
// Both pieces with embeded RFID-tag have to be on the sensor, so the maglock can be opened
// After that Hall-sensor starts to give readings. Players have object with embeded magnet
// and place where they can put the object and when treshold and time is passed the puzzle will end
// solving the puzzle will send message via wifi to admin server
// admin server can solve and reset puzzle with commands via wifi

// Include the puzzleWifiConnect library and settings
#include "puzzleWifiConnect.h"

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN_1 2  // 1 rfid sensor slave select
#define SS_PIN_2 3  // 2 rfid sensor slave select
#define RST_PIN 8   // RST-pin for both mfrc522 sensors
MFRC522 mfrc522_1(SS_PIN_1, RST_PIN);   // Create MFRC522_1 instance.
MFRC522 mfrc522_2(SS_PIN_2, RST_PIN);   // Create MFRC522_2 instance.

// This pin will be driven LOW to release a lock.
const byte lockPin = A1;

//Puzzle steps states
int object_1 = 0;
int object_2 = 0;

//Hall sensor variables
const int numReadings = 10; // size of the readings array

int readings[numReadings];  // the readings from the analog input
int readIndex = 0;          // the index of the current reading
int total = 0;              // the running total
int average = 0;            // the average

int Hall_1 = A0;            // pin for Hall-sensor
bool object_3 = false;      // state for final puzzle

//threshold time for hall-sensor read
unsigned long magnet = 0;
const long magnet_read = 100;

//pause between sensor readings object1
unsigned long previousMillis1 = 0;
const long wait1 = 2000;
//pause between sensor readings object2
unsigned long previousMillis2 = 0;
const long wait2 = 2000;

void setup() {

  Serial.begin(9600);                   // Initiate a serial communication
  Serial.println("Card reader setup");
  SPI.begin();                          // Initiate  SPI bus
  mfrc522_1.PCD_Init();                 // Initiate MFRC522_1
  mfrc522_2.PCD_Init();                 // Initiate MFRC522_2
  Serial.println("Card reader setup ready");
  Serial.println();

  // initialize all the hall-sensor readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }

  // setup wifi
  Serial.println("Setup wifi");
  puzzleWifiSetup();
  Serial.println("Wifi setup ready");
  Serial.println();

  delay (10);
}
void loop() {
  object1();
  object2();
  // if both objects are on reader, lets check the puzzle states
  if (object_1 == 1 && object_2 == 1) {
    Serial.println("objects at place. Release the magnet");
    Serial.println();
    // if so release the magnet
    digitalWrite(lockPin, HIGH);
    object3();
  }
  puzzleWifiLoop();
  delay (10);
}

void object1() {

  unsigned long currentMillis1 = millis();
  if (currentMillis1 - previousMillis1 <= wait1) {
    previousMillis1 = currentMillis1;
  }
  // Look for new cards
  if ( ! mfrc522_1.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522_1.PICC_ReadCardSerial())
  {
    Serial.println();
    Serial.print("object_1 detected");
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522_1.uid.size; i++)
  {
    Serial.print(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522_1.uid.uidByte[i], HEX);
    content.concat(String(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522_1.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  //change here the UID of the card/cards that you want to give access
  if ((content.substring(1) == "E9 C7 75 99", "3A 9F 74 1A") && ( ! mfrc522_1.PICC_IsNewCardPresent()))
  {
    Serial.println("Authorized access");
    Serial.println();
    object_1 = 1;
    if (object_1 = 1)
    {
      Serial.println("object1 solved");
      Serial.println();
    }
  }
  // Halt PICC
  mfrc522_1.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522_1.PCD_StopCrypto1();
  delay(100);
}

void object2() {

  unsigned long currentMillis2 = millis();
  if (currentMillis2 - previousMillis2 <= wait2) {
    previousMillis2 = currentMillis2;
  }
  // Look for new cards
  if ( ! mfrc522_2.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522_2.PICC_ReadCardSerial())
  {
    Serial.println();
    Serial.print("object_2 detected");
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522_2.uid.size; i++)
  {
    Serial.print(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522_2.uid.uidByte[i], HEX);
    content.concat(String(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522_2.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  //change here the UID of the card/cards that you want to give access
  if ((content.substring(1) == "E9 C7 75 99", "3A 9F 74 1A") && ( ! mfrc522_2.PICC_IsNewCardPresent()))
  {
    Serial.print("Authorized access");
    Serial.println();
    object_2 = 1;
    if (object_2 = 1)
    {
      Serial.print("object2 solved");
      Serial.println();
    }
  }
  // Halt PICC
  mfrc522_2.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522_2.PCD_StopCrypto1();
  delay(100);
}

void object3() {

  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(Hall_1);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  Serial.println(average);

  unsigned long magnet = millis();
  while (millis() < magnet + magnet_read) {
    if ((average <= 485) && object_3 == false) {
      if (object_3 == false) {
        object_3 = true;
        solve();
        // Moment when magnet is not present
        if ((average > 485) && object_3 == true) {
          object_3 = false;
        }
      }
    }
  }
  // delay before next reading
  delay(10);
}

/*************************************
   Wifi communication functions below
 *************************************/

/**
   SOLVE

   This is solve function. When you click  puzzle solved in admin dashboard this function gets called.
*/
void solve() {
  if (puzzleActive) {
    // do here what you have to do to solve the puzzle

    // Send status to admin
    sendSolve();
  } else {
    Serial.println("Puzzle not active, cant solve it");
  }
}

/**
   RESET

   This is reset function. When you click  puzzle reset in admin dashboard this function gets called.
*/
void reset() {
  if (puzzleActive) {
    // do here what you have to do to reset the puzzle

    // Set the lock pin as output and secure the lock
    pinMode(lockPin, OUTPUT);
    digitalWrite(lockPin, LOW);
    // Reset puzzle states back to zero
    object_1 = 0;
    object_2 = 0;
    object_3 = 0;
    // Send status to admin
    sendReset();
  } else {
    Serial.println("Puzzle not active, cant reset it");
  }
}

/**
   ACTIVATE

   This is activate function. When you click puzzle activate in admin dashboard this function gets called.
*/
void activate() {
  // do here what you have to do to activate the puzzle

  // Send status to admin
  sendActive();
}

/**
   DEACTIVATE

   This is deactivate function. When you click puzzle deactivate in admin dashboard this function gets called.
*/
void deactivate() {
  // do here what you have to do to deactivate the puzzle

  // Send status to admin
  sendDeactive();
}

/**
   This will check if wifi has received any control messages eg. solve, reset etc.
   Call this in the loop.
*/
void checkIncomingCommands() {
  if (hasReset) {
    hasReset = false;
    reset();
  }
  if (hasSolve) {
    hasSolve = false;
    solve();
  }
  if (hasActivate) {
    hasActivate = false;
    activate();
  }
  if (hasDeactivate) {
    hasDeactivate = false;
    deactivate();
  }
}
[/code]</>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What is happening:

Rfid readers freeze. They wont read tags and puzzle wont go forward.

I checked connections and  continuity with multimeter. Those checks ok.

When i take other sensor away from vcc and gnd, other sensors starts to work and vice versa.

When first i started making the enclosure for sensors i didnt know possible interference what sensors can cause for eachother. Now it is obvious to me because i understand that sensors are antennas and receivers at same time.

Maybe the easiest way would be making the new enclosure with spacing at least 50cm or more between sensors, but that would be painstaking work to start all over again.

So i ask. Is it possible to use only one reader at the time and loop readers on at the time and save the states, so we can check are the conditions right to open the magnet. How this is done in code?

Would it be option to power up sensors separately for example with relay and do sensor looping that way?

Thank you for reading this far. I hope this information is enough and there are stuff what you can point me.

Best regards:
rei_kalev
![Puzzle|574x500](upload://m1nwTvnUv75bIiT87XHJkguhPri.jpeg)

When you are talking to your MFRC522 sensors, you need to make sure the chip select pin for the other one is HIGH so it does not listen/respond. That is how SPI works.... Enable the device you wish to talk to, communicate, disable the device, repeat for next SPI device.

Update your object1() and object2() functions to enable the device and then disable it before you exit.

void object1() {

  digitalWrite(SS_PIN_1, LOW );   // enable
  
  unsigned long currentMillis1 = millis();
  if (currentMillis1 - previousMillis1 <= wait1) {
    previousMillis1 = currentMillis1;
  }
  // Look for new cards
  if ( ! mfrc522_1.PICC_IsNewCardPresent())
  {
    digitalWrite(SS_PIN_1, HIGH );   // disable
    return;
  }
  // Select one of the cards
  if ( ! mfrc522_1.PICC_ReadCardSerial())
  {
    Serial.println();
    Serial.print("object_1 detected");
    digitalWrite(SS_PIN_1, HIGH );   // disable
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522_1.uid.size; i++)
  {
    Serial.print(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522_1.uid.uidByte[i], HEX);
    content.concat(String(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522_1.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  //change here the UID of the card/cards that you want to give access
  if ((content.substring(1) == "E9 C7 75 99", "3A 9F 74 1A") && ( ! mfrc522_1.PICC_IsNewCardPresent()))
  {
    Serial.println("Authorized access");
    Serial.println();
    object_1 = 1;
    if (object_1 = 1)
    {
      Serial.println("object1 solved");
      Serial.println();
    }
  }
  // Halt PICC
  mfrc522_1.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522_1.PCD_StopCrypto1();
  digitalWrite(SS_PIN_1, HIGH );   // disable
  delay(100);
}

Also, since you are converting your 12V down to 9V to supply your board, why not regulate it down to 5V and supply it to Vin directly? It will avoid the onboard regulator which can only supply 500mA.

1 Like

200 mA.

1 Like

This expression doesn't do what you seem to think it does. It does not compare a substring to two different strings. Replace this, in at least two places that I saw, with:

(content.substring(1) == "E9 C7 75 99" || content.substring(1) == "3A 9F 74 1A")

1 Like

Hey again and thanks for replying!

I did changes what @johnwasser and @blh64 suggested to me. Updated code below.

</>


// Puzzle logic:
// Both pieces with embeded RFID-tag have to be on the sensor, so the maglock can be opened
// After that Hall-sensor starts to give readings. Players have object with embeded magnet
// and place where they can put the object and when treshold and time is passed the puzzle will end
// solving the puzzle will send message via wifi to admin server
// admin server can solve and reset puzzle with commands via wifi

// Include the puzzleWifiConnect library and settings
#include "puzzleWifiConnect.h"

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN_1 2  // 1 rfid sensor slave select
#define SS_PIN_2 3  // 2 rfid sensor slave select
#define RST_PIN 8   // RST-pin for both mfrc522 sensors
MFRC522 mfrc522_1(SS_PIN_1, RST_PIN);   // Create MFRC522_1 instance.
MFRC522 mfrc522_2(SS_PIN_2, RST_PIN);   // Create MFRC522_2 instance.

// This pin will be driven LOW to release a lock.
const byte lockPin = A1;

//Puzzle steps states
int object_1 = 0;
int object_2 = 0;

//Hall sensor variables
const int numReadings = 10; // size of the readings array

int readings[numReadings];  // the readings from the analog input
int readIndex = 0;          // the index of the current reading
int total = 0;              // the running total
int average = 0;            // the average

int Hall_1 = A0;            // pin for Hall-sensor
bool object_3 = false;      // state for final puzzle

//threshold time for hall-sensor read
unsigned long magnet = 0;
const long magnet_read = 100;

//pause between sensor readings object1
//unsigned long previousMillis1 = 0;
//const long wait1 = 2000;
//pause between sensor readings object2
//unsigned long previousMillis2 = 0;
//const long wait2 = 2000;

void setup() {

  Serial.begin(9600);                   // Initiate a serial communication
  Serial.println("Card reader setup");
  SPI.begin();                          // Initiate  SPI bus
  mfrc522_1.PCD_Init();                 // Initiate MFRC522_1
  mfrc522_2.PCD_Init();                 // Initiate MFRC522_2
  Serial.println("Card reader setup ready");
  Serial.println();

  // initialize all the hall-sensor readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }

  // setup wifi
  Serial.println("Setup wifi");
  puzzleWifiSetup();
  Serial.println("Wifi setup ready");
  Serial.println();

  delay (10);
}
void loop() {
  object1();
  object2();
  // if both objects are on reader, lets check the puzzle states
  if (object_1 == 1 && object_2 == 1) {
    Serial.println("objects at place. Release the magnet");
    Serial.println();
    // if so release the magnet
    digitalWrite(lockPin, HIGH);
    object3();
  }
  puzzleWifiLoop();
  delay (10);
}

void object1() {

  // Drive Slave select pin to LOW to activate sensor 1
  digitalWrite(SS_PIN_1, LOW);

  Serial.println("Sensor 1 ready for card");
  Serial.println();

  //unsigned long currentMillis1 = millis();
  //if (currentMillis1 - previousMillis1 <= wait1) {
  //previousMillis1 = currentMillis1;
  //}
  // Look for new cards
  if ( ! mfrc522_1.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522_1.PICC_ReadCardSerial())
  {
    Serial.println();
    Serial.print("object_1 detected");
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522_1.uid.size; i++)
  {
    Serial.print(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522_1.uid.uidByte[i], HEX);
    content.concat(String(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522_1.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  //change here the UID of the card/cards that you want to give access
  if ((content.substring(1) == "E9 C7 75 99" || content.substring(1) == "3A 9F 74 1A") && ( ! mfrc522_1.PICC_IsNewCardPresent()))
  {
    Serial.println("Authorized access");
    Serial.println();
    object_1 = 1;
    if (object_1 = 1)
    {
      Serial.println("object1 solved");
      Serial.println();
    }
  }
  // Halt PICC
  mfrc522_1.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522_1.PCD_StopCrypto1();
  // Drive Slave select pin to HIGH to stop sensor 1
  digitalWrite(SS_PIN_1, HIGH);
  delay(100);
}

void object2() {

  // Drive Slave select pin to LOW to activate sensor 2
  digitalWrite(SS_PIN_2, LOW);

  Serial.println("Sensor 2 ready for card");
  Serial.println();

  //unsigned long currentMillis2 = millis();
  //if (currentMillis2 - previousMillis2 <= wait2) {
  //previousMillis2 = currentMillis2;
  //}
  // Look for new cards
  if ( ! mfrc522_2.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522_2.PICC_ReadCardSerial())
  {
    Serial.println();
    Serial.print("object_2 detected");
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522_2.uid.size; i++)
  {
    Serial.print(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522_2.uid.uidByte[i], HEX);
    content.concat(String(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522_2.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  //change here the UID of the card/cards that you want to give access
  if ((content.substring(1) == "E9 C7 75 99" || content.substring(1) == "3A 9F 74 1A") && ( ! mfrc522_2.PICC_IsNewCardPresent()))
  {
    Serial.print("Authorized access");
    Serial.println();
    object_2 = 1;
    if (object_2 = 1)
    {
      Serial.print("object2 solved");
      Serial.println();
    }
  }
  // Halt PICC
  mfrc522_2.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522_2.PCD_StopCrypto1();
  // Drive Slave select pin to HIGH to stop sensor 2
  digitalWrite(SS_PIN_2, HIGH);
  delay(100);
}

void object3() {

  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(Hall_1);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  Serial.println(average);

  unsigned long magnet = millis();
  while (millis() < magnet + magnet_read) {
    if ((average <= 485) && object_3 == false) {
      if (object_3 == false) {
        object_3 = true;
        solve();
        // Moment when magnet is not present
        if ((average > 485) && object_3 == true) {
          object_3 = false;
        }
      }
    }
  }
  // delay before next reading
  delay(10);
}

/*************************************
   Wifi communication functions below
 *************************************/

/**
   SOLVE

   This is solve function. When you click  puzzle solved in admin dashboard this function gets called.
*/
void solve() {
  if (puzzleActive) {
    // do here what you have to do to solve the puzzle

    // Send status to admin
    sendSolve();
  } else {
    Serial.println("Puzzle not active, cant solve it");
  }
}

/**
   RESET

   This is reset function. When you click  puzzle reset in admin dashboard this function gets called.
*/
void reset() {
  if (puzzleActive) {
    // do here what you have to do to reset the puzzle

    // Set the lock pin as output and secure the lock
    pinMode(lockPin, OUTPUT);
    digitalWrite(lockPin, LOW);
    // Reset puzzle states back to zero
    object_1 = 0;
    object_2 = 0;
    object_3 = 0;
    // Send status to admin
    sendReset();
  } else {
    Serial.println("Puzzle not active, cant reset it");
  }
}

/**
   ACTIVATE

   This is activate function. When you click puzzle activate in admin dashboard this function gets called.
*/
void activate() {
  // do here what you have to do to activate the puzzle

  // Send status to admin
  sendActive();
}

/**
   DEACTIVATE

   This is deactivate function. When you click puzzle deactivate in admin dashboard this function gets called.
*/
void deactivate() {
  // do here what you have to do to deactivate the puzzle

  // Send status to admin
  sendDeactive();
}

/**
   This will check if wifi has received any control messages eg. solve, reset etc.
   Call this in the loop.
*/
void checkIncomingCommands() {
  if (hasReset) {
    hasReset = false;
    reset();
  }
  if (hasSolve) {
    hasSolve = false;
    solve();
  }
  if (hasActivate) {
    hasActivate = false;
    activate();
  }
  if (hasDeactivate) {
    hasDeactivate = false;
    deactivate();
  }
}

</>

With changes i also uncommented millis function from both object 1 and 2 away, because it looked that it didn't do anything and i feared that it would affect how delay would work. I added serial print: (Serial.println("Sensor 1 and 2 ready for card"); after digitalWrite SS_PIN_1 and 2, LOW to see if code executes that far.

I post picture from Serial monitor window and there you can see that program never read the actual card. The moment when this picture was taken, the rfid-tag was on top the sensor.

from timestamp you can see that delay wont work either. Serial print happens between object_1 and object_2 in about 50ms, when delay after every void is 100ms

On hardware side i tried to change both rfid sensors. No results.
I also moved sensors a part. Now there are 60cm between sensors. No results.

I don't think problem is power managment. Rfid sensrors take at peaks 30mA, so that is 60mA for rfid sensors, Triggering current for relay is 5mA and hall-effect sensor takes 10mA. Combined that is 75mA

Reason why I haven't used Vin pin for powering Arduino is that, for my knowledge there is no regulation and i don't want that accident happen that i give more then 5V to Vin pin.

Any ideas?

I assume that you mean "supply to 5V" ? The spec for Vin is a minimum of 7V.

The relevant part of the schematic; look where Vin is connected; Vin is basically the same as the barrel.

image

There is an extremely good reason not to use "Vin" or the "barrel jack" on a UNO.


You need a 5 V regulator - I gather the one you have is suitable, it just needs to be "tweaked" to 5 V.

You feed it in parallel to all parts requiring 5 V including the Arduino at the "5V" pin. You should however disconnect the "5V" pin whenever you have the USB port plugged into a PC.

If there is any concern whatsoever that the regulator may accidentally feed in excess of 5 V to the Arduino, then simply throw it out and go get a reliable one. This is simply a no-brainer! :face_with_raised_eyebrow:

The relays draw 90 mA each from the 5 V supply when actuated.

Hey!

Earlier Fritzing diagram shows that LM2596S DC-DC converter converts 12V to 9V and then power goes trough barrel jack to arduino. Arduino then with it's internal regulator regulates 9V to 5V. This is ok?

In LM2596S there are potentiometer trimmer. I have trimmed output to 9V and cheked twice with multimeter. After that i glued small hotglue tap to the trimmer, so it would not change.

Can I fry arduino if i take serial monitor with usb and same time feeding arduino with 9V trough barrel jack?

Even with relay drawing 90mA, Total current draw from all sensors and relay still sums 160mA.
And that 90mA current draw goes trough 12V to 5V DC-DC converter? Not trough arduino pins?

Yes.

No.

You're not feeding anything significant from the regulator so you're OK.

1 Like

Hello again! Some progress and new problems with puzzle.

I managed to get code running and it's looks working.

Now the problem is that RFID-readers work only when Arduino is powered via laptops Usb. relay is powered trough 12V to 5V DC-DC converter and 12V magnet is powered trough PC-power supply.

When i power Arduino trough barrel jack with 9V from DC-DC converter the puzzle won't solve. Also when looking Serial Monitor with laptop, sensors will detect presence of the card but won't read tag and it's UID.

My next step is to purchase a oscilloscope. That would be nice to have also in future.

Why oscilloscope? I'm guesing ripple in DC-DC converters output.

Am i on right track with my problemsolving or is there somthing what i dont understand?

I'm guessing not. More likely to be an issue where all your grounds are not properly tied together so the whole system uses the same reference for GND. A schematic would be most useful and possibly eliminate the guessing.

Did I not warn you about that? :roll_eyes:

Use a proper 5 V regulator (switchmode converter - I gather you already have it) to provide 5 V to the Arduino as described and with the cautions given in #8.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.