HC SR04 With Nano BLE 33 not working

Hi Everyone!
Relative newbie to arduino here, hoping you guys can help me out.
I'm attempting to design a larger system that incorporates Arduino Nano BLE 33's along with the HC-SR04 Distance sensor. I got everything working fine on an Arduino UNO, but when I swapped over to the Nano BLE, the distance sensor refuses to return any distance values at all.

My Code is as follows:

#define ULTRASONIC_TRIG_PIN 2 // pin trig is D2
#define ULTRASONIC_ECHO_PIN 3 // pin echo is D3

long duration;
float distance;

void setup() {
  pinMode(ULTRASONIC_TRIG_PIN, OUTPUT);
  pinMode(ULTRASONIC_ECHO_PIN, INPUT);
  Serial.begin(9600);
  delay(1500);
}

void loop() {
digitalWrite(ULTRASONIC_TRIG_PIN, LOW);
delayMicroseconds(2);

digitalWrite(ULTRASONIC_TRIG_PIN, HIGH);
delayMicroseconds(10);

digitalWrite(ULTRASONIC_TRIG_PIN, LOW);
duration = pulseIn(ULTRASONIC_ECHO_PIN, HIGH);
/* two ways to measure distance */
//distance = duration * 0.034 / 2; 
distance = (duration/2) / 29.1;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(100);
}

Below is a diagram of my Circuit:

I am using the aforementioned Arduino UNO as a 5V power supply, and share a common ground with the Nano and the HC-SR04.

I have referenced all the previous topics and attempted their suggestions, I added a voltage bridge to drop the echo from 5 to 2.5 V, changed the code, changed the parts. However, the distance sensor still stubbornly refuses to show anything besides 0.

If any help for a new guy like me could be provided, I would be extremely grateful!

The Nano has no positive power. Only GND and the 2 signals.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.