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: Newbie Mayfly Setup for RS485 sensor to internet

Home Forums Mayfly Data Logger Newbie Mayfly Setup for RS485 sensor to internet Reply To: Newbie Mayfly Setup for RS485 sensor to internet


    Hi Neil,

    You renamed the .ino file to a .cpp?

    Sorry I didn’t have time to explain what all of the things meant. 4 hours of glazed reading sounds painfully familiar.

    My platformio.ini file is in the root directory for my PlatformIO “project”. It has to be moved from the sketch folder to the root directory. Sara puts an example ini file in the sketch folder so we don’t have to guess which dependencies are needed for the sketch (which I really appreciate, but it seems to be a source of confusion for new users).

    Here’s where my sketch is located:

    And for that sketch, my ini file is located here:

    To “build” (aka “compile” and I sill think of it as compile, as does your terminal monitor!) the sketch, PlatformIO will use the instructions I give it in the ini file. When the build occurs, PlatformIO will fetch and write your libraries and write them to a hidden directory (at least as Atom renders PlatformIO). To see the hidden files, I go into Settings>Packages>tree-view and I uncheck the “Hide Ignored Names” default. This will reveal several folders in your root directory that were built based on your instructions in the ini file, including .git, .pioenvs, and .piolibdeps.

    My ini file looks something like this (and I’ll break it down below):

    ; PlatformIO Project Configuration File
    ; Build options: build flags, source filter
    ; Upload options: custom upload port, speed and extra flags
    ; Library options: dependencies, extra library storages
    ; Advanced options: extra scripting
    ; Please visit documentation for the other options and examples
    ; https://docs.platformio.org/page/projectconf.html

    ;src_dir = deploy-Limno/MeteoTsu-1
    ;src_dir = deploy-BAF/UST/Bixby4c
    ;src_dir = deploy-BAF/testsketches/Yosemitech_utilities/ChangeSlaveID
    ;src_dir = deploy-BAF/testsketches/Yosemitech_utilities/GetSlaveID
    ;src_dir = deploy-BAF/YosiConductivity
    src_dir = deploy-BAF/WSP01
    ;src_dir = deploy-BAF/testsketches/onewiresearch
    ;src_dir = deploy-BAF/baro_rho_correction

    platform = atmelavr
    framework = arduino
    board = mayfly
    lib_ldf_mode = deep
    lib_ignore = RTCZero
    lib_deps =
    ; Using ModularSensors *master* branch as of May 18, 2018: v0.11.7
    ; EnviroDIY_ModularSensors@=0.11.6
    ;Using ModularSensors *PaleoTerraRedox* branch as of Sept 18, after hardware I2C with variable base correction

    In this syntax, the semicolon is the comment out character and it *must* be at the beginning of the line with no spaces in front if it or you will think your computer is blowing up.

    Here’s how you tell your instructions to PlatformIO:

    [platformio]: Tells PlatformIO where to find your sketch (your .ino file). Don’t point to a file name, point to the directory. Remember how the Arduino IDE required you to have your sketch in an enclosing folder of the same name? Still true in PlatformIO. Notice that I like to keep several directories handy here, but I can build only one directory (the rest are commented out).

    [env:mayfly]: This is your virtual environment. PlatformIO knows the Mayfly board (and something like 500 other boards). There are several things to specify in the environment:

    platform = this is the type of microcontroller you are using. The Mayfly (and probably most Arduinos?) are AVR, which is a family of microcontrollers developed by Atmel.

    framework = arduino. This one makes sense, but apparently you can use multiple frameworks.

    board = mayfly

    lib_def_mode = This is how you want PlatformIO to search for library dependencies. The mode options are listed here. I’ve been directed to use “deep” and that seems to include everything we need.

    lib_ignore = Exclude this library.

    lib_deps = This is where we point to the URLs of GitHub repositories. We can tell PlatformIO to use the most recent version of the library (syntax matters), such as anything greater than or equal to version 0.12.2:

    Or you can point to a specific commit on GitHub, which allows you to point to development branches. My recent deployment used some new work that hadn’t been merged into the Master branch, so I directed it to the development branch. When I do this, I make a note about the date and any memorable aspects of that commit, so I don’t have to go back and read the commits on GitHub to remember why I selected that. I also keep track of which commits I used when I deploy a station (in a readme.md file in my deployment repository) so I can replicate it if needed:
    ;Using ModularSensors *PaleoTerraRedox* branch as of Sept 18, after hardware I2C with variable base correction

    Not sure why they must be listed separately, but currently the Modular Sensors library requires these libraries: