Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Boss lady on 8/13/2024 in #firmware-and-baremetal
How to Display Warnings on OLED Based on Object Distance Using BeagleBone Black?
Hey guys, still based on my project parking assistance system using a BeagleBone Black running Embedded Linux, VL53L0X time of flight distance sensor to detect the distance to nearby objects and a 0.96-inch OLED display to show the distance and warning messages. how can I display warning messages on the OLED screen when the detected object is too close or too far. i am getting the error Error: Display not updating i have verified timing of the time.sleep() function, ensured proper buffer clearing with disp.clear() but still getting same error. here's my code
import board
import busio
import adafruit_vl53l0x
from Adafruit_SSD1306 import SSD1306_128_64
import time

# Initialize I2C bus and devices
i2c = busio.I2C(board.SCL, board.SDA)
vl53 = adafruit_vl53l0x.VL53L0X(i2c)
disp = SSD1306_128_64(rst=None)
disp.begin()
disp.clear()
disp.display()

while True:
distance = vl53.range
print(f"Distance: {distance} mm")

disp.clear()
if distance < 100:
disp.text("Warning: Too Close!", 0, 0, 1)
elif distance > 2000:
disp.text("Warning: Too Far!", 0, 0, 1)
else:
disp.text(f"Distance: {distance} mm", 0, 0, 1)
disp.display()

time.sleep(1)
import board
import busio
import adafruit_vl53l0x
from Adafruit_SSD1306 import SSD1306_128_64
import time

# Initialize I2C bus and devices
i2c = busio.I2C(board.SCL, board.SDA)
vl53 = adafruit_vl53l0x.VL53L0X(i2c)
disp = SSD1306_128_64(rst=None)
disp.begin()
disp.clear()
disp.display()

while True:
distance = vl53.range
print(f"Distance: {distance} mm")

disp.clear()
if distance < 100:
disp.text("Warning: Too Close!", 0, 0, 1)
elif distance > 2000:
disp.text("Warning: Too Far!", 0, 0, 1)
else:
disp.text(f"Distance: {distance} mm", 0, 0, 1)
disp.display()

time.sleep(1)
5 replies