OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › HC-SR04 & RF Transmitter on SprinklerPi › Reply To: HC-SR04 & RF Transmitter on SprinklerPi
The HC-SR04 ultrasonic distance sensor is a digital sensor, not an analog sensor. You should not connect it to the analog pins. Instead, you need to allocate two free digital pins for it. Because the sensor output is 5V (its powered by 5V), you should connect a 1K resistor from its output to OSPi’s GPIO, to avoid potentially damaging RPi’s GPIO. Alternatively, there are newer versions of HC-SR04 — called HC-SR04+, that can be powered from 3.3V and hence outputs 3.3V too. If you use HC-SR04+, there is no need to use the series 1K resistor.
Note that OpenGarage (www.opengarage.io) is a standalone WiFi-enabled sensor that can be used to sense garage door status, but also used to sense water level — it has a built-in HC-SR04 sensor. You may want to consider using OpenGarage as a standalone sensor.
About the RF transmitter, again, it’s a digital component, and you should not connect it to the analog pins.