Hey I'm pretty sure It something stupid that I oversaw in reading & rereading the docs.
But I'm trying to upload my main.py and I'm doing this via webrepl. I've confirmed this when I os.listdir().
So I reboot and the file is going and main.py could not be read. What I read is that I should safely remove the esp8266 that it keeps the file. How do I do this in terminal on a mac. I've found no command for safely removing a serial device. Except 'umount device name' but that give me and error that it isn't there.
Or do I have to this in micropython console?
Safely remove Wemos D1 mini
Re: Safely remove Wemos D1 mini
Nobody or is it such a dumb question? ^^blckpstv wrote:Hey I'm pretty sure It something stupid that I oversaw in reading & rereading the docs.
But I'm trying to upload my main.py and I'm doing this via webrepl. I've confirmed this when I os.listdir().
So I reboot and the file is going and main.py could not be read. What I read is that I should safely remove the esp8266 that it keeps the file. How do I do this in terminal on a mac. I've found no command for safely removing a serial device. Except 'umount device name' but that give me and error that it isn't there.
Or do I have to this in micropython console?
Re: Safely remove Wemos D1 mini
The ESP8266 boards can't act a USB storage -- they only have the serial console. That means you don't need (in fact, can't) "safely remove" them. However, disconnecting their power while they are performing file operations on their internal file system can still result in file corruption -- so don't disconnect it while the file is transferring.
There is no "main.py" on the board by default, so that warning is normal, unless you uploaded a "main.py" file and that can't be read -- that would mean there is something wrong.
There is no "main.py" on the board by default, so that warning is normal, unless you uploaded a "main.py" file and that can't be read -- that would mean there is something wrong.
Re: Safely remove Wemos D1 mini
Ok dumb questiondeshipu wrote:The ESP8266 boards can't act a USB storage -- they only have the serial console. That means you don't need (in fact, can't) "safely remove" them. However, disconnecting their power while they are performing file operations on their internal file system can still result in file corruption -- so don't disconnect it while the file is transferring.
There is no "main.py" on the board by default, so that warning is normal, unless you uploaded a "main.py" file and that can't be read -- that would mean there is something wrong.
One last to follow up on, when importing dht.py and running >>> run dht.py or python dht.py
I get errors
Code: Select all
dht.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'py'
Re: Safely remove Wemos D1 mini
The prompt you are getting from the board is already the Python interpreter. You don't have to start it by writing "python" -- there is no operating system and no system prompt. In order to run "dht.py" you need to do "import dht" or "execfile("dht.py")". The "main.py" file gets executed automatically at start, so you will probably want to use that once you finish your code.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Safely remove Wemos D1 mini
In general the best way to develop with MicroPython is as follows. If your application is called dht.py you can run it by issuing
There's a case, however, for not having it run automatically on import: it can make debugging easier if you don't. So I usually define a function which can have any name, but let's call it main(). Then, after making any change to dht.py on the target, you issue ctrl-D to reset the board followed by
The reason I prefer this is because after doing the import you can change global variables. Or your main() function might have arguments you want to alter at runtime.
Once you're happy with the application, to make it auto-run just add the above lines to main.py. If you find you've made a mistake, commenting out those two lines in main.py gets you back to debugging.
Code: Select all
import dht
Code: Select all
import dht
dht.main()
Once you're happy with the application, to make it auto-run just add the above lines to main.py. If you find you've made a mistake, commenting out those two lines in main.py gets you back to debugging.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.