Incorrect behavior on AC current

Hi,
I'm very new to arduino.

This is my first project.

I was trying to follow this guide:
https://create.arduino.cc/projecthub/SurtrTech/laser-tripwire-alarm-arduino-e8922b

however, instead of arduino uno R3, I used a pro mini 328p 5v
I'm using a PL2303HXA usb-to-ttl converter to program the arduino

everything works fine when the board is connected to pc and powered via usb.

But as soon as I connect it to ac power, the buzzer is continuously beeping.

I'm not sure what is going on.

Can anyone please help?

Is it possible to monitor the serial output while connected to AC?

I'm afraid to connect it to my laptop when there is already power going in through RAW port.

Is it ok to connect to laptop when the board is connected to AC?

To clear up confusion, I've used a 5v 700mA dc transformer.

Please help.

Thanks.

/* This code is for a LASER Tripwire Alarm based on a light sensor, LASER module and a push button
 * The LASER is constantly sending beams to the sensor, when someone passes the light is not detected
 * and the alarm goes off, and will not stop until you press the button
 * Refer to www.surtrtech.com for more details
 */
 
#define Rec 8       //Light sensor input
#define Laser 9     //Laser module 
#define Button 13   //Push button input
#define Buzzer 11   //Buzzer

bool detection;

void setup() {
  pinMode(Laser, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  digitalWrite(Laser, HIGH); //Turning on the laser
  delay(2000);
}

void loop() {

 short Detect = digitalRead(Rec);            //Constanly reading the module value
 bool  Button_state = digitalRead(Button);  //And the button value (1-0)
 
 if(Detect == 0)              //The Max value is 760, if someone passes it goes below that (every value lower than 700 can do the work)
    detection = true;          //The detection is triggered

 if(detection==true)
    {
      digitalWrite(Buzzer, HIGH); //Turning on the Buzzer
       delay(150);            
      digitalWrite(Buzzer, LOW);
       delay(50);
    }
 
 if(Button_state == HIGH)  //If the button is pressed the buzzer is turned off and the detection too
    {
      detection = false;
      digitalWrite(Buzzer, LOW);
    }

  
}

Is the output labeled as 5V an AC signal or is there another component that is converting it to DC for feeding the board?

1 Like

Its dc of course.
I used one of those tiny AC to DV 5v 700mA
transformer circuit.

Did you measure the actual voltage under load? Those transformer based adapters have no voltage regulation.

Also, if you want to power your MCU from 5V, do not connect it to the RAW pin. That pin expects at least 7V or so input, it goes to an on board regulator that will limit it to 5V.

1 Like

No, I did not.
I used one pf these:

Again, you are applying power to the wrong pin.

1 Like

Yes, someone else explained it in pm.

I thought these transformer output are not to be trusted that's why I connected it to Vin.
Ill measure the output voltage and connect ot to vcc, and will see how ot goes.

However, can you please tell me about my other question?
How do I monitor serial console, if powered through external power?

For that, you have to connect a separate serial-to-USB converter board to the TX/RX pins. Or, you can continue to monitor serial through the USB port. It just won't be supplying power any more.

1 Like

Carrying on simultaneous private and public conversations on a forum topic is bad manners. It can waste a lot of peoples time.

1 Like

He didn't reply here.
Just replied in pm.
So out of my control I believe?

Except that you didn't echo the information here.

Oh, sorry.
He said that only about 5 minutes before you.
I didn't know I should have mentioned here what he said.

Anyway, you have the answer...

Yes, thanks a lot for your help.

For that, you have to connect a separate serial-to-USB converter board to the TX/RX pins. Or, you can continue to monitor serial through the USB port. It just won't be supplying power any more

I have pl2303 serial to usb
Can i connect only TX/RX if power is provided through vcc from other source?

I mean, if I connect vcc and ground to the pl2303 as well, will it harm my laptop?

Yes, you only have to provide current limiting series resistors if both devices will not be powered at the same time. But why not use the existing USB port? It does the same thing. Edit - oh, forgot you have a Pro Mini. Okay, you could disconnect the VCC from the PL2303 to the Mini.

In that case (where you need an ongoing USB serial connection for your app), the use of a Mini is a mistake, you should use a Nano or other board that already has the USB interface.

1 Like

I exceeded the number of replies I could post.
Now I'm able to post again.

this is the revised schematic.
I still have the same issue.
However, if the serial converter is connected to laptop, it works.
As soon as I disconnect the serial converter from laptop, the buzzer starts beeping.

I measured the transfer output. it is 5.01V at load, 5.05 at no-load.
current draw is between 45-50mA.

Your tact switch should go to ground not Vcc, if you plan to use it that way, and you would also have to use INPUT_PULLUP option of pin configuration. If not, you will have to add a pull down resistor.

That doesn't help anyone else with a similar problem in a future search.

Sorry, I don't understand this.
I'm new here, so please tell me what is the proper etiquette here?
When he replied to me in a PM, what should I have told him?
"DON"T PM ME?"
It's not like I sent everyone PM asking for help.
That user Chose to not reply here and instead PM me.
What is my fault here?

Thanks for the info, I just read more details about input options, and learnt a bit more.
However, just to test things, I completely removed the button and relevant codes.

Still doesn't help with the problem I am having.

I also tested with 2x14500 batteries in Vin/RAW pin
it works perfectly.

Could the power supply be the issue?
I mean it supplies 5v, that I can measure and monitor, but I don't have a oscilloscope where I can analyze the output of that power supply.

I'll try powering from mobile output next. I don't have a micro usb port handy right now.
Will have to wait a bit for that.