Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    UART Reading Serial Stream - Escape Sequences

    Scheduled Pinned Locked Moved Discussion
    uartescape sequencserial escape
    18 Posts 4 Posters 4.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      spookyrufus @robert-hh
      last edited by

      @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?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @spookyrufus
        last edited by

        @spookyrufus The inverter is sufficient. I just see I have a different module. It just looks similar.

        robert-hhR 1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @robert-hh
          last edited by robert-hh

          @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.
          0_1507220818541_2N7000.jpg

          S 1 Reply Last reply Reply Quote 1
          • S Offline
            spookyrufus @robert-hh
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • T Offline
              tmz
              last edited by

              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

              S robert-hhR 2 Replies Last reply Reply Quote 0
              • S Offline
                spookyrufus @tmz
                last edited by

                @tmz Hi thanks for the reply. Does this mean that you are powering your sensor with 5V then?

                1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @tmz
                  last edited by

                  @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.

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    spookyrufus @robert-hh
                    last edited by

                    @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 .

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      spookyrufus
                      last edited by spookyrufus

                      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.

                      1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @spookyrufus
                        last edited by robert-hh

                        @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 ....

                        1 Reply Last reply Reply Quote 0

                        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
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom