<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=47&amp;t=24612&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2024-01-22T17:39:40+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=47&amp;t=24612&amp;mode</id>
<entry>
<author><name><![CDATA[tommot]]></name></author>
<updated>2024-01-22T17:39:40+01:00</updated>
<published>2024-01-22T17:39:40+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237834#p237834</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237834#p237834"/>
<title type="html"><![CDATA[Re: ultrasonic A02YYUW dalmierz problem z odczytem]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237834#p237834"><![CDATA[
problem prawdopodobnie jest bufor portu Serial zapełnia sie i musi być odczytany w całości <br />Temat już nie aktualny przeszedłem na inny czujnik<br />pozdrawiam<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=15541">tommot</a> — 22 sty 2024, o 17:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[tommot]]></name></author>
<updated>2024-01-07T12:20:52+01:00</updated>
<published>2024-01-07T12:20:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237803#p237803</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237803#p237803"/>
<title type="html"><![CDATA[ultrasonic A02YYUW dalmierz problem z odczytem]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24612&amp;p=237803#p237803"><![CDATA[
Witam <br />Nie mogę sobie dać rady z prawidłowym odczytem danych <br />Chce odczytać dane wysłać na serial i odczekać np 1sek Problem w tym że dane docierają z 'opóźnieniem' tz pomiar dostaje co sekunde ale po 6-7 sekundach jest on prawidłowy<br />i niewiem gdze leży problem <br /><br /><br />proszę o zerkniecie w kod <br /><br /><br />[syntax=c]#include &lt;Arduino.h&gt;<br />#include &lt;U8g2lib.h&gt;<br />#include &lt;SPI.h&gt;<br />//#include &lt;Wire.h&gt;<br />#include &lt;SoftwareSerial.h&gt;<br /><br /><br />//******komunikacja RADAR****<br />int pinTX = 0;<br />int pinRX = 1;<br />//***************************<br /><br />///////////////////////////////////////// Define connections to sensor<br />// Array to store incoming serial data<br />unsigned char data_buffer&#91;4&#93; = {0};<br />// Integer to store distance<br />int distance = 0;<br />// Variable to hold checksum<br />unsigned char CS;<br />// Object to represent software serial port<br />SoftwareSerial dalmierz(pinRX, pinTX);<br />/////////////////////////////////////<br /><br />int progress = 0; // progress of the progressbar<br /><br /><br />void test (){<br /> /////////////dalmierz///////////////////////////////////<br />// Run if data available<br />//Serial.print(&quot;distance: &quot;);<br />  if (dalmierz.available() &gt; 0) {<br />//Serial.println(&quot;cos3&quot;);<br />    delay(4);<br /><br />    // Check for packet header character 0xff<br />    if (dalmierz.read() == 0xff) {<br />      // Insert header into array<br />      data_buffer&#91;0&#93; = 0xff;<br />      // Read remaining 3 characters of data and insert into array<br />      for (int i = 1; i &lt; 4; i++) {<br />        data_buffer&#91;i&#93; = dalmierz.read();<br />        <br />      }<br /><br />      //Compute checksum<br />      CS = data_buffer&#91;0&#93; + data_buffer&#91;1&#93; + data_buffer&#91;2&#93;;<br />      // If checksum is valid compose distance from data<br />      if (data_buffer&#91;3&#93; == CS) {<br />        distance = (data_buffer&#91;1&#93; &lt;&lt; 8) + data_buffer&#91;2&#93;;<br />        distance = distance/10;<br />        progress = distance;<br />        // Print to serial monitor<br />       <br />      }<br />      //Serial.println(&quot;cos1&quot;);<br />    }<br />   // Serial.println(&quot;cos2&quot;);<br />  }<br />  <br />//return distance;<br />  <br />}<br /><br /><br /><br /><br />void setup() {<br />  // put your setup code here, to run once:<br />Serial.begin(115200);<br /> dalmierz.begin(9600);<br /> delay(1000);<br />}<br /><br />void loop() {<br /> test();<br /> Serial.print( data_buffer&#91;0&#93; ,HEX ); Serial.print( data_buffer&#91;1&#93; ,HEX ); Serial.print( data_buffer&#91;2&#93; ,HEX ); Serial.print( data_buffer&#91;3&#93; ,HEX ) ;<br />  Serial.print(&quot; distance: &quot;);<br />        Serial.print(distance);<br />        Serial.println(&quot; cm&quot;);<br />       // Serial.println(dalmierz.read());<br />        delay(1000);<br />///////////////////////////////////////////////////////<br />  // put your main code here, to run repeatedly:<br /><br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=15541">tommot</a> — 7 sty 2024, o 12:20</p><hr />
]]></content>
</entry>
</feed>