<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bad Ultrasonic distance measure]]></title><description><![CDATA[<p dir="auto">My ultrasonic sensor reports a <strong>bad distance</strong>. For example, I measure to the ceiling of the room, and it reports 80 cm where it is above 2 meters.</p>
<p dir="auto">I have:</p>
<ul>
<li>a <strong>Ultrasonic</strong> range sensor</li>
<li>a M5 <strong>CoreInk</strong>. The sensor is connected on GPIO 32 and 33.</li>
</ul>
<p dir="auto">This is how I do it. Can you tell me what's wrong or an idea how to debug? thx</p>
<pre><code class="language-c">#define M5_I2C_ADDR_ULTRASONIC 0x57
Ink_Sprite InkPageSprite(&amp;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 &lt; 150) &amp;&amp; (distance &gt; 0)) {
      char buffer[30];
      sprintf(buffer,"%.1f cm",distance);
      InkPageSprite.drawString(15,150,buffer,&amp;AsciiFont24x48);
      InkPageSprite.pushSprite();
  }

  // Sleep 
  delay(2000);
}</code></pre>
]]></description><link>https://community.m5stack.com/topic/4154/bad-ultrasonic-distance-measure</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 23:04:34 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4154.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Mar 2022 17:23:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bad Ultrasonic distance measure on Wed, 30 Mar 2022 01:31:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aafortinet" aria-label="Profile: aafortinet">@<bdi>aafortinet</bdi></a>  A mate of mine had the same issue -- seemed not to work until he used it within the 2-150cm parameters. The all good.</p>
]]></description><link>https://community.m5stack.com/post/17051</link><guid isPermaLink="true">https://community.m5stack.com/post/17051</guid><dc:creator><![CDATA[creakygate]]></dc:creator><pubDate>Wed, 30 Mar 2022 01:31:38 GMT</pubDate></item><item><title><![CDATA[Reply to Bad Ultrasonic distance measure on Tue, 29 Mar 2022 15:08:55 GMT]]></title><description><![CDATA[<p dir="auto">Which kind of sensor are you using? is the ultrasonic unit?<br />
<a href="https://shop.m5stack.com/products/ultrasonic-distance-unit-i-o-rcwl-9620?variant=42084187930881" target="_blank" rel="noopener noreferrer nofollow ugc">https://shop.m5stack.com/products/ultrasonic-distance-unit-i-o-rcwl-9620?variant=42084187930881</a></p>
]]></description><link>https://community.m5stack.com/post/17044</link><guid isPermaLink="true">https://community.m5stack.com/post/17044</guid><dc:creator><![CDATA[Genio]]></dc:creator><pubDate>Tue, 29 Mar 2022 15:08:55 GMT</pubDate></item><item><title><![CDATA[Reply to Bad Ultrasonic distance measure on Tue, 29 Mar 2022 06:42:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aafortinet" aria-label="Profile: aafortinet">@<bdi>aafortinet</bdi></a> 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.</p>
]]></description><link>https://community.m5stack.com/post/17043</link><guid isPermaLink="true">https://community.m5stack.com/post/17043</guid><dc:creator><![CDATA[aafortinet]]></dc:creator><pubDate>Tue, 29 Mar 2022 06:42:09 GMT</pubDate></item></channel></rss>