0

I would like to have a serial Bluetooth module thats completely removable, leaving nothing connected to the arduino.

My code would freeze up whenever the Bluetooth module was removed. I eventually tracked down the issue to an overwhelming amount of garbage being received from the disconnected serial pins.

I enabled the internal pull-up resistor on pin 0 (serial rx) in the setup() function which appears to have solved all my problems but is that correct? I found barely any information on removable serial devices, floating serial connections and pull-up resistors.

I suppose it's important to enable the pull up before calling serial1.begin() or maybe flushing the serial buffer once before reading any input to ensure there's no garbage?

1

Yes, what you have done is good.

It is important to tie all unused inputs to a stable state (normally low) to reduce current consumption from floating inputs. When those inputs are actively used but not connected it is even more important to stop things happening that shouldn't.

As I mentioned, normally you'd use a pull-down, not a pull-up, but the UART is actually a special case where you would want to use a pull-up (as you have) not a pull-down.

UART is "Idle High", which means that when there is no data being transmitted on a line it is held high by the transmitter. By adding a pull-up you are making it appear as if there is something connected but that something isn't actively transmitting at the moment.

The internal pullups aren't very strong, so in a noisy environment you may still get some spurious data on the UART. If that happens then you want to add an external stronger (lower resistance) pull up.

Another thing to think about with your disconnected pins is to protect them from ESD. You should have some TVS diodes on those pins to absorb spikes, and some small inline resistors to limit any overcurrent conditions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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