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

  • Hi there, I'm new to the LoPy environment and have two questions.

    ps. I've succesfully upgraded my LoPy to the latest filmware and followed the basic steps to get my LoPy working (the stoplight example, in the examples section, provider by Pycom, is working :)) ... I can access my LoPy (with the Pycom Expansion Board) by direct serial-usb cable and by AP (Access Point/WiFi hotspot)

    Question 1:
    My next step (because I want to access my LoPy from a distance, and I'm not ready yet to use lora) is to connect the LoPy by WiFi (Corporate WiFi). I can manage this, but how do you find the LoPy back in the wireless network?
    For example, when I use the Pymkr IDE, how can I connect to/find the LoPy when it's in 'the cloud'? I can imagine you use an unique IP number, but when it's dynamic, the IP changes. Or perhaps do you use the unique LoPy name or perhaps a MAC Address?
    My goal will be a couple of LoPy's in a corporate WiFi with one manage tool. The manage tool will be webbased and programmed by html/python (custom made).

    Question 2:
    Are there any examples out there, or perhaps people with experience that succesfully used the UART of the LoPy?
    I want to transmit (hard connection/wiring) Tx (serial data) commands to the LoPy. Also Rx data is important for my. But first the basics ;-)

    I hope someone can help me out, or point me in the right direction... With kind regards, Jeroen Wolf (from the Netherlands)

  • @jmarcelino
    [Solved ]
    Resolved, used a different power supply unit and it worked. I guess even though I was getting enough juice of 3.3VDC out of the Expansion board with a LoPy current was not enough.
    Thanks much!

  • @jmarcelino
    Sorry for the confusion, when I meant with no Pycom unit I meant I was not using the Pycom modules for communication test with the MAX3232....the PC's COM port and Tera term is being used for initail MAX3232 communication test . The expansion 2.0 board has a Lopy plugged with no code, to make sure the expansion board spits out the Vout of 3.3VDC. Once I verify the MAX3232 communication functionality, I will add the LoPy to the communicate with third part UART communication

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

  • @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)

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

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

  • @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.
    Thank you.

  • 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:

    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.

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

  • @joena

    to write letters e.g. "HI"


  • 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

  • @jmarcelino

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

  • @joena
    yes that should do it!

    Let us know how it goes :)

  • @jmarcelino alt text

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

    Grts, Jeroen

  • @jmarcelino

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


    I learned something today :-)

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

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

  • 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

    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!

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

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

    With kind regards, Jeroen

Pycom on Twitter