I have a WiPy board (1.3) and i'd like to connect to my home network with it, so i could send data via socket to my home server without any internet connection. I have this board almost a year ago, but i have the freetime to use it just now. When i bought it i found some methods in the documentation that i could run any *py file. (For example "run myScript.py" or something like that) and i can't seem to find it anymore, not even the 1.3 documentation for WiPy. Here's my code for connecting to the router:
wlan = WLAN(mode=WLAN.STA)
# go for fixed IP settings
wlan.ifconfig(config=('dhcp'))
wlan.scan() # scan for available networks
wlan.connect(ssid='mySsid', auth=(WLAN.WPA2, 'somePassword'))
while not wlan.isconnected():
pass
I don't want to put the code into main.py or boot.py because i'm not always using the WiPy at home, and i can connect to it only with Wi-Fi, so it would be trouble some when i'm not at my home network.
PS: I'm new to the forum, nice to meet you all. Searched for this already, but couldn't really find anything, so i hope its okay to ask that.
Run file via MicroPython prompt
Re: Run file via MicroPython prompt
Hi and welcome to the forum! Make yourself at home :)
In order to run your scripts on WiPy, you need to have them uploaded onto the board. There's a number of ways of doing this, but using the FTP client is the easiest in my opinion. See http://docs.micropython.org/en/latest/w ... ftp-access for details.
Once you uploaded your myScript.py you can use "import myScript" directly from your main.py or from REPL. You can import selectively by using "from myScript import myClass", if you wish. The import call will load your code in and all classes/functions will be available.
Hope this answers your question!
In order to run your scripts on WiPy, you need to have them uploaded onto the board. There's a number of ways of doing this, but using the FTP client is the easiest in my opinion. See http://docs.micropython.org/en/latest/w ... ftp-access for details.
Once you uploaded your myScript.py you can use "import myScript" directly from your main.py or from REPL. You can import selectively by using "from myScript import myClass", if you wish. The import call will load your code in and all classes/functions will be available.
Hope this answers your question!
-
- Posts: 38
- Joined: Mon May 16, 2016 6:35 pm
Re: Run file via MicroPython prompt
Put the code to configure the device in a module in the lib directory. Then import and run the function to configure it from the repl.
Sent from my SM-G920T using Tapatalk
Sent from my SM-G920T using Tapatalk
Re: Run file via MicroPython prompt
You can also run files by using pyboard.py found in the tools directory:
https://github.com/micropython/micropyt ... pyboard.py
You can run:
https://github.com/micropython/micropyt ... pyboard.py
You can run:
Code: Select all
pyboard.py IP-address somefile.py