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)
-
@joena said in LoPy on corporate WiFi and using Tx/Rx commands:
Question 1:
this can point to two scenarios
- 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 ;-) - 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-02Question 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
- All lopys connect to server and i can think that this is the basic and simplest scenario
-
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.
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
-
for your reply livius :)
-
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 0DWith kind regards, Jeroen
-
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!
-
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 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
-
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 :-)
-
Something like this jmarcelino? The VCC would be the 3.3Vout of the LoPy. The chip is the MAX3232.
Grts, Jeroen
-
@joena
yes that should do it!Let us know how it goes :)
-
Just to inform, i will be testing it not today, but tomorrow (today I've ordered the max3232 unit), hope it arrives tomorrow ;)
-
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
-
-
The way @livius wrote is the most generic way but because 0x0D is a carriage return in ASCII you can just use
\rat the end of the string. -
Hi livius, Hi jmarcelino,
Thx for your tips... Great news (at least for me ;-)), the first step in my end goal is working :-)

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