Compile for ESP8266 with a Controller & Module using vscode

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Compile for ESP8266 with a Controller & Module using vscode

#1 Post by JR01 » 06 Aug 2019, 22:33

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)
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#2 Post by TD-er » 08 Aug 2019, 17:31

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)

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#3 Post by JR01 » 08 Aug 2019, 22:13

Thank you, will try it
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#4 Post by TD-er » 08 Aug 2019, 23:21

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.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#5 Post by JR01 » 11 Aug 2019, 16:11

It works, will now load the firmware, to see if it works. Can I do that from vscode?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#6 Post by JR01 » 11 Aug 2019, 18:34

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.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#7 Post by TD-er » 11 Aug 2019, 20:48

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

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#8 Post by JR01 » 17 Aug 2019, 16:39

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")
])

-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#9 Post by TD-er » 17 Aug 2019, 21:24

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.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#10 Post by JR01 » 18 Aug 2019, 08:59

Thank you, and the code of pre_extra_script.py aboce, why do I still see all plugins in drop down?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests