My project requires reading 5 serial devices (RFID readers) at the same time. I chose an Arduino Mega 2560 as it comes with 4 serial RX ports. For the fifth port I am using the SoftwareSerial library.

My loop() checks each Serial port to detect if an RFID tag is being read. This works perfectly.

However, I am powering the board from an wall wart. When the power is disconnected the sketch no longer runs. I must unplug RX0, plug in the power supply, and reattach RX0.

If the board ever loses power it will have to be reset manually which is not ideal.

Please help me understand Why is this happening? and how can I fix it?

  • 2
    My guess is that the bootloader gets activated after reset, and waits for code. I don't know how to avoid this however. Commented May 13, 2015 at 13:31
  • Does it sit there with an LED flashing?
    – Majenko
    Commented May 13, 2015 at 14:01
  • If you are willing to use ISP for programming you could remove the bootloader. Or you can modify the bootloader to time out if no valid programming operations occur, or to check an "I'm being programmed" pin. Commented May 13, 2015 at 14:37

2 Answers 2


It looks like your RFID readers are very chatty on startup, and the board is going into bootloader mode.

I'd consider either controlling the RFID reader's power using another pin (and a transistor or mosfet if the reader needs more than 20mA), or using a gate ( AND for instance, or a simple switch IC like the 4066) that you can control to disable the RX0 input until program start.

Another thing I've done in the past is multiplexed multiple serial devices to one serial input. The RFID readers probably have outputs that indicate a card presence, so use those and a multiplexor. When the card presence is indicated, connect that serial port using the multiplexor, read the card and act accordingly, then wait for another card detect event.


You can simply disable the bootloader rather than erasing it. Find out the current fuse settings using a fuse-detection program. Change the BOOTRST flag in the High fuse to be unchecked, referring to this page: Engbedded Atmel AVR® Fuse Calculator

Write the High fuse back. Then it will ignore the bootloader and go straight to your code. Of course, to upload a new version you will have to put the BOOTRST fuse back, or you won't be able to use the bootloader to upload a new sketch.

One way of changing the fuse is to use my Atmega chip stand-alone programmer sketch. This has an interactive "change fuses" option. To run this you just need a spare board (eg. a Uno) and 6 wires to connect the programming board to your target Mega2560.

Example wiring shown on the linked page. Note that you do not need the SD board to merely change fuses. Just the two Arduinos and the connecting wires are enough for that.

When you first run the sketch it should inform you of the current fuses. Look at the High fuse and follow my instructions above.

You should see something like this:

Entered programming mode OK.
Signature = 1E 98 01 
Processor = ATmega2560
Flash memory size = 262144
LFuse = FF 
HFuse = D8 
EFuse = FD 
Lock byte = FF 
Bootloader in use: Yes

In this case the High fuse was D8, which has the bootloader enabled. Using the Fuse Calculator site we can see that it should now be D9 which disables the bootloader.

An alternative way to change the fuse is to use Avrdude, if you have a stand-alone ISP programmer handy.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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