Platformio and MySensors development branch



  • Is anyone successfully using Platformio with development branch?

    I am using platformio to do my Arduino development. Works fine if I stick to the Master branch of MySensors (library #548). But if I try to use the Development branch (manually installing it as a library for Platformio) then I get a lot of compile problems that frankly make no sense. E.g. compiling the MQTT demo (GatewayW5100MQTTClient) I get errors in MyGatewayTransportEthernet that EthernetServer and EthernetClient are not a type, aka they were not found in an include somewhere.
    http://platformio.org for those wondering.



  • @gerritv I will answer the question myself.

    The directory layout of MySensors is a bit unusual, requires the following layout in platformio.ini

    [platformio]
    lib_dir = ../lib
    
    [env:nanoatmega328]
    platform = atmelavr
    framework = arduino
    board = nanoatmega328
    build_flags = -I../lib/MySensors
    lib_ignore = MySensors
    

    The directory layout I use is:
    Top level, a directory called lib with the contents of MySensors development branch. Inside this top level directory you have your various projects relating to this Solution:
    A directory for your sensor node sketch, e.g, LivingRoomNode which contains the Platformio directory and the above info in its ini file
    A directory for your gateway, with the same library parameters

    The result is a solution with multiple source projects pointing at the same MySensors library.

    Platformio is a great way to develop ESP8266/Arduino etc code. Also Platformio works very well with Visual Studio 2015 CE (this is what I build my MySensors nodes and gateways with).



  • I am trying to do the same but can't get a compile to work. I created a directory structure similar to the one you describe. In my gateway /src directory I copied the GatewayESP8266MQTTClient.ino file and used the same parameters for platformio.ini as in your example:

    [platformio]
    lib_dir = ../lib
    
    [env:nodemcu]
    platform = espressif
    framework = arduino
    board = nodemcu
    build_flags = -I../lib/MySensors
    lib_ignore = MySensors
    

    However, when I compile I get this error:

    src/tmp_ino_to.cpp:129:22: fatal error: MySensor.h: No such file or directory
    #include <MySensor.h>
    ^
    compilation terminated.
    

    The sketch otherwise compiles perfectly fine under the Arduino IDE.

    I'm sure it's a configuration issue somewhere. Can you expand a bit more on your file structure. Did you need to do any customization of PlatformIO to make it see the MySensors library?



  • @Iyad-Nahas your .ino file must be in the src directory. I was compiling my ESP8266 gw yesterday with no issues.
    I didn't need any customization of platformio. I am using 2.8.5



  • @gerritv Sorry, just re-read your msg and you already have the .ino in correct place.
    Are you certain there is no .ino outside the src directory? Are you using the development version of the libraries as well as the example from it?
    I recently changed my MySensors lib directory to be direct from Git development branch so the platformio lines are a bit different now (but same idea)

    [platformio]
    lib_dir = ../MySensorsLib/libraries
    
    [env:nodemcuv2]
    platform = espressif
    framework = arduino
    board = nodemcuv2
    build_flags = -I../MySensorsLib/libraries/MySensors
    lib_ignore = MySensors
    targets = upload
    

    Example output from my recent build:

    1>------ Build started: Project: GW-ESP8266, Configuration: Debug Win32 ------
    1>  [04/07/16 11:47:31] Processing nodemcuv2 (framework: arduino, build_flags: -I../MySensorsLib/libraries/MySensors, lib_ignore: MySensors, platform: espressif, board: nodemcuv2, targets: upload)
    1>
    1>  xtensa-lx106-elf-g++ -o .pioenvs\nodemcuv2\src\tmp_ino_to.o -c -fno-rtti -fno-exceptions -std=c++11 -Os -mlongcalls -mtext-section-literals -falign-functions=4 -ffunction-sections -fdata-sections -MMD -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12 -DARDUINO=20100 -DPLATFORMIO=020805 -U__STRICT_ANSI__ -IC:\Users\gerrit\.platformio\packages\framework-arduinoespressif\tools\sdk\include "-IC:\Users\gerrit\Documents\My Projects\SensorNet\MySensorsLib\libraries\MySensors" -I.pioenvs\nodemcuv2\FrameworkArduino -I.pioenvs\nodemcuv2\FrameworkArduinoVariant -I.pioenvs\nodemcuv2\EEPROM -I.pioenvs\nodemcuv2\SPI -I.pioenvs\nodemcuv2\ESP8266WiFi src\tmp_ino_to.cpp
    1>  xtensa-lx106-elf-g++ -o .pioenvs\nodemcuv2\firmware.elf -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -Wl,-T"esp8266.flash.4m1m.ld" .pioenvs\nodemcuv2\src\tmp_ino_to.o -LC:\Users\gerrit\.platformio\packages\framework-arduinoespressif\tools\sdk\lib -LC:\Users\gerrit\.platformio\packages\ldscripts -L.pioenvs\nodemcuv2 -Wl,--start-group .pioenvs\nodemcuv2\libFrameworkArduinoVariant.a .pioenvs\nodemcuv2\libFrameworkArduino.a -lmesh -lwpa2 -lsmartconfig -lpp -lmain -lwpa -llwip -lnet80211 -lwps -lcrypto -lphy -lhal -laxtls -lgcc -lm .pioenvs\nodemcuv2\libEEPROM.a .pioenvs\nodemcuv2\libSPI.a .pioenvs\nodemcuv2\libESP8266WiFi.a -Wl,--end-group
    1>  "C:\Users\gerrit\.platformio\packages\tool-esptool\esptool" -eo "C:\Users\gerrit\.platformio\packages\framework-arduinoespressif\bootloaders\eboot\eboot.elf" -bo .pioenvs\nodemcuv2\firmware.bin -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo .pioenvs\nodemcuv2\firmware.elf -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
    1>  <lambda>(["upload"], [".pioenvs\nodemcuv2\firmware.bin"])
    1>  Auto-detected UPLOAD_PORT/DISK: COM6
    1>  "C:\Users\gerrit\.platformio\packages\tool-esptool\esptool" -vv -cd nodemcu -cb 115200 -cp COM6 -cf .pioenvs\nodemcuv2\firmware.bin
    1>  esptool v0.4.8 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    1>  setting board to nodemcu
    1>  setting baudrate from 115200 to 115200
    1>  setting port from COM1 to COM6```


  • Well, after some trial and error I ended up with just adding the build_flags option with the path to the MySensors library and now building works fine.

    Here's my final platform.ini:

    [env:nodemcu]
    platform = espressif
    framework = arduino
    board = nodemcu
    build_flags = -I../lib/libraries/MySensors
    

    Now to figure out why the auto upload doesn't work. If I upload manually it works fine, but when I add "targets = upload" it keeps trying to connect then times out with an error. No big deal though. I don't mind uploading manually.

    Thank you for your help.


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 5
  • 3
  • 3
  • 6

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts