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

    TEROS 12 and SDI-12

    Scheduled Pinned Locked Moved MicroPython
    teros12sdi-12
    41 Posts 7 Posters 6.0k Views 8 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.
    • T Offline
      tttadam @robert-hh
      last edited by

      @robert-hh said in TEROS 12 and SDI-12:

      RS485

      Can you recommend me a rs485 breakout board for pycom?
      All I can find has an usb port on the end.

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

        @tttadam search for "RS485 TTL breakout board". Most of the are made for 5V at the UART side, but some too for 3.3V.

        T 1 Reply Last reply Reply Quote 1
        • T Offline
          tttadam @robert-hh
          last edited by tttadam

          @robert-hh said in TEROS 12 and SDI-12:

          @tttadam search for "RS485 TTL breakout board". Most of the are made for 5V at the UART side, but some too for 3.3V.

          What I found is this sorry for the hungarian, but I need it ASAP, so I turned to local stores.
          I also found this image on online. I think they are the same. But its still not clear how should I use it because it has 4 wire on both side.
          alt text

          Thank you for the help.

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

            @tttadam It's not clear to me if that is easier to use than simply a one transistor level shifter. And so I would not use that choice.

            Besides that:
            Receiver Output -> Pycom RX
            The board operates at 5V, so you have to add at least a resistor of 4.7k to 10k between receiver Output and Pycom RX to protect the Pycom board.
            Driver Input -> Pycom TX
            Receiver Enable and Driver Enable can be switched together to a GPIO which is used to switch between receive and transmit.
            Data A and B are the differential output/inputs. And that makes the trouble, since the sensor has not differential data interface. Thats why in the post I linked there is a 1.8V reference, to create a virtual differential signal.
            5V and Ground are obvious.

            As said, I would prefer to connect RX and TX at the pycom device and connect it via a level shifter to the Sensor data line. You may need a pull-up resistor at the sensor to 5v, and in the software you will receive the commands that you have sent in addition to the response. In any case, it is not just plug and run.

            The obvious advantage of the RS485 version is it's ability to drive long wires.

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

              @robert-hh Alright, my knowledge is not so strong in this area, so I accept your recommendtation, no RS485 and level shifter it is. Thank you for the advice.
              So level shifters, I found this one.
              This is what was in your mind? If so, how would you wire it?

              robert-hhR 1 Reply Last reply Reply Quote 0
              • T Offline
                tvetter1976
                last edited by tvetter1976

                Regarding Level shifter. Take a look at this one:
                https://learn.sparkfun.com/tutorials/single-supply-logic-level-converter-hookup-guide/all
                and 3.3V RS485 Converter:
                https://eckstein-shop.de/RS485-Board-33V

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

                  @tttadam That one is OK. You need just one channel. LV to 3.3V, HV to 5V A1 to both RX and TX of the pycom device. B1 to the data line of the sensor.
                  You have still the task to make TX high impedance when you receive. So you can try:
                  a) to set up the UART to the desired mode, and then
                  b) init the PIN for TX as OPEN_DRAIN.
                  if that does not work, connect a diode (e.g. 1N4148 or 1N5711) between A1 of the level shifter to TX, such that the Cathode (the side with the bar) is at TX. That prevents the TX output from driving the signal when it is high. It still can sink the signal line.

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    Pesien @tttadam
                    last edited by

                    @tttadam That link is the pulses_get function, not the library.
                    I'll post the library on github once it works.

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

                      @Pesien I made a PR for inverted UART signals. It is here:
                      https://github.com/pycom/pycom-micropython-sigfox/pull/310

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

                        Okay, so I facing with this topic again. (I put it into the drawer for some time, but it's on my desk now again)
                        So I am using a level shifter.
                        Also if I am right I need to use an external power source to power the teros 12, I use a 1.5A usb brick.
                        But the wiring is still not clear to me.
                        This is what I come up with. I don't want to fry it so first I would like to ask the community. pic of the wireing
                        Thanks,

                        robert-hhR 3 Replies Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @tttadam
                          last edited by

                          @tttadam A diagram of the wiring with labels about what is what would be more helpful than a picture of a few wires.

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

                            @tttadam So, what you need is not only a level shifter. If you compare the interfaces you see quite a number of differences:
                            SDI-12:
                            a) Level 0 and 5 V
                            b) Halfduplex
                            c) Inverted
                            d) Load must be between 1 and 2 kOhm

                            WiPy:
                            a) Level 0 and 3.3 V
                            b) Full Duplex
                            c) Straight
                            d) Load > 200 Ohm

                            For a), a level shifter might work
                            for b) That has a hardware and software part. If you do the hardware right, if serves also for a) and c). The software part is easy. You just have to cope with the fact, that you will also receive what you have sent.
                            for c), you need to invert, unless you change the WiPy firmware
                            for d) minor problem.
                            So, lets look for a solution to that. What comes into my mind is a circuit with two transistors and a few resistors.
                            sdi12-shifter.jpg
                            Instead of the 2n7000 you can also use a small signal npn transistor (e.g. 2N3904, BC547), instead of the BS250 a small signal pnp transistor (e.g.2N3906, BC557). That circuit should shift the levels, invert the signals and provide a proper impedance for SDI-12. The ration of R3 and R5 has to be chosen, such that the SDI line is low when the TX line is high.

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

                              @tttadam Another variant with two optocouplers, which has the advantage that is completely isolates the SDI-12 wire from the WiPy. Given that these wires can be long, that may be useful.
                              sdi12-shifter-2.jpg
                              There are also devices with two couplers in one package, like the ILD74, but the CNY17 is more common. Since it is operated in a digital mode, the actual device is less critical.

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

                                You can still to use the serial output from the sensor and directily read the measurement using the UART. You don't need sdi12 at all. The only thing you need to is to switch on/off the senor. Then the sensor will send its measurement. The logic is not invereted. Why is this not an option for you? Also the digital output voltage output from Terros 12 is only 3.6V and not 5V.
                                From the manual:
                                http://manuals.decagon.com/Integrator Guide/18224 TEROS 11-12 Integrator Guide.pdf
                                "DDI SERIAL INTRODUCTION
                                The DDI serial protocol is the method used by the METER data loggers for collecting data from the sensor. This protocol uses the data line configured to transmit data from the sensor to the receiver only (simplex). Typically, the receive side is a microprocessor UART or a general-purpose I/O pin using a bitbang method to receive data. Sensor measurements are triggered by applying power to the sensor"

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

                                  @tvetter1976 Thanks for the manual. That is interesting, especially in that the signal levels deviate from the SDI-12 spec. But that should work. Nevertheless, I will give the adapter with the optocouplers a try. Not that I need it, but since I suggested it, I would like to know if it works. It's just one € value of parts, even in a local store. I like the idea of isolation. With cable lengths of 5 to 75 m, noise and spikes can get an issue.

                                  1 Reply Last reply Reply Quote 0
                                  • J Offline
                                    jmpratt @tttadam
                                    last edited by

                                    @tttadam I use two METER sensors with WiPy but I have them connected through a converter board. It communicates with the SDI-12 bus via the Pycom serial port.

                                    http://www.inmojo.com/store/liudr-arduino-and-physics-gadgets/item/sdi-12-serial-logger-shield/

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

                                      @robert-hh okay, I just hooked on an UART port with a level shifter.
                                      This is what I got:
                                      b'\x80\x00\x00\x80\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x80\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x80\x00\x80\x80\x00\x00\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x00\x00\x80\x80\x80\x00\x80\x80\x00\x00\x80\x00'

                                      But I am not sure, how does it make sense. Can you gave me some hint? :)

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

                                        @tttadam The Teros device only sends a UART message once after power on. Since according to the Teros data sheet the high level is 3.6V, you do not need the level shifter. In fact, the level shifter you use may make things worse.
                                        After the first message, the Teros device changes the polarity. That will be seen by the UART as start bit, and so it will constantly try to receive bytes. WIth the given set-up, you only can receive one message after power up of the Teros devuice, and then you must discard every else until the next power cycle of the Teros device.

                                        robert-hhR T 2 Replies Last reply Reply Quote 0
                                        • robert-hhR Offline
                                          robert-hh @robert-hh
                                          last edited by robert-hh

                                          @robert-hh I made a breadboard set-up with the optocouplers according to the schematics below. Since I do not have a SDI-12 device, I can only rate it by the intrinsic loop-back (what is sent, will also be received). The picture below shows the timing: yellow is Tx, green is the SDI-12 bus line, pink is RX. The optocoupler used is a 4N27 device. The voltage at the SDI-12 line is 5V. But due to the isolation, that does not matter much. Only the resistor values may have to be adapted.

                                          4n27.jpg

                                          For that set-up, I changed the resistor values a little bit. The 4N27 has a relatively low current transfer ratio, which required a lower value of R8. A 4N25 might work better. The new schematics is below. R10 improves the switch off timing, R11 the off level.

                                          sdi12-shifter-2.jpg

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

                                            @tttadam Now the set-up with the transistor circuit. I added Q3 as level shifter to the output branch. The circuit is now:

                                            sdi12-shifter.jpg

                                            Timing diagram with colors as before (yellow: Tx, green SDI12 bus, pink Rx:

                                            transistor.jpg

                                            Transitions are much faster.

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

                                            Pycom on Twitter

                                            Pycom