Developer Setup

If you want to fork this repository and work with it, you'll need to set PlatformIO up a bit differently than you would to merely use this library.

First, fork this repository into your own GitHub space. Clone it to your local computer.

Open the folder you've cloned this repo into with either VSCode or Atom. Have PlatformIO create a new project for you, but instead of allowing it to create a new folder, select the folder you've already cloned this repo into.

Create a new source program to work with in a new directory. This is the directory you should reference in the src_dir line of your platformio.ini. Also add this directory to your .gitignore file so you can test and play with your code without publishing personal passwords or other messiness to the web. I recommend you start with one of the programs in the compile_tests folder rather than one of the examples because the compiler test programs are much more extensive and include all sensors and many modems in them.

Set your platformio.ini configuration file up like this:

1; PlatformIO Project Configuration File
2;
3
4[platformio]
5description = ModularSensors Library
6; Pick your default environment, if you have more than one and don't want to build all of them every time
7default_envs = mayfly
8; Set the director for the code you want to test from
9src_dir = your_directory/your_source_code
10
11[env]
12; Default baud for all examples
13monitor_speed = 115200
14framework = arduino
15; To run code checks; cppcheck and clangtidy must be installed
16check_tool = cppcheck, clangtidy
17check_patterns =
18 src
19 extras
20 examples
21check_flags =
22 cppcheck: --enable=all, --inline-suppr
23 clangtidy: --checks=-*
24; deep search for dependencies, evalulating preprocessor conditionals
25lib_ldf_mode = deep+
26; look for the library directory
27lib_extra_dirs = .
28; We have to ignore these folders or PlatformIO will double count all the dependencies
29lib_ignore =
30 .git
31 .pio
32 .vscode
33 doc
34 examples
35 sensor_tests
36 extras
37 Adafruit NeoPixel
38 Adafruit GFX Library
39 Adafruit SSD1306
40 Adafruit ADXL343
41 Adafruit STMPE610
42 Adafruit TouchScreen
43 Adafruit ILI9341
44; All these library dependencies must be listed out since we're in the library
45; source code and won't read the dependencies from the library.json like a
46; typical user would
47lib_deps =
48 envirodiy/EnviroDIY_DS3231
49 arduino-libraries/RTCZero
50 greygnome/EnableInterrupt
51 greiman/SdFat
52 vshymanskyy/TinyGSM
53 knolleary/PubSubClient
54 adafruit/Adafruit BusIO
55 adafruit/Adafruit Unified Sensor
56 https://github.com/soligen2010/Adafruit_ADS1X15.git
57 adafruit/Adafruit AM2315
58 adafruit/Adafruit BME280 Library
59 adafruit/DHT sensor library
60 adafruit/Adafruit INA219
61 adafruit/Adafruit MPL115A2
62 adafruit/Adafruit SHT4x Library
63 MartinL1/BMP388_DEV
64 paulstoffregen/OneWire
65 milesburton/DallasTemperature
66 envirodiy/SDI-12
67 northernwidget/MS5803
68 https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C
69 envirodiy/SensorModbusMaster
70 envirodiy/KellerModbus
71 envirodiy/YosemitechModbus
72 vshymanskyy/StreamDebugger
73; The directories for the ModularSensors library source code
74src_filter =
75 +<*>
76 +<../../src>
77 +<../../src/sensors>
78 +<../../src/publishers>
79 +<../../src/modems>
80 +<../../src/WatchDogs>
81 +<../../src/clocks>
82 +<../../src/utils>
83; Some common build flags
84build_flags =
85 -D SDI12_EXTERNAL_PCINT
86 -D NEOSWSERIAL_EXTERNAL_PCINT
87 -D MQTT_MAX_PACKET_SIZE=240
88 -D TINY_GSM_RX_BUFFER=64
89 -D TINY_GSM_YIELD_MS=2
90extra_scripts = pre:pioScripts/generate_compile_commands.py
91targets = compiledb
92
93[env:mayfly]
94; Find your COM port, enter it here, and remove the semicolon at the start of the line
95; upload_port = COM##
96; monitor_port = COM##
97board = mayfly
98platform = atmelavr
99framework = arduino
100; You probably need some software serial libraries
101lib_deps =
102 ${env.lib_deps}
103 https://github.com/EnviroDIY/SoftwareSerial_ExternalInts.git
104 https://github.com/PaulStoffregen/AltSoftSerial.git
105 https://github.com/SRGDamia1/NeoSWSerial.git
106; AVR boards need to ignore RTCZero, it's for SAMD only and will not compile for AVR
107lib_ignore =
108 ${env.lib_ignore}
109 RTCZero
110 Adafruit Zero DMA Library
111; Any extra build flags you want
112build_flags =
113 ${env.build_flags}
114 -D STANDARD_SERIAL_OUTPUT=Serial
115 -D DEBUGGING_SERIAL_OUTPUT=Serial
116 -D DEEP_DEBUGGING_SERIAL_OUTPUT=Serial
117; when I'm uploading frequently, I disable verification of the write
118upload_flags =
119 -V
120
121
122[env:adafruit_feather_m0]
123; Find your COM port, enter it here, and remove the semicolon at the start of the line
124; upload_port = COM##
125; monitor_port = COM##
126platform = atmelsam
127board = adafruit_feather_m0
128framework = arduino
129; SAMD boards need RTCZero for the real time clock and sleeping
130lib_deps =
131 ${env.lib_deps}
132 RTCZero
133; Most of the software serial libraries won't compile.
134; Use the SERCOM's; they're better anyway
135lib_ignore =
136 ${env.lib_ignore}
137 SoftwareSerial_ExtInts
138 AltSoftSerial
139 NeoSWSerial
140 SoftwareWire
141build_flags =
142 ${env.build_flags}
143build_unflags = -D USE_TINYUSB

While you're working on development, there is extensive debugging text built into this library. More on that is in the Code Debugging page. In fact, there is so much debugging that turning it on universally through a build flag will cause the program to be too big to fit on a Mayfly and will likely crash a SAMD board's on-board USB drivers.