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

Reply To: PlatormIO: ..Python 2.7 interpreter error

Home Forums Mayfly Data Logger PlatormIO: ..Python 2.7 interpreter error Reply To: PlatormIO: ..Python 2.7 interpreter error

Sara Damiano

    You need to include the Arduino library – add #include <Arduino.h> to the top of your program.  The Arduino IDE adds that automatically and does some other “massaging” of files when it converts an ino to a real cpp file that gcc then compiles; PlatformIO doesn’t.  Depending on how you’ve structured your program, that may cause a few more snags.  The two things your most likely to hit are:

    • pre-processor defines within a file (ie #define) which the Arduino IDE applies as global build flags rather than single-compile-unit defines
      • the defines you have for pin numbers and headers are probably ok
    • the basic cpp requirement that a function be declared or defined before it is used, which the Arduino IDE does some squirrlyness to get around.
      • If you have any functions in your program other than setup(){..} and loop(){...} make sure they’re above the setup and loop functions.  You may also have to re-order your functions depending on the order in which you’ve created/used them.

    Like most things, PlatformIO has some documentation on this:  https://docs.platformio.org/en/latest/faq.html#convert-arduino-file-to-c-manually

    I don’t know what all you’re doing in your program, but I’m it might be easier to start with the ModularSensors examples and use the already existing support for Atlas sensors.  And, of course, documentation for that:  https://github.com/EnviroDIY/ModularSensors/wiki/Atlas-Sensors