im getting <none> as response.... and it is supost to get a array...
i can figure it out
UART
-
- Posts: 7
- Joined: Fri Jul 29, 2022 5:47 pm
Re: UART
Now i get "none" again as a response. Maybe its some error in the connections i made but i don't think so:
Tx and Rx connected to the TX2 and RX2 os the esp32
The Receiver enable and Driver enable are both connected to GPIO23
vin serving as power supply to the max485 converter
Tx and Rx connected to the TX2 and RX2 os the esp32
The Receiver enable and Driver enable are both connected to GPIO23
vin serving as power supply to the max485 converter
Re: UART
So you're using a RS485 connection, which explains the sleep(1) in the code. But sleep(1) may be too long. You have to switch the direction immediately after sending. At 9600, sending 1 byte takes about 1 ms.So the sleep time would be roughly:
utime.sleep_ms(len(hex) + 1)
or whatever msg you send. Or if the value of the baudrate is in the variable baud, you could estimate the sleep time as:
sleep_time_ms = len(msg) * 1_000 * 10 // baud + 1
You may have to align the sleep time a little bit. For actions like these a low cost logic analyzer (~12 USD) is extremely valuable. It#s almost impossible to get the timing right without being able to measure the timing.
Sample links for the logic analyzer, to explain, what I mean:
https://www.amazon.com/-/de/dp/B07KW445 ... 73&sr=8-13
As software for the logic analyzer, you can use Saleae Logic or Pulseview.
utime.sleep_ms(len(hex) + 1)
or whatever msg you send. Or if the value of the baudrate is in the variable baud, you could estimate the sleep time as:
sleep_time_ms = len(msg) * 1_000 * 10 // baud + 1
You may have to align the sleep time a little bit. For actions like these a low cost logic analyzer (~12 USD) is extremely valuable. It#s almost impossible to get the timing right without being able to measure the timing.
Sample links for the logic analyzer, to explain, what I mean:
https://www.amazon.com/-/de/dp/B07KW445 ... 73&sr=8-13
As software for the logic analyzer, you can use Saleae Logic or Pulseview.