The Adafruit US-100 Ultrasonic Distance Sensor is a versatile and reliable device designed to measure distances using ultrasonic waves. It emits a sound wave at a frequency beyond human hearing and calculates the distance to an object based on the time it takes for the echo to return. This sensor is widely used in robotics, automation, and IoT applications due to its accuracy, ease of use, and compatibility with microcontrollers like Arduino.
The following table outlines the key technical details of the Adafruit US-100 Ultrasonic Distance Sensor:
Parameter | Specification |
---|---|
Operating Voltage | 2.4V to 5.5V |
Operating Current | ~2mA |
Measuring Range | 2cm to 450cm |
Accuracy | ±0.3cm |
Output Modes | Serial (UART) or PWM |
Operating Temperature | -20°C to 70°C |
Dimensions | 45mm x 20mm x 15mm |
The US-100 sensor has a 4-pin interface. The pinout is as follows:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (2.4V to 5.5V). Connect to the 5V pin of your microcontroller. |
2 | Trig/TX | Trigger pin for PWM mode or TX pin for UART mode. |
3 | Echo/RX | Echo pin for PWM mode or RX pin for UART mode. |
4 | GND | Ground. Connect to the GND pin of your microcontroller. |
// Example code for using the Adafruit US-100 Ultrasonic Distance Sensor in PWM mode
// with an Arduino UNO. This code measures the distance to an object and prints it
// to the Serial Monitor.
#define TRIG_PIN 9 // Define the pin connected to the Trig pin of the sensor
#define ECHO_PIN 10 // Define the pin connected to the Echo pin of the sensor
void setup() {
pinMode(TRIG_PIN, OUTPUT); // Set the Trig pin as an output
pinMode(ECHO_PIN, INPUT); // Set the Echo pin as an input
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
// Send a 10-microsecond pulse to the Trig pin to trigger the sensor
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Measure the duration of the pulse on the Echo pin
long duration = pulseIn(ECHO_PIN, HIGH);
// Calculate the distance in centimeters
float distance = (duration / 2.0) * 0.0343;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(500); // Wait for 500ms before taking the next measurement
}
No Output or Incorrect Readings:
Inconsistent Measurements:
Sensor Not Responding in UART Mode:
Q: Can the US-100 measure distances below 2cm?
A: No, the minimum measurable distance is 2cm. Objects closer than this may not be detected accurately.
Q: How do I switch between PWM and UART modes?
A: The US-100 defaults to PWM mode. To use UART mode, send a specific command via the TX pin. Refer to the manufacturer's datasheet for details.
Q: Can I use the US-100 with a 3.3V microcontroller?
A: Yes, but you should use a level shifter or resistor divider to ensure the sensor's 5V signals are compatible with the 3.3V logic levels of your microcontroller.