Page 1 of 1

Compile for ESP8266 with a Controller & Module using vscode

Posted: 06 Aug 2019, 22:33
by JR01
Hi, I am struggling to find documentation / or even any pointers of how to compile my own code for a target ESP8266 (say Wemos 4mb), using vscode, (with platformio extention?), where do I uncomment what I want in my code for a controller / modules, and then compile?

I want to compile firmware with only the C_014 controller (Homie) and Hum & Temp DHT22 in the code, plus normals, like Switch.

In the latest topic on platformio, the guys says they need to write the instructions still - I understand this is lower priority with all going on, but can someone just point me in the right direction? For instance:

1. Does one do that on the folder (for instance) ../ESPEasy_mega_20190805/source/src/ESPEasy.ino file - uncommenting stuff? (to make for instance C_014 work, and comment all the modules I do not want...)
2. Or does the old platformio instructions with Atom somehow still hold? ie. in above folder tree, rename /source/ to /ESPEasy/
3. (I am on Mac with vscode + arduino + platformio modules installed)

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 08 Aug 2019, 17:31
by TD-er
If you have PIO installed and the source tree cloned to your hard drive, then you can open the main dir of the repository (the level with platformio.ini in it)
Then in a few moments on the left, there will appear an alien logo, the logo of PlatformIO. (assuming VS code)
If you click that one, you will get a tree with lots and lots of project tasks and environments.

The easiest is to go for the environment "env:custom_ESP8266_4M" and unfold that one.
Then select "Build" to see if it will start building.

If that's working, you can open the file "pre_extra_script.py" and add or remove the plugins and controllers you need.
That Python file is used in the "env:custom_ESP8266_4M" to define what should be embedded and what not.

For example to have only the controller "C014", you can remove "CONTROLLER_SET_ALL", and just add "USES_C014",

The same for the plugins you need.

The file is built in the ".pio/build/...." directory right under the main repository directory (the one with the platformio.ini in it)

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 08 Aug 2019, 22:13
by JR01
Thank you, will try it

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 08 Aug 2019, 23:21
by TD-er
Let me (or GrovKillen) know if it is enough so we can cut-and-paste it into the documentation.

I guess it is being asked about daily how to build stuff.

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 11 Aug 2019, 16:11
by JR01
It works, will now load the firmware, to see if it works. Can I do that from vscode?

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 11 Aug 2019, 18:34
by JR01
Fantastic - its working, got the platformio upload command as well. I am in Linux, had to install 99-platformio-udev.rules to make platofrmio upload tools work in vscode.

Thank you.

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 11 Aug 2019, 20:48
by TD-er
Great :)
Now we have to start cut'n-paste'ing this into the docs.

I made a commit for the documentation: https://github.com/letscontrolit/ESPEas ... 7ca9509096

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 17 Aug 2019, 16:39
by JR01
Working very well, some more advise please, regarding to changes to my pre_extra_script.py file in ESPEasy folder, I changed it as per below.

I want only the Devices listed in the list.

Per your instructions, I cloned latest github of espeasy to local, changed file pre_extra_script.py per below, committed all changes, but I still get all Devices. Is my file below correct, or something to do with git?

Code: Select all

Import("env")

env.Append(CPPDEFINES=[
  "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x",
#  "CONTROLLER_SET_ALL",
  "NOTIFIER_SET_NONE",
#  "PLUGIN_SET_ONLY_SWITCH",
  "USES_P001",  # Switch
  "USES_C014",  # Homie Controller
  "USES_P086",  # Homie Receiver
  "USES_P005",  # DHT22
  "USES_P033",  # Dummy Device

  ("WEBSERVER_RULES_DEBUG", "0")
])


Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 17 Aug 2019, 21:24
by TD-er
For just building you don't have to commit it.
Platformio is just using the files on the hard drive during build.
So after changing that .py file, you should build it again using the build task.

Re: Compile for ESP8266 with a Controller & Module using vscode

Posted: 18 Aug 2019, 08:59
by JR01
Thank you, and the code of pre_extra_script.py aboce, why do I still see all plugins in drop down?