Running Ultrasonic click on UART protocol
Running Ultrasonic click on UART protocol
I am trying to run the ultrasonic click:https://www.mikroe.com/ultrasonic-2-click using UART protocol.However my program is just returning 0.
Can someone please have a look at my code and tell me where I may be going wrong.
Code:https://github.com/Yadnik1/Ultrasonic-U ... %20uart.py
Thank you very much.
Can someone please have a look at my code and tell me where I may be going wrong.
Code:https://github.com/Yadnik1/Ultrasonic-U ... %20uart.py
Thank you very much.
Re: Running Ultrasonic click on UART protocol
Do you have a datasheet for this device, or a reference driver (e.g. Arduino) that implements the protocol?
Re: Running Ultrasonic click on UART protocol
Yes the link to the data sheet is : https://download.mikroe.com/documents/d ... 460-Q1.pdf
The library can be found at the end of this forum in zip format : https://e2e.ti.com/support/sensors-grou ... nd-arduino
Thank you very much!!
The library can be found at the end of this forum in zip format : https://e2e.ti.com/support/sensors-grou ... nd-arduino
Thank you very much!!
Re: Running Ultrasonic click on UART protocol
ThanksYadnik wrote: ↑Fri Aug 06, 2021 4:02 amYes the link to the data sheet is : https://download.mikroe.com/documents/d ... 460-Q1.pdf
The library can be found at the end of this forum in zip format : https://e2e.ti.com/support/sensors-grou ... nd-arduino
Your code doesn't send a full command, just the sync byte. That forum post you linked to has a minimal example that shows the full payloads you need to send.
Re: Running Ultrasonic click on UART protocol
I did incorporate the changes in my code from the code : https://e2e.ti.com/support/sensors-grou ... nd-arduino
However I am yet getting the same error i.e. my program returns only 0's
Can you please have a look at my code:https://github.com/Yadnik1/Ultrasonic-C ... %20uart.py and please tell what mistakes I may be making.
However I am yet getting the same error i.e. my program returns only 0's
Can you please have a look at my code:https://github.com/Yadnik1/Ultrasonic-C ... %20uart.py and please tell what mistakes I may be making.
Re: Running Ultrasonic click on UART protocol
I don't think the code (example, there are many like this) is doing what you think it is:
b'\buf10' is likely to output b'\x08uf10', or the characters backspace u f 10 in sequence
bytes(buf10) should send b'U\n&\x00\xcf', which is probably more along the lines of what you want.
Code: Select all
buf10=bytearray(256)
…
buf10= (0x55, 0x0A, 0x26, 0x00, 0xCF)
…
uart.write(b'\buf10')
bytes(buf10) should send b'U\n&\x00\xcf', which is probably more along the lines of what you want.
Re: Running Ultrasonic click on UART protocol
I tried using bytes(buf10),however that gives me an error saying SyntaxError: can't assign to expression. My code currently looks like this:https://github.com/Yadnik1/Ultrasonic-C ... %20uart.py .
Can you please have a look and please tell me any alternative of assigning the hexadecimal values to the buffer.
Thank you very much!!
Can you please have a look and please tell me any alternative of assigning the hexadecimal values to the buffer.
Thank you very much!!
Re: Running Ultrasonic click on UART protocol
Yeah, you're doing that wrong. A way to do it (like I showed you) is:
and when you need to use it, refer to
Also, please don't link to entire programs: post a minimal failing example in code tags. It's rather rude to expect people to scurry off and look at all your code and work out what's wrong with it. Also, isolating the smallest non-working part helps you understand the problem. Don't make it hard to be helped.
Code: Select all
buf10= (0x55, 0x0A, 0x26, 0x00, 0xCF)
Code: Select all
bytes(buf10)
Re: Running Ultrasonic click on UART protocol
Sorry scruss,
I will only post the part of code that does not work now onwards.
I will only post the part of code that does not work now onwards.
Re: Running Ultrasonic click on UART protocol
I think this what you were saying:
utime.sleep_ms(1)
uart.write(bytes(buf25))
utime.sleep_ms(1)
uart.write(bytes(buf10))
utime.sleep_ms(1)
However this also is returning only 0's, any other suggestions you have.
Thank you!!
utime.sleep_ms(1)
uart.write(bytes(buf25))
utime.sleep_ms(1)
uart.write(bytes(buf10))
utime.sleep_ms(1)
However this also is returning only 0's, any other suggestions you have.
Thank you!!