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

best practices enabling debugging modular sensors using platformIO

Home Forums Mayfly Data Logger best practices enabling debugging modular sensors using platformIO

Viewing 9 reply threads
  • Author
    • #12990

        Dear all,
        I have quite some trouble to enable debugging. In the header files (.h) of the modular sensors library you can enable debugging by uncommenting a debugging statement. However working form platformIO and using lib_deps = EnviroDIY_ModularSensors, I am getting puzzled how to properly adjust header files. If I use a cloned version of the Modular sensor library and adjust header files the compilation terminates because it cannot find all library dependencies.

        I would like to enable debugging for ThingSpeakPublisher.h and Sodaq2GBeeR6.h.

        Any help would be greatly appreciated


      • #12991
        Sara Damiano

          You can also enable all of the debugging using a build flag in your platformio.ini. The result is exactly the same as if you un-comment the line in the header. You can add flags for any (or all) of the different modules.

          There also seems to be a bug in the very latest PlatformIO (4.0.0) when installing library dependencies. For some reason when I create a new project, add EnviroDIY_ModularSensors to my dependencies, and then try to compile, the library dependency finder doesn’t correctly find and install of of the dependencies during the first build. If I manually install the library using pio lib install EnviroDIY_ModularSensors before building, it finds everything perfectly.

        • #12992

            @srgdamiano, does this mean that
            is no longer needed in the lib_deps?
            (In other words, is Stream Debugger now in Modular Sensors?)

          • #12993
            Sara Damiano

              Oh, and just to note about those other build flags:

              -DSDI12_EXTERNAL_PCINT – this tells the library that you don’t want the SDI-12 library to try to monopolize the interrupts on an AVR board, which is required to make it “play nice” with the other libraries. You absolutely must set this because the SDI-12 library is a dependency of ModularSensors (even if you’re not using any SDI-12 sensors)

              -DNEOSWSERIAL_EXTERNAL_PCINT – this does the same thing to NeoSoftwareSerial. You only need this if you’re actually using that library, though it makes no difference if you define it but don’t use that library.

              -DMQTT_MAX_PACKET_SIZE=240 tells the MQTT library (PubSubClient) you need a bigger buffer for the outgoing request. The ThingSpeak publisher is the only one that uses MQTT (so far). I put it at 240 characters, which should be plenty long enough to send 8 fields to ThingSpeak (the maximum that ThingSpeak accepts at once). If you’re only using a few fields you could omit this flag, which would save you a tiny big of RAM, but be cautious because the MQTT library just won’t send the if the request length exceeds the buffer length.

              -DTINY_GSM_RX_BUFFER=512 – This is in the examples, but it really only matters if you’re using an ESP8266, AI Thinker, or Neoway M590. Don’t define it and save some some RAM with the GPRSBee.

            • #12994
              Sara Damiano

                @fisherba – StreamDebugger is only needed if you include it in your program; it isn’t and never was a dependency of ModularSensors or TinyGSM. It’s not included in ModularSensors.

              • #12995

                  Thanks for all the information, this was very helpful. If I try to build using the following build flags,

                  I get the following error.

                  It does build without the debugging options. Maybe I should not add a second error, but if I drop the DMS_SODAQ2GBEER6_DEBUG and replace it for the DMS_THINGSPEAKPUBLISHER_DEBUG, I get a build error because of a redeclaration of ‘uint32_t start’

                  Any help would be greatly appreciated.

                • #12999
                  Sara Damiano

                    I’m sorry I’ve not responded. I’m honestly baffled by the errors.

                    Could you show your whole ini and a shot of the contents of your .pio/libdeps/mayfly folder?

                  • #13000

                      I have been doing some testing to better understand what is happening. I first tried to build and compile the same example in my deployments folder, that I made during the Learn EnviroDIY Programming tutorial (which was great!). In that project folder I have much less errors. Apparently, I didn’t made a new project folder with the correct settings in the project wizard (through home, new project). After starting a new project folder with correct settings I am able to successfully build an compile the example using the MS_SODAQ2GBEER6_DEBUG build flag. I am a novice in PlatformIO, I just made a mistake somewhere in the process of making a new project folder. Still, if I add DMS_THINGSPEAKPUBLISHER_DEBUG build flag, the build error described above still exist (because of a redeclaration of ‘uint32_t start’).

                      below you find the ini file.

                    • #13001
                      Sara Damiano

                        I found the issue with the ThingSpeakDebugger. It’s now been fixed. It might take until tomorrow before PlatformIO “sees” the new version though.

                        To update your libraries in your current project:
                        – Open a new terminal in your project in Atom or go to the Terminal pane in VSCode
                        – type pio lib update
                        – all your libraries for the project should be updated. Watch for ModularSensors to move from 0.23.3 to 0.23.4.

                        If you’re feeling very impatient and don’t want to wait for the PlatformIO registries to catch the 0.23.4 update, you can uninstall the registered version of ModularSensors and install it from git instead:
                        – Open a new terminal in your project
                        – Uninstall ModularSensors by typing: pio lib uninstall EnviroDIY_ModularSensors
                        – Open your platformio.ini file in your project
                        – In the lib_deps section, replace EnviroDIY_ModularSensors with https://github.com/EnviroDIY/ModularSensors.git
                        – Save the platformio.ini
                        – “Clean” out any pre-compiled library bits by hitting the trash can button in Atom, or going to project tasks > clean in VSCode
                        – Re-compile and upload your program

                      • #13064

                          Thanks a lot, ThingSpeakDebugger is working!

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