apef
02/07/2024, 8:26 PMimport serial.ports.uart show Port
, as serial.ports could not be found, to uart show Port
instead. If this was a mistake (and what lead to our problem), then any help to import serial.ports would be appreciated.
When running the example file that is provided with the package (to simply read and output the distance values from the sensor in the terminal), the code seems to stop on this line: msg := "{\"range\": $(dyp.range)}"
which we've narrowed down to the blocking happening on line 40 in the package dyp_a01.toit file --> frame := port.read
. The read function (from the standard library 'uart') is blocking until data is available, according to the documentation.
The sensor is connected to an ESP-WROOM-32, to pins: VIN(5v), RX2 (pin17), TX2 (pin16), GND. The sensor works, it has been verified to be functioning correctly when tested in C with ESP-IDF.floitsch
02/08/2024, 8:17 AMimport
change is correct.
Let me see if I can find documentation about the DYP-A02floitsch
02/08/2024, 8:27 AMimport
change).floitsch
02/08/2024, 8:28 AMfloitsch
02/08/2024, 8:28 AMfloitsch
02/08/2024, 8:32 AMfloitsch
02/08/2024, 8:33 AMimport gpio
import uart
main:
rx := gpio.Pin 16 // Labeled as TX on the sensor.
port := uart.Port --rx=rx --baud-rate=9600 --tx=null
while true:
data := port.read
print "received: $data"
apef
02/08/2024, 12:52 PMfloitsch
02/08/2024, 12:55 PMfloitsch
02/08/2024, 12:56 PMfloitsch
02/08/2024, 12:56 PMfloitsch
02/08/2024, 12:58 PMfloitsch
02/08/2024, 12:58 PMapef
02/08/2024, 1:02 PMfloitsch
02/08/2024, 6:18 PMfloitsch
02/08/2024, 6:19 PMapef
02/08/2024, 6:45 PMfloitsch
02/09/2024, 6:28 AM