CodeforSouth / iot-flood-tracker

⚡️ 😴 Learn how to build a sensor that could be used for tracking flooding
https://medium.com/code-for-miami/building-iot-flood-trackers-for-miami-with-miami-7186a8c7200e
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Review Resistors Value #2

Open tonyqui opened 5 years ago

tonyqui commented 5 years ago

According to the reported voltage values and assuming that R2 = 1KOhm, it looks more precise to set R1 to around 520Ohm, to have a voltage of 3.3Volts between D4 and D5.

A R1 = 480Ohm resistor will force 3.37 Volts between D4 and D5, when the sensor outputs 5Volts A R1 = 500Ohm resistor will force 3.33 Volts between D4 and D5, when the sensor outputs 5Volts A R1 = 520Ohm resistor will force 3.289 Volts between D4 and D5, when the sensor outputs 5Volts

Is there any specific reason behind the fact that this design exceeds the 3.3V safe level reported in electron datasheet? On top of that, as long as D-pins are digital only, It does not make any difference if you have an high voltage of 3V instead of 3.3V (I think the digital threshold should be above 1.75V). This is just a remark in case you want to remain on the safe side without exceeding constructor's recommendation.

Cheers, Antonio

tonyqui commented 5 years ago

Evidence is provided also in official documentation: https://www.electronicwings.com/particle/ultrasonic-sensor-hc-sr04-interfacing-with-particle-photon

Using R1 = 2*R2 gives in output 3.3 instead of 3.37. Moreover, it believe it makes sense also to scale down this a little bit more around 3, due to the digital input on the board.

The library itself implemented by Particle, is simply checking if the pin is in high status:

"The time for which the echo pin remains high, i.e. the width of the Echo pin gives the time taken for generated ultrasonic sound to travel to the object and back."

and due to the digital sampling, a value >1.75 should be already considered as a True/high value.