Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

platformio.ini help

Home Forums Mayfly Data Logger platformio.ini help

Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #17614
      Laura DeCicco
      Participant

        I’ve mostly converted from the basic Arduino IDE to VSCode/Platform IO. The main reason I made the switch was library management. I love every aspect so far (code completion, integrated Git tools, etc), but I’m still struggling with how to best use the platformio.ini file to manage required libraries for a project.

        For example, this is an example file that has worked for me:

        But now I’d like to add some MQTT communication to my main.cpp. To start, I was hoping to follow the beginning of this tutorial:

        https://docs.arduino.cc/tutorials/mkr-1000-wifi/mkr-1000-mqtt-device-to-device

        What’s the best way to use the .ini file to get the ArduinoMqttClient library installed for this project?

        Things I’ve tried:

        I’ve added: arduino-libraries/ArduinoMqttClient

        to a new line in the lib_deps

        I’ve tried opening the Arduino IDE and installing the ArduinoMqttClient from there.

        For both of those, I still get the red squiggly mark under:
        #include <ArduinoMqttClient.h>
        With the hover message “Can’t open the source file ArduinoMqttClient.h”

        Any tips on how to manage libraries via the .ini file and how to add new libraries would be appreciated. Similarly, are there suggestions for when/how to update libraries? At one point I clicked a button that updated some of the Adafruit libraries and got stuck because the ModularSensor library was looking for an older version (which I’d rather not have to deal with again if possible).

        Thanks for any info and sorry if this topic was discussed before. I did search the forum, but I wouldn’t be surprised if I missed a pertinent discussion.

        This is the best conversation I came across:

        best practices enabling debugging modular sensors using platformIO

         

      • #17616
        neilh20
        Participant

          @ldecicco congrats on trying the platformio – it has a lot of professional capability, but like anything – getting in a fancy plane(!) there are lots of bells and whistles that can go off.

          For “new” libs there are at least two ways to work with them, a)  put the full path to them under libdeps

          I find a https://github.com/arduino-libraries/ArduinoMqttClient

          and in the platformio.ini

          This pulls into your directory under .pio\libdeps\mayfly

          b) clone to directory <lib> – that is go to the directory lib and run

          git clone git@github.com:arduino-libraries/ArduinoMqttClient.git

          Check that its been installed correctly and builds OK. Also then need to make sure its also not specified in platformio.ini as it will also be pulled in to .pio\libdeps\mayfly and compile there instead.

          To be able to modify a lib, there are a couple more stages – assuming you have a github account, first on github fork the lib, then clone it into the local lib directory.  Check that its building ok from that directory. Then make modifications, finally “git push” back to your forked repo.

          For a number of examples, you could look at my forks in

          https://github.com/neilh10/ModularSensors/tree/release1/examples/tu_xx01 – and say how I manage TinyGSM – the amazing AT interface lib  ~ see

          https://github.com/neilh10/TinyGSM.git<span class=”pl-c”>#rel1 ;Bug fixes over Envirodiy</span>

          It is very powerful, however does require a lot of learning by doing and also checking out other examples.

          It does also require following how git works – for instance on a repo fork I try and add to a different “branch” than what the source uses. so envirodiy specifies “master”, but I create and add to “release1”, and then in the repo make that the source branch.

          To understand git,  I prefer the cmd line interface, as I don’t quite trust what the gui github client to tell me what its doing. I do use the vsc git for looking at differences. I often make small changes, say in a comment, just to test out how it works, and verify that its getting to the online repo correctly. I keep a “<project>-diary.docx” of what I’ve done that works.  Its pretty amazing, however it can take some curating to know the sequences to make it work.

          Hope that works for you

           

        • #17621
          Laura DeCicco
          Participant

            Thanks @neilh20, I think I needed to run pio pkg install . Now that I have done that – the libraries do indeed clone then install automatically when I update the .ini file.

            I’m still not sure I fully appreciate the power of the .ini file and pio commands…but  that will come with time I guess.

            Git is a critical part of my daily work-life, and I’ll always try to get everyone I know to use it!

             

          • #17627
            neilh20
            Participant

              Great @ldecicco  – one area to note with “pio pkg install” is how it becomes part of your build process.  I like to have a development build environment tree.  Then a final “release” environment – and attempt to take a full snapshot of all libs used. I encapsulate the difference in text instructions and operation of the platformio.ini.

          Viewing 3 reply threads
          • You must be logged in to reply to this topic.