Can anyone tell how to put .py file into the 8266?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
41536172@qq.com
Posts: 11
Joined: Sun May 08, 2016 3:41 pm

Can anyone tell how to put .py file into the 8266?

Post by 41536172@qq.com » Mon May 09, 2016 2:38 pm

i want to put my .py file into the 8266 instead of use the REPL.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Can anyone tell how to put .py file into the 8266?

Post by platforma » Tue May 10, 2016 10:04 am

Please see: http://forum.micropython.org/viewtopic.php?f=16&t=1655, "I'd like to run my own code from a script instead of REPL" section.

You have a few officially supported methods (i.e not external tools)
- Put your files in esp8266/scripts and invoke them with "import mymodule"
- Look into "frozen bytecode", there are discussions in the esp8266 subforum.
- Write your files directly through REPL using file.write() and a paste mode (press Ctrl-E while in REPL)
- Use the new webrepl_cli.py to upload your files from the command line.

hamish
Posts: 3
Joined: Fri Mar 18, 2016 11:56 am

Re: Can anyone tell how to put .py file into the 8266?

Post by hamish » Tue May 10, 2016 10:54 pm

It would be really nice if micropython had something like esp8266basic does where you can edit load and save files from a web browser. That feature alone make esp8266basic really usable once you have the esp built into an enclosure and want to program it remotely. Loading a script into micropython is still painfull. But I am amazed at how fast its improving.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Can anyone tell how to put .py file into the 8266?

Post by pfalcon » Wed May 11, 2016 6:08 pm

platforma, I'd suggest there to be "How to transfer files to my ESP8266?" question, and it should be close to the top of the FAQ. Let me know if you agree.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Can anyone tell how to put .py file into the 8266?

Post by platforma » Thu May 12, 2016 3:43 pm

pfalcon wrote:platforma, I'd suggest there to be "How to transfer files to my ESP8266?" question, and it should be close to the top of the FAQ. Let me know if you agree.
Affirmative, will add it to the top. I need to tidy up that FAQ anyway. Thanks for the suggestion!
done: http://forum.micropython.org/viewtopic. ... 9499#p9499

EasyRider
Posts: 94
Joined: Wed Dec 30, 2015 8:17 am

Re: Can anyone tell how to put .py file into the 8266?

Post by EasyRider » Fri Jul 01, 2016 9:09 am

I still can't see clear instructions (for newbies) on how to upload files to ESP8266.

Brief link in FAQ points to documentation that states.
so give it a try using webrepl_cli.py from the repository above
:?

For a newbie that is not familiar with a Linux OS command line and probably does not even use Linux based system.

How and where do you run webrepl_cli.py in Windows, if at all possible?

There are very clear instructions for beginners how to print "Hello world", configure GPIO pin and flash a LED.
http://docs.micropython.org/en/latest/e ... rd-control

I appreciate that Micropython for ESP is still in early stages of development, but ability to upload programs to ESP in a relatively easy way should surely have a very high priority.

Regards
John

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

Re: Can anyone tell how to put .py file into the 8266?

Post by jms » Fri Jul 01, 2016 9:49 am

Not quite relevant to the question but just because there is mention of command line (or software or operating systems for that matter) bringing the word "Linux" in just isn't right. Before graphical user interfaces all interactive software had command lines. If Linus had never been born we'd still have the rest of the family of UNIX and UNIX-alike OSs.

The webrepl client is written in Python and as such runs on anything that supports that.

Sorry for polluting the forum with my rants.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Can anyone tell how to put .py file into the 8266?

Post by deshipu » Fri Jul 01, 2016 10:40 am

EasyRider wrote: How and where do you run webrepl_cli.py in Windows, if at all possible?
I don't have Windows, but it would be something like this:
  • Install Python on your system, if you haven't already done so, and make sure it's in your PATH.
  • Download and unpack the .zip with the WebREPL from github.
  • Start→Run...→cmd.exe
  • Navigate to the directory where you unpacked the .zip using the "cd" command.
  • Run "python webrepl_cli.py" to see the usage help.
  • Run "python webrepl_cli.py some_file.py 192.168.4.1:" to upload "some_file.py" to ESP with addresss "192.168.4.1".

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Can anyone tell how to put .py file into the 8266?

Post by pfalcon » Fri Jul 01, 2016 11:05 am

jms wrote: The webrepl client is written in Python and as such runs on anything that supports that.

Sorry for polluting the forum with my rants.
That's not a rant, that's direct and correct answer to EasyRider's question, thanks jms, that's not first helpful answer you give, please keep it up.

Please also note that "How to transfer files to my ESP8266?" is a question from FAQ: http://forum.micropython.org/viewtopic.php?f=16&t=1908

Also please note that recently Damien added initial experimental support for transferring files straight from WebREPL HTML client (http://micropython.org/webrepl). I myself didn't yet have chance to try it, so any help with testing is welcome.

(And I would like to extend an invitation for JavaScript/Web programmers to contribute UI improvements to WebREPL HTML client - but please discuss changes you have in mind first, one requirement we have for it is to stay lean and mean, so please don't bring in your favorite JS framework du jour without argumentation why it can't be done without it).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Can anyone tell how to put .py file into the 8266?

Post by deshipu » Fri Jul 01, 2016 11:08 am

pfalcon wrote: (And I would like to extend an invitation for JavaScript/Web programmers to contribute UI improvements to WebREPL HTML client - but please discuss changes you have in mind first, one requirement we have for it is to stay lean and mean, so please don't bring in your favorite JS framework du jour without argumentation why it can't be done without it).
I really can't see a reason why there couldn't be a small javascript library for talking to the WebREPL, and then there can be many different actual user interfaces, some of them "lean and mean", and some gaudy and hip?

Post Reply