ESP8266/MicroPython-Copy data from terminal to file

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
samerou
Posts: 38
Joined: Mon Feb 11, 2019 12:51 pm

ESP8266/MicroPython-Copy data from terminal to file

Post by samerou » Sat Feb 16, 2019 12:54 pm

Hello ,
I'm trying to create a syntax which allow me to copy in an instance T=1.5s a data from micropython terminal like ("Webrepl or teraterm ) and send it to specific file like txt or another type but I couldn't find the key to start this properly

Anyone can light me on this ?

B.R
samerou

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by OutoftheBOTS_ » Sat Feb 16, 2019 9:19 pm

Open a file and write it to file

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by Roberthh » Sun Feb 17, 2019 6:58 am

@samerou: On which deviec do you want to write:
a) do you want to write data sent by the ESP8266 into a file on the PC, or
b) do you want to write data sent by the PC into a file on the ESP8266
In case of a) at least with programs like Tertarm, you can open a log file, which capture all activity. In case of b), like @OutoftheBOTS_ told, open a file and write to it everything you receive by reading from sys.stdin.

samerou
Posts: 38
Joined: Mon Feb 11, 2019 12:51 pm

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by samerou » Sun Feb 17, 2019 11:49 am

[quote=Roberthh post_id=34182 time=1550386690 user_id=601]
@samerou: On which deviec do you want to write:
a) do you want to write data sent by the ESP8266 into a file on the PC, or
b) do you want to write data sent by the PC into a file on the ESP8266
In case of a) at least with programs like Tertarm, you can open a log file, which capture all activity. In case of b), like @OutoftheBOTS_ told, open a file and write to it everything you receive by reading from sys.stdin.
[/quote]

@Roberthh, thank you for answering me ,

I'm looking for case a : exporting data from esp terminal(Teraterm ,Upyloader ,Webrepl) into PC

So what are you saying that there is a file "log" that records everything displayed in terminal ? where should I find it ?

Is there away to export data from Terminal in specific location defined by me and different type of file like (CSV, TXT,....) ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by Roberthh » Sun Feb 17, 2019 4:22 pm

There is an option in Teraterm to log all interface activity in a file, under File->Log. This is just the raw character stream. I do not expect that this is possible with Webrepl.
If you are using simple tools like picocom or screen form the command line, you can always "tee" the screen output to a file, like:

picocom -b 115200 -p /dev/ttyUSB0 | tee my_logfile.txt

samerou
Posts: 38
Joined: Mon Feb 11, 2019 12:51 pm

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by samerou » Mon Feb 18, 2019 6:51 am

Roberthh wrote:
Sun Feb 17, 2019 4:22 pm
There is an option in Teraterm to log all interface activity in a file, under File->Log. This is just the raw character stream. I do not expect that this is possible with Webrepl.
If you are using simple tools like picocom or screen form the command line, you can always "tee" the screen output to a file, like:

picocom -b 115200 -p /dev/ttyUSB0 | tee my_logfile.txt
Thank you so much I'm gonna accept this as answer ,

Have a nice day

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by kevinkk525 » Mon Feb 18, 2019 9:35 am

I created a little logging program that puts the time in front of the device output. If you are interest I can post it. Or actually it is already here: https://github.com/kevinkk525/micropyth ... _logger.py Just have to adapt it to not write something to the repl if that could conflict with your program. It's started from commandline with first arg is the port, 2nd arg is the statement you want to write to repl (e.g. to start some program) and 3rd arg is if it should write something to the repl or just listen.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

samerou
Posts: 38
Joined: Mon Feb 11, 2019 12:51 pm

Re: ESP8266/MicroPython-Copy data from terminal to file

Post by samerou » Mon Feb 18, 2019 10:01 pm

kevinkk525 wrote:
Mon Feb 18, 2019 9:35 am
I created a little logging program that puts the time in front of the device output. If you are interest I can post it. Or actually it is already here: https://github.com/kevinkk525/micropyth ... _logger.py Just have to adapt it to not write something to the repl if that could conflict with your program. It's started from commandline with first arg is the port, 2nd arg is the statement you want to write to repl (e.g. to start some program) and 3rd arg is if it should write something to the repl or just listen.
[/quote



@kevinkk525 , Thank you so much I'm open to any kind of example

Post Reply