I am adding a distance sensor to existing project that uses Arduino due, do I connect the trigger pin and the echo pin of the HC-SR04 ultrasonic sensor directly to Arduino due which uses 3.3V while HC-SR04 ultrasonic sensor uses 5V or do I need to use a voltage divider?
-
Could you tell us a bit more about the thickness sensor? – Avamander Feb 14 '16 at 10:17
-
1Reading the datasheet for the sensor will get you the output voltage range of the sensor. – Chetan Bhargava Feb 14 '16 at 10:29
-
@user17339 Thank you for adding information about what sensor you were writing about. – Avamander Feb 14 '16 at 15:52
-
@Avamander I was just advising OP to read the sensor datasheet. – Chetan Bhargava Feb 14 '16 at 20:12
-
@ChetanBhargava I mixed up the @. – Avamander Feb 14 '16 at 20:26
3 Answers
As suggested in previous answers, you can directly use a Due output to drive the HC-SR04's Trig pin; according to the HC-SR04 spec sheet, that pin operates at TTL levels. It will see 0 V as a 0-input and will see 3.3 V as a 1-input since it exceeds 2.4 V. Also see 3.3v input to Arduino digital pin in electronics.stackexchange.
However, the Due's inputs are not 5 V tolerant, so you will need to use a voltage divider between the Echo pin and a Due input. See second paragraph of arduino.cc's ArduinoBoardDue article:
Warning: Unlike most Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board.
- 8,840
- 3
- 17
- 32
Well, it depends on the sensor itself. Some sensors run on both 5V and 3.3V. There's a similar question here on StackExchange: How to connect 5V sensors to 3.3V digital input (Due)?
But, in short, if the sensor can't operate in 3.3V, you'll need a level converter /shifter.
The trigger pin is an input, so you can connect that directly to the Due.
The echo pin will however output 5v. You could use a voltage divider to bring that down to 3.3v or a bit lower.
- 11,286
- 3
- 20
- 34