UART Reading Serial Stream - Escape Sequences
-
@robert-hh OK, thank you. So by putting a 74HC04 in between the sensor and the LoPy, would I still need to shift 7 bits to the right via software, or is the 74HC04 sufficient to correct the issue?
-
@spookyrufus The inverter is sufficient. I just see I have a different module. It just looks similar.
-
@robert-hh Since in UART mode the input has a Pull-Up resistor, a single Transistor like the 2N7000 or the like should do it. The transistor has three legs, called D (Drain), S (Source) and G (Gate). Connect S to GND, D to the UART input (P4) and G to the sensor output. I verified that with a Pulse generator, and the waveform is in spec.

-
@robert-hh Thank you Robert. I appreciate very much you taking the time to explain me. I would have never figured out the issue myself, and still can't quite wrap my head around why they would decide to invert the serial signal on the sensor.
-
Hi, @spookyrufus i have the same issue reading MaxSonar sensor on LoPy with Expansion board. The solution is using RS232 converter IC https://www.sparkfun.com/products/11189
-
@tmz Hi thanks for the reply. Does this mean that you are powering your sensor with 5V then?
-
@tmz I would strongly object to use that solution, for a few reasons:
a) If by bad luck you connect the RS232 out to the LoPy/WiPy in, you might damage the LoPy, because RS232 out levels are +/-5V .. +/-12V, which is definitely outside the permittet range of -0.3 .. 3.6 V for inputs.
b) the logic levels of the converter on the RS232 input side do not match the 0..5V range. It may works, but could not be relaible.
c) price. A 74HC04 cost < 50 cent, a single transistor 10..20 cent, and available at almost every electronic shop. The board you show is 6$ + shipping. The single transistor could be directly attached to the Sonar board; no extra wiring. -
@robert-hh I will definitely try the transistor way. I just received an answer from MaxBotix official support, and what they replied is as follows:
"We are not familiar with the Pycom microcontrollers, however, we have seen similar issues on the Raspberry Pi. It appears that you need a serial inverter (RS232 to TTL) to interface with this microcontroller. Implementing a serial inverter should solve the issue you are seeing. "
Which I believe is compatible with what Robert is saying .
-
Transistor finally arrived (had to order it). Put it into place - solution works like a charm. Thanks Robert for the help, I appreciate it very much.
If some mod wants to mark the thread as [SOLVED], it'd be now good to do so. I tried doing it myself but could not find how to edit my thread's title. -
@spookyrufus It depends whthter you have a 736x or 738x model. When you operate the device from 3.3V, you shoul dbe able to connect the Serial out from the sensor directly to the Uart RX. If it is a 736x model, you'll need a Inverter, like you can do with a 2N7000: gate -> Sensor, Source -> GND, Drain -> RX, 10k Pullup-Resistor between RX and Vcc. You may also use an inverter chip, like 74hc04 ....
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login