Shorting a GPIO pin on Electron

I am powering a sensor (DFROBOT turbidity sensor) through A3 pin on Particle Electron. I haven’t encountered any issues yet but I am wondering, if water somehow enters the sensor, the worst thing that could happen (apart from the sensor getting ruined) is that the pin A3 and GND might get shorted through the sensor. What could happen if such situation arises? Could it harm the module in some way?

If your pin never is set for pinMode(A3, OUTPUT) with digitalWrite(A3, HIGH) or analogWrite(A3, pwm) nothing bad should happen - the ADC would just measure 0V.
It would be wores if you had any more than 3.3V on that pin as this is one of the two pins that are under no circumstance tolerant to anything higher than 3.3V.

1 Like

I apologise. I didn’t explain the connections properly. I am powering the sensor through A3 so I am setting the pin to digitalWrite(A3, OUTPUT). I am reading the sensor through another analog pin, A4.

In that case shorting A3 to GND while driving it HIGH you will exceed the 25mA max rating for the output stage.

But looking at the datasheet your sensor seems to draw up to 40mA which already exceeds the limit - I’d recommend you rethink powering it off of a GPIO at all.

Yes, I understand that but could it affect the module adversely. I am switching the sensor ON for only a couple of seconds every 15 minutes.

Even if you switch it on for only a few seconds, you may not immediately blow the output stage but you will in any case increase degradation of the GPIO which will eventually just go - expecially since the sensor exceeds the the recommended max current by factor 2.

BTW, the operation voltage of the sensor is stated to be 5V while the GPIOs on the Electron only sources 3.3V.
If you intend to run the device off of LiPo without 5V source, you should consider a step-up booster which you can switch on/off via your control pin.

6 Likes

As far as the sensor’s operation voltage is concerned, I have successfully been able to power it with the module and get an output. I knew that the sensor works at 5V so I did a rough calibration of its output at 3V3 against solutions of known turbidity. I guess I will have to power it with the 3V3 pin and a switch rather than a GPIO.

Or you use a transistor which you can control via GPIO.

1 Like

I’d listen to ScruffR. Don’t use i/o to power devices. Do use current limiting resistors to protect your i/o.

For your sensor, if the voltage range is already what you want, you could protect the electron with an opamp such as an LM358 run as a voltage follower between the electron and the device. If the device is shorted, then it’s no big deal. The input terminals to an opamp are a virtual short anyway.

2 Likes

By switch I meant something like TPS22917.