Hi all… I’ve been wondering about this scenario for some time. I think it’s a valid concern no matter what board you are experimenting with.
Here it is. Currently the board is running a sketch that configures Pin 5 as an OUPUT and sets its’ value to HIGH.
All is well. We change to another project where the sketch configures Pin 5 as an INPUT and the pin is connected to the data out pin of a sensor. The question is… if we assemble the new circuit and power up the board with the old sketch still loaded, will the sensor or the board be damaged? The 30+ years I spent working as an Electronics tech tells me this is asking for trouble.
Is there some sort of protocol for doing this safely, or does it not matter?
Maybe uploading the new code before circuit assembly?
thanks charlie
Hi Charlie.
To be honest, I usually don’t think about that. I’m not sure if it doesn’t matter or if I was just lucky until now.
But, in theory, yes, we should have careful with that. It might damage the board or the sensor, even though nothing happened to my boards or sensors until now.
However, the best practice is to upload the new code before assembling the circuit. Not only because of that but also because some GPIOs, when connected, might cause issues uploading code to the board.
The best procedure to follow would be:
- Upload the new code
- Disconnect power from the board
- Assemble the circuit
- Power the board again
- Press the RST button to restart the board
Regards,
Sara
I don’t see how that could hurt the board or the sensor unless there is a major difference in voltage between the two. These boards and sensors tend to be 5V tolerant. If both are 5V then setting the output of a sensor to 5V shouldn’t hurt it as this would be the max it would send anyway.
… not if the sensor is sending out 5 Volts and the board is outputting 0 volts. …. think of the “upper” transistor on the sensor being active (i.e. effectively shorted to its power rail of 5 volts), and the “lower” transistor on the board being active (i.e. effectively shorted to its ground rail) …. isn’t that a way to blow one or the other transistors? Maybe best to figure out what the sensor is doing (e.g. sending out a “1”), and have the board’s initial output be the same.