ESP32 Command Station

Atani Dec 10, 2017

  1. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    Hi. I try to compile your project, but the python script build_index_header.py does not want to work in Visual Studio Code + Platformio with python 2.7.12 extensions installed. I have an error on the first line 'import env' ! Can you send me the file index_html.h ? Or explain how install the missing part of Python ?
     
  2. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Can you send me the output from running the platformio build target? You shouldn't need anything beyond vscode and platformio extensions installed to successfully compile the code.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  3. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    Hi. I try to compile your project, but the python script build_index_header.py does not want to work in Visual Studio Code + Platformio with python 2.7.12 extensions installed. I have an error on the first line 'import env' ! Can you send me the file index_html.h ? Or explain how install the missing part of Python ?
     
  4. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    PS D:\Mes documents\Trusty\Arduino\DCCppESP32> & python "d:/Mes documents/Trusty/Arduino/DCCppESP32/build_index_header.py"
    Traceback (most recent call last):
    File "d:/Mes documents/Trusty/Arduino/DCCppESP32/build_index_header.py", line 1, in <module>
    import env
    ImportError: No module named env
    PS D:\Mes documents\Trusty\Arduino\DCCppESP32> & python "d:/Mes documents/Trusty/Arduino/DCCppESP32/build_index_header.py"
    Traceback (most recent call last):
    File "d:/Mes documents/Trusty/Arduino/DCCppESP32/build_index_header.py", line 40, in <module>
    env.AddPreAction('$BUILD_DIR/src/WebServer.cpp.o', build_index_html_h)
    NameError: name 'env' is not defined
     
  5. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Are you trying to run it directly vs running the build target that platformio provides for you? There should be a build button in vscode in the lower left corner of the window.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  6. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    I have tried both methods. After installing all updated versions of Python (3.7.1), Visual Studio Code (1.28.2) and extensions PlatformIO (Home 1.0.5 and Core 3.6.1rc6) and Python (2018.9.1), the result is the same :

    CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
    PLATFORM: Espressif 32 > Espressif ESP32 Dev Module
    SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash)
    DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny)
    Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF MODES: FINDER(chain+) COMPATIBILITY(strict)
    Collected 28 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <SPI> 1.0
    |-- <ArduinoJson> 5.13.3
    |-- <AsyncTCP> 1.0.1
    |-- <ESP Async WebServer> 1.2.0
    | |-- <AsyncTCP> 1.0.1
    | |-- <FS> 1.0
    | |-- <WiFi> 1.0
    | |-- <ArduinoJson> 5.13.3
    |-- <ESP8266_SSD1306> 4.0.0
    | |-- <SPI> 1.0
    | |-- <Wire> 1.0
    |-- <LiquidCrystal_PCF8574> 1.1.0
    | |-- <Wire> 1.0
    |-- <ESPmDNS> 1.0
    | |-- <WiFi> 1.0
    |-- <Preferences> 1.0
    |-- <Wire> 1.0
    |-- <FS> 1.0
    |-- <WiFi> 1.0
    ImportError: No module named env:
    File "C:\users\thierry\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 175:
    env.SConscript(item, exports="env")
    File "C:\Users\Thierry\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 541:
    return _SConscript(self.fs, *files, **subst_kw)
    File "C:\Users\Thierry\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 250:
    exec _file_ in call_stack[-1].globals
    File "D:\Mes documents\Trusty\Arduino\DCCppESP32\build_index_header.py", line 1:
    import env

    To obtain this, i have tried 'pio run' in console, 'Execute this Python script in a terminal', and the command 'Terminal/Run Build Task...' from menu...
     
  7. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Python 3.x is not supported by PlatformIO Core https://docs.platformio.org/en/latest/installation.html. So that is the problem. Until they upgrade to Python 3.x it will be necessary to use Python 2.7.x.
     
  8. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    Ok, but the first try was with Python 2.7.13, and I just give a try with it now, this is the same problem...
    As I have read on PlatformIO site, the 'env' module was added in version 3.4.1 of the core of the extension. There is probably a link between python and PlatformIO which is not good on my machine...
     
  9. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Yes, PlatformIo Core is very sensitive to the python version. When you added 2.7.x did you add it to the system path? Make sure it is in the path *BEFORE* python 3.x.

    Also look in the .vscode directory, there is a Jon file in there with reference to path which you might need to update, I don't know if it picks up updates from the OS or not. I see it as a bug in platformio that it duplicated various IS settings in it's own config files.

    Also if you are using the released version 1.1.1 you can download the pre generated header file from the release page, but it likely won't help you compile with platformio.

    I'm looking at options for moving to a more portable build system, likely a CMakeFile approach as that is the direction arduino-esp32 has moved. I'm also not happy with a few limitations that I've encountered with platformio lately (main one being you can't pick up arbitrary version of arduino-esp32 or esp-idf).

    Sent from my ONEPLUS A5010 using Tapatalk
     
  10. Duesselklaus

    Duesselklaus New Member

    9
    0
    1
    Hi Mike,

    Thanks for your effort to keep DCC++ alive! I am running DC++ on a UNO (driving a LENZ booster) for several months and I also moved it to a Pro-Micro to integrate it into the booster housing. It works - but due to the limited ressources available I had to do some "tweaks" (in RocRail) to operate > 35 switches. Ok, it's not worth spending more effort into it having for example ESP available. I started to move the code - then I found your posts. Now I see that you're far ahead ....
    Well, I downloaded both ESP8266 and ESP32 projects from github - but platformio does not install on my computer due to content filter, proxy etc.
    So I'm "limited" to use the Arduino IDE. I installed all required libraries - but on ESP8266 I have issues with ArduinoJson and Wifi. With ESP32 I struggle with index_html.h. Ok, I will do fresh installs - and then ask for support with precise problem descriptions :).
    Is there any futher "build" description other than the info given in README.md?

    Regards, Klaus
     
  11. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I would recommend downloading the required bits when you can via a non-filtered internet connection. I'm also switched over to using vscode lately with the platformio plugin. This may be an option for you on the filtered internet, there is support for proxy connections as well last I checked but I don't use them.

    Both of these should be available in the Arduino IDE for the ESP8266. What sort of issue are you hitting with them?

    in the release area on github you can download a version specific copy of the index_html.h file pre-generated. The latest release version should work with the latest master code. For development branch (were more recent activity is taking place) the only way to get the file would be build it with the python script (it is not directly executable as it requires PlatformIO build extensions).

    For the Arduino IDE there are not many instructions other than some here in this thread or in another ESP32 thread on this forum. There is also the issue here to track the documentation efforts, I haven't had a chance to document it further and I'm not sure it is worth it since the Arduino IDE doesn't offer very much in the usability department.
     
  12. Duesselklaus

    Duesselklaus New Member

    9
    0
    1
    I found the releases folder, downloaded both versions and the matching index_html.h files. Thank you!

    Now I have similar problems in both "branches" (ESP8266 and ESP32).

    The compiler complains about :

    sketch\MotorBoard.cpp: In static member function 'static void MotorBoardManager::getState(ArduinoJson650_0_0::JsonArray&)':

    MotorBoard.cpp:200: error: invalid initialization of non-const reference of type 'ArduinoJson650_0_0::JsonObject&' from an rvalue of type 'ArduinoJson650_0_0::JsonObject'

    JsonObject &board = array.createNestedObject();

    ...

    invalid initialization of non-const reference of type 'ArduinoJson650_0_0::JsonObject&' from an rvalue of type 'ArduinoJson650_0_0::JsonObject'

    Any idea how to fix this? I have the ArduinoJson library downloaded from GitHub - but no improvement. Sorry, lack of knowlegde I suppose ....
     
  13. Duesselklaus

    Duesselklaus New Member

    9
    0
    1
    Ups. Sometimes it is good to ask a question - to get down to the bottom of the problem. Mine was: I had the beta version of the ArduinoJson installed. I "downgraded" to the latest release and it is compiling now. I will now start to experiment with ESP8266 - the ESP32 hasn't still been delivered .... :-(
     
  14. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I haven't tested the beta version of ArduinoJson but from what you are showing it looks like it will pose a few problems. I'll need to check into it and see what is going on with that when I can.
     
  15. Duesselklaus

    Duesselklaus New Member

    9
    0
    1
    My ESP8266 is running now, but the SSIS is "ESP_1032D4" - and not the one specified in config.h. The web server is also not accessible on port 80. Maybe I mixed up libraries for ESP8266 and ESP32 ....
     
  16. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    The ESP8266 doesn't sound like it has been flashed with the DCC++ base station code for it. For the Arduino/ESP8266 version of the base station you need to flash both the ESP8266 and the Arduino boards with their respective code for it to work properly.

    The ESP8266 will not have its AP active but will instead connect to an AP that you specify.
     
  17. PaulS

    PaulS TrainBoard Member

    16
    6
    7
    Hello, first I would like to thank you for your work with DCC++ on the ESP32. I'm not able to build the project due to PIO not finding the index_htm.h file. I'm using ATOM(1.32.2ia32), Platform IO(1.06) on Windows10 (with Python2.7 and path set), although I'm a newbie with PIO.

    Not sure how to resolve this. Any help on this would be greatly appreciated.​
    Best Regards,​
    Paul​
    PIO build error message:

    Processing esp32 (framework: arduino; platform: espressif32; board: esp32dev)

    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
    PLATFORM: Espressif 32 > Espressif ESP32 Dev Module
    SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash)
    DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, ol
    imex-jtag-tiny)
    Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF MODES: FINDER(chain+) COMPATIBILITY(strict)
    Collected 28 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <SPI> 1.0
    |-- <ArduinoJson> 5.13.3
    |-- <AsyncTCP> 1.0.1
    |-- <ESP Async WebServer> 1.2.0
    | |-- <AsyncTCP> 1.0.1
    | |-- <FS> 1.0
    | |-- <ArduinoJson> 5.13.3
    | |-- <WiFi> 1.0
    |-- <ESP8266_SSD1306> 4.0.0
    | |-- <Wire> 1.0
    | |-- <SPI> 1.0
    |-- <LiquidCrystal_PCF8574> 1.1.0
    | |-- <Wire> 1.0
    |-- <ESPmDNS> 1.0
    | |-- <WiFi> 1.0
    |-- <Preferences> 1.0
    |-- <Wire> 1.0
    |-- <WiFi> 1.0
    |-- <FS> 1.0
    build_index_html_h([".pioenvs\esp32\src\WebServer.cpp.o"], ["src\WebServer.cpp"])
    Attempting to compress C:\Users\pauls\Documents\PlatformIO\Projects\DCCppESP32-master/data/index.html
    Compressed index.html.gz file is 8071 bytes
    Compiling .pioenvs\esp32\src\WebServer.cpp.o
    Compiling .pioenvs\esp32\lib29b\ESP Async WebServer_ID306\WebAuthentication.cpp.o
    Compiling .pioenvs\esp32\lib29b\ESP Async WebServer_ID306\WebHandlers.cpp.o
    Compiling .pioenvs\esp32\lib29b\ESP Async WebServer_ID306\WebRequest.cpp.o
    Compiling .pioenvs\esp32\lib29b\ESP Async WebServer_ID306\WebResponses.cpp.o
    src\WebServer.cpp:28:24: fatal error: index_html.h: No such file or directory

    ********************************************************************
    * Looking for index_html.h dependency? Check our library registry!
    *
    * CLI > platformio lib search "header:index_html.h"
    * Web > https://platformio.org/lib/search?query=header:index_html.h
    *
    ********************************************************************

    compilation terminated.
    *** [.pioenvs\esp32\src\WebServer.cpp.o] Error 1
    [ERROR] Took 104.98 seconds

     
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I have pushed a fix for this just now to the master branch, unfortunately PlatformIO no longer allows adding paths to the include path dynamically. If you pull down the latest master code (specifically build_index_header.py) it should now work for you.
     
  19. John Holdsworth

    John Holdsworth TrainBoard Member

    21
    4
    6

    Just so you don't feel lonely.. I've got the same problem..no experience at DCC but some at coding..this looks like the software for me though...some help would be much appreciated

    regards JH
     
  20. PaulS

    PaulS TrainBoard Member

    16
    6
    7
    Thank-you Mike for your quick response, the project now builds without errors. Onto up-loading to the ESP32.... I'm sure I'll be back with more ???

    BR
    Paul
     
    Atani likes this.

Share This Page