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

    LoPy on corporate WiFi and using Tx/Rx commands **SOLVED**

    Scheduled Pinned Locked Moved LoPy
    lopywifiuartsolved
    23 Posts 5 Posters 7.8k Views 6 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.
    • L Offline
      livius @joena
      last edited by

      @joena said in LoPy on corporate WiFi and using Tx/Rx commands:

      Question 1:

      this can point to two scenarios

      1. All lopys connect to server and i can think that this is the basic and simplest scenario
        and work without any problem - you do not find them only them find you ;-)
      2. If your tool need to find them than basic steep is to set all Lopy unique but prefixed name (maybe default is ok for you) and then after connection you can add some autorization. You can of course use fixed mac list but if this is for developing purpose then use simplest posible way for you.

      HINT - Do not use Pymakr at all
      https://forum.pycom.io/topic/635/pymakr-time-of-death-09-02

      Question 2:
      use standard documentation for uart
      https://docs.pycom.io/pycom_esp32/library/machine.UART.html

      • it work for me without problem - but i do not use flow control
        i read somwhere on the forum that flow control not work properlyu and i do not know i it is fixed now

      think about people first, then computers

      1 Reply Last reply Reply Quote 0
      • B Offline
        bucknall @joena
        last edited by

        Hi @joena,

        What I normally do, is place a snippet of code at the end of my boot.py -

        wlan.ifconfig()
        

        This tells me what the IP address of my device when it has connected to my WiFi network.

        You can also set a static IP address for the device so it's the same everytime you connect to the network.

        (https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/wlan.html#assigning-a-static-ip-address-when-booting)

        Question 2:

        Yes! I've recently been talking to the LoPy from a Raspberry Pi (https://github.com/Bucknalla/lopy-raspberrypi) I need to push this code to the documentation but it's a fairly straightforward process. Just make sure that you wire the TX & RX correctly! :)

        Let me know how you get on with this!

        Cheers,

        Alex

        Developer Evangelist - Pycom

        J 1 Reply Last reply Reply Quote 1
        • J Offline
          joena
          last edited by

          for your reply livius :)

          1 Reply Last reply Reply Quote 0
          • J Offline
            joena @bucknall
            last edited by

            @bucknall

            Hi Bucknall, thx for your reply ... :)
            When reading my original post I forgot to mention something essential (for question 2). I don't want to control the LoPy via another device, I want the LoPy to control another device (a lcd projector).

            What is the easiest method to sent a hex code via Tx (rs232) to my projector using a LoPy?

            I hope you can help me out, or point me into the right direction...
            In your example I saw lorawan, but If I want to do it using UART is this also possible?

            Tx:
            my ascii code is: POWR 1%0D
            the hex code is: 50 4F 57 52 20 20 20 31 0D

            With kind regards, Jeroen

            B J 2 Replies Last reply Reply Quote 0
            • B Offline
              bucknall @joena
              last edited by

              Hi @joena,

              Absolutely! So let me just confirm - You wish to control an LCD projector via rs232 from the LoPy?

              You can do this using the UART class:

              from machine import UART
              lcd_projector = UART(1) 
              
              lcd_projector.init(9600, bits=8, parity=None, stop=1) # you may need specific options
              lcd_projector.write(your_data)
              

              You will need to ensure that your wiring goes between TX & RX [P3/P4 (lopy), G11/G24 (expansion board)] to your projector

              Let me know how that goes!

              Developer Evangelist - Pycom

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jmarcelino @joena
                last edited by

                @joena

                To add to @bucknall's reply, the UART connections will give you 3.3 volt level serial however true RS-232 - what most projectors expect - use up to +15/-15V levels so you'll need an extra driver chip like the MAX3232.

                If you look on Ebay you can find many cheap MAX3232 modules. Then connect your LoPy UART to those and from there to your projector.

                J 2 Replies Last reply Reply Quote 1
                • J Offline
                  joena @bucknall
                  last edited by

                  @bucknall

                  Hi bucknall, thx so much for your quick answer/response. Yes i want to control the projector with the LoPy ;-) for now Tx signals/commands are great, if all works out I want to implement Rx to read out projector status, like lamp hours, on/off status, etc.

                  Your response looks promising .. I will implement it tomorrow at work (I just got out of work ;-))

                  I will let you/the community know if it worked :-) thx for now, Jeroen

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    joena @jmarcelino
                    last edited by

                    @jmarcelino

                    Aah thx jmarcelino, I will keep this in mind. Thx for this pointer, jeroen

                    http://www.radio-electronics.com/info/telecommunications_networks/rs232/signals-voltages-levels.php

                    I learned something today :-)

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      joena @jmarcelino
                      last edited by joena

                      @jmarcelino alt text

                      Something like this jmarcelino? The VCC would be the 3.3Vout of the LoPy. The chip is the MAX3232.

                      Grts, Jeroen

                      J 1 Reply Last reply Reply Quote 1
                      • J Offline
                        jmarcelino @joena
                        last edited by

                        @joena
                        yes that should do it!

                        Let us know how it goes :)

                        J 1 Reply Last reply Reply Quote 0
                        • J Offline
                          joena @jmarcelino
                          last edited by

                          @jmarcelino
                          @bucknall

                          Just to inform, i will be testing it not today, but tomorrow (today I've ordered the max3232 unit), hope it arrives tomorrow ;)

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            joena
                            last edited by joena

                            Totday the MAX3232 breakout box arrived and serial data is succesfully sent to the rs232 port :-) So great (I used a free dataviewer tool, from Extron to check this). Only one question:
                            I can sent the ASCII Power ON commando, but after each command I have to sent the execute code to the projector, this is the hex command: %0D (for our type projector). What syntax in python is correct to accomplish this? I used these lines:

                            from machine import UART
                            lcd_projector = UART(1)
                            lcd_projector.init(9600, bits=8, parity=None, stop=1)
                            lcd_projector.write('POWR 1')

                            I can see the correct code (if I use the data viewer), but the problem is that the code isn't executed. Can I use ASCII and HEX in one line??

                            If I hard code append it, the projector sees this as a sort of variable/string.. This is not correct

                            Grts, Jeroen

                            L 1 Reply Last reply Reply Quote 0
                            • L Offline
                              livius @joena
                              last edited by

                              @joena

                              to write letters e.g. "HI"

                              uart.write(bytes([0x48,0x49]))
                              

                              think about people first, then computers

                              J 1 Reply Last reply Reply Quote 0
                              • J Offline
                                jmarcelino @livius
                                last edited by jmarcelino

                                The way @livius wrote is the most generic way but because 0x0D is a carriage return in ASCII you can just use \r at the end of the string.

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  joena
                                  last edited by joena

                                  Hi livius, Hi jmarcelino,

                                  Thx for your tips... Great news (at least for me ;-)), the first step in my end goal is working :-)

                                  alt text

                                  It is now possible for me to turn on a projector (or any other command(s)) via WiFi using the LoPy and the MAX3232 board.

                                  For reference and other people interested this is the code for main.py... (boot.py is unaltered)

                                  from machine import UART
                                  projector = UART(1)
                                  projector.init(baudrate=9600, bits=8, parity=None, stop=1)
                                  projector.write('POWR 1\r')

                                  from machine import Pin
                                  led = Pin("G16", mode=Pin.OUT)
                                  button = Pin("G17", mode=Pin.IN, pull=Pin.PULL_UP)

                                  while True:
                                  led(button())

                                  Next step will be:

                                  • A (couple of) button(s) hard wired directly to the LoPy to give more functionality.
                                  • Read out projector status (lamp hours, active input, etc.) and doing something with this info.
                                  • Implement the LoPy on the corporate open WiFi network and finding the LoPy back.
                                  • Using LoRa instead of WiFi in a point-to-point configuration (I preferer this over WiFi).
                                  • Design/program a webbased managing tool to control lots (max 100) devices.
                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    DDA @joena
                                    last edited by

                                    @joena
                                    I have two of those MAX3232 modules and its not working, I initially thought I had it figured out. So to test further I have the MAX3232 breakout box powered by the Expansion boards 2.0 VCC and GND, which would be 3.3VDC. Then I looped the TX and RX as loop back on the module with no Pycom unit, and connected to my PC's COM port. When I send an escape or other character I see a flicker on the TX and RX LED on the breakout board but no loop back response on my TeraTerm terminal, which is set to 9600, 8,none,1. What seems to be wrong, I tried both my MAX3232 modules from amazon...same result.
                                    https://www.amazon.com/gp/product/B01JYNHNW6/ref=oh_aui_detailpage_o04_s00?ie=UTF8&psc=1
                                    Thank you.

                                    J 1 Reply Last reply Reply Quote 0
                                    • J Offline
                                      jmarcelino @DDA
                                      last edited by

                                      @dda
                                      Vcc (do you mean Vin?) on the expansion board is actually 5V. You need a Pycom module (WiPy, LoPy, etc) to regulate that into 3.3V on the separate 3V3 pin.

                                      D 2 Replies Last reply Reply Quote 0
                                      • D Offline
                                        DDA @jmarcelino
                                        last edited by DDA

                                        @jmarcelino
                                        I meant, I used the Vout of the expansion board(3.3VDC) and GND to power the MAX3232 break out board, it has a LoPy plugged in with no code( os.mkfs was used to make sure its not running any)...the expansion board is powered via the USB port. I can see the breakout board is receiving 3.3VDC.

                                        J 1 Reply Last reply Reply Quote 0
                                        • J Offline
                                          jmarcelino @DDA
                                          last edited by jmarcelino

                                          @dda
                                          Ok maybe I misunderstood what you meant by “with no Pycom unit”, but if you really have no Pycom module you will not have 3.3V from the expansion board alone (other than perhaps some parasitic powering from the Tx/RX pins)

                                          D 2 Replies Last reply Reply Quote 0
                                          • D Offline
                                            DDA @jmarcelino
                                            last edited by

                                            @jmarcelino
                                            Also, I made sure my echo is ON, on my PC. When I manually short DB9 connectors( Com1) pin2 & 3 without the breakout MAX3232 board, any character I send is echoed back on to my TeraTerm terminal. When I connect the same DB9 to my breakout board and short the Tx and Rx on the MAX3232 which is powered via the expansion with LoPy no loopback echo is observed. Lopy is just there to make the voltage out of the expansion 2.0 functional.

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

                                            Pycom on Twitter

                                            Pycom