Bad Ultrasonic distance measure
-
My ultrasonic sensor reports a bad distance. For example, I measure to the ceiling of the room, and it reports 80 cm where it is above 2 meters.
I have:
- a Ultrasonic range sensor
- a M5 CoreInk. The sensor is connected on GPIO 32 and 33.
This is how I do it. Can you tell me what's wrong or an idea how to debug? thx
#define M5_I2C_ADDR_ULTRASONIC 0x57 Ink_Sprite InkPageSprite(&M5.M5Ink); void setup() { M5.begin(); //Init CoreInk. digitalWrite(LED_EXT_PIN,LOW); if( !M5.M5Ink.isInit()) //Init CoreInk screen. { Serial.printf("[-] M5Ink init failed"); while (1) delay(100); } Wire.begin(32,33); Serial.printf("[+] Wire begin done\n"); M5.M5Ink.clear(); //Clear screen. Serial.printf("[+] Clearing eInk screen\n"); delay(1000); if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){ Serial.printf("[-] Ink Sprite create failed"); } } void loop() { static float distance = 0; distance = readDistance(); Serial.printf("Distance=%.1f cm\n",distance); if ((distance < 150) && (distance > 0)) { char buffer[30]; sprintf(buffer,"%.1f cm",distance); InkPageSprite.drawString(15,150,buffer,&AsciiFont24x48); InkPageSprite.pushSprite(); } // Sleep delay(2000); }
-
@aafortinet after more measures, the ultrasonic sensors seems to work correctly. It's just that (1) the units in my program were wrong, (2) it does not work below 2cm and above 150 and gives erroneous answer then. This range isn't very big, and typically I measured 2m.
-
Which kind of sensor are you using? is the ultrasonic unit?
https://shop.m5stack.com/products/ultrasonic-distance-unit-i-o-rcwl-9620?variant=42084187930881 -
@aafortinet A mate of mine had the same issue -- seemed not to work until he used it within the 2-150cm parameters. The all good.