Page 1 of 2

ESP32: How to send files from internal flash to PC

Posted: Tue Aug 06, 2019 8:26 am
by akushva
I am working on a project where an esp32 takes Voltage and current sensor data of a house. I am storing these sensor values in a text file(CSV format) in the esp32 internal flash memory. I want to transfer the CSV file my PC via LAN/Wifi/COM(Priority-LAN -due to distance issues) so that I can perform further analysis on them.

Can we access PC's filesystem using micropython? How can i attempt to transfer files via wired/wireless medium to PC hard disk?


Thank you

Re: ESP32: How to send files from internal flash to PC

Posted: Tue Aug 06, 2019 2:33 pm
by Christian Walther
If you can live with initiating the transfer from the PC side (it sounds like you want the opposite), the WebREPL is the easiest way to transfer files wirelessly from and to ESP boards, using either the HTML or command-line client.

If you need to initiate the transfer from the microcontroller side, then some kind of HTTP POST would probably be easiest, but I have no experience with that.

To transfer files over a serial connection (also initiated from the PC side), there are several options, rshell and ampy being among the more popular ones.

If you would rather transmit measured data continuously than collect it in a file, look into MQTT.

Re: ESP32: How to send files from internal flash to PC

Posted: Tue Aug 06, 2019 2:54 pm
by jimmo
hi Christian,

Did you make more progress with https://github.com/micropython/micropyt ... -492205467

This sounds like it would be really useful for the device-initiated case described here?

Re: ESP32: How to send files from internal flash to PC

Posted: Tue Aug 06, 2019 4:30 pm
by Roberthh
I tried the slimmed down version of a ftp lib https://github.com/SpotlightKid/micropython-ftplib.git
And it worked so far.

Re: ESP32: How to send files from internal flash to PC

Posted: Tue Aug 06, 2019 7:21 pm
by Christian Walther
jimmo wrote:
Tue Aug 06, 2019 2:54 pm
Did you make more progress with https://github.com/micropython/micropyt ... -492205467

This sounds like it would be really useful for the device-initiated case described here?
Yes, you are right, if the PC can be online all the time that could be used too.

No, I haven’t spent any time on it since then. I did get a little farther than the comment you quote – it does work over a serial connection now – but got stuck on making it work over WebREPL, see two comments down. Let’s see if I can make some time for that…

Re: ESP32: How to send files from internal flash to PC

Posted: Wed Aug 07, 2019 9:23 am
by ghayne
Have you considered sending the data using MQTT in real time?
I am doing something similar with temperature readings, using Node-Red to receive the MQTT messages and pass them to an InfluxDB database for analysis with Grafana.
I was pleasantly surprised how easy it is to set up MQTT on MicroPython.

Re: ESP32: How to send files from internal flash to PC

Posted: Mon Aug 12, 2019 6:09 am
by akushva
Roberthh wrote:
Tue Aug 06, 2019 4:30 pm
I tried the slimmed down version of a ftp lib https://github.com/SpotlightKid/micropython-ftplib.git
And it worked so far.

Thanks. I'll look into it.

Re: ESP32: How to send files from internal flash to PC

Posted: Mon Aug 12, 2019 6:13 am
by akushva
Christian Walther wrote:
Tue Aug 06, 2019 2:33 pm
If you can live with initiating the transfer from the PC side (it sounds like you want the opposite), the WebREPL is the easiest way to transfer files wirelessly from and to ESP boards, using either the HTML or command-line client.

If you need to initiate the transfer from the microcontroller side, then some kind of HTTP POST would probably be easiest, but I have no experience with that.

To transfer files over a serial connection (also initiated from the PC side), there are several options, rshell and ampy being among the more popular ones.

If you would rather transmit measured data continuously than collect it in a file, look into MQTT.

I was trying a microcontroller initiated transfer. I was thinking about storing it into files so that i can arrange the data day wise and so on.

Re: ESP32: How to send files from internal flash to PC

Posted: Mon Mar 16, 2020 10:42 am
by mkcastillote
Hello Roberthh, how did you managed to install the micropython-ftplib? I am using NodeMCU (ESP8266), and also I already tried different programming platforms for my NodeMCU (ESP8266), like 'uPyCraft', and 'ampy'. Please teach me how to install the micropython-ftplib. Thank you!

Re: ESP32: How to send files from internal flash to PC

Posted: Mon Mar 16, 2020 11:34 am
by Roberthh
You can upload the respective .py or .mpy file to the device, using ampy or rshell or pyboard.py. In the repository I linked there is a special version for ESP8266.
Since I build my own firmware image including an ftp server and other tools as frozen bytecode, I probably used ftp for it.