Arduino code conversion

Hello, I have the following question: is it possible and how to upload the Arduino code to the NodeMCU ESP 8266 board using Python code? I will be very grateful🙏

Welcome to the forum

It is not clear whether you want to upload and run Python code or whether you want to upload and run "Arduino" (ie, C++) code using Python in some way

Please clarify what you want to do

I want to upload C++ code (Arduino code) but via Python code to a NodeMCU ESP8266 board

The IDE already uses Python to upload the C++ code to the ESP8266. What are you hoping to achieve ?

For information, here is how the upload is invoked

"C:\Users\Bob2\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3" -I "C:\Users\Bob2\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2/tools/upload.py" --chip esp8266 --port "COM5" --baud "921600" ""  --before default_reset --after hard_reset write_flash 0x0 "C:\Users\Bob2\AppData\Local\Temp\arduino\sketches\BC333A28F54CFE18AC84568556CC8DFB/sketch_dec23b.ino.bin"

This, of course, is after the code has been compiled. Instead of using the IDE to compile the code you could use the Arduino CLI tool but it is not something that I know anything about

1 Like

why python?

why not use avrdude which is used by the Arduino IDE to download/program the chip?

or do you want to use python to invoke something like avrdude

Because that's for AVR chips.

1 Like

what tool does Arduino IDE use to download/program and esp32?
is it esptool.py?
under aduino-esp32-master/tools

Yes. esptool.py

Note, however, that the original question is about uploading to an ESP8266 rather than an ESP32 for which upload.py appears to be used

2 Likes

Any moment now, we are going to find out what we all suspect already. @nightmagic believes that if the upload process uses Python scripts, then the code that gets uploaded has been somehow converted from C++ to Python. @nightmagic, sorry, but that is not the case.

I think I didn't ask the question correctly. I want to download the code written in Arduino IDE without Arduino IDE because I am creating a program on PyQt5 and for convenience I want to not need to download Arduino IDE for use. I recently learned that it is possible to convert C++ (Arduino) code to binary code and download it to the NodeMCU ESP8266 board using the esptool library, but I don't know how to convert Arduino code to binary code.

You use a compiler. It does not have to be invoked from the IDE. If you turn on verbose reporting of compilation in the IDE you will see the commands that the compiler uses

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.