diff --git a/.github/workflows/build_examples.yaml b/.github/workflows/build_examples.yaml index f2d769bfb..6d548e3a4 100644 --- a/.github/workflows/build_examples.yaml +++ b/.github/workflows/build_examples.yaml @@ -14,14 +14,15 @@ jobs: [ examples/single_sensor/, examples/simple_logging/, + examples/simple_logging_LearnEnviroDIY/, examples/DRWI_CitSci/, examples/DRWI_LTE/, examples/DRWI_NoCellular/, examples/double_logger/, examples/baro_rho_correction/, examples/data_saving/, + examples/logging_to_MMW/, examples/logging_to_ThingSpeak/, - examples/menu_a_la_carte/, ] steps: @@ -53,76 +54,6 @@ jobs: python -m pip install --upgrade pip pip install --upgrade platformio - # Install *all* the dependencies! - - name: Install the dependencies at global level - run: | - echo "::debug::Installing envirodiy/EnviroDIY_DS3231" - pio lib -g install envirodiy/EnviroDIY_DS3231 - echo "::debug::Installing arduino-libraries/RTCZero" - pio lib -g install arduino-libraries/RTCZero - echo "::debug::Installing greygnome/EnableInterrupt" - pio lib -g install greygnome/EnableInterrupt - echo "::debug::Installing greiman/SdFat" - pio lib -g install greiman/SdFat - echo "::debug::Installing vshymanskyy/TinyGSM" - pio lib -g install vshymanskyy/TinyGSM - echo "::debug::Installing knolleary/PubSubClient" - pio lib -g install knolleary/PubSubClient - echo "::debug::Installing adafruit/'Adafruit BusIO'" - pio lib -g install adafruit/'Adafruit BusIO' - echo "::debug::Installing adafruit/'Adafruit Unified Sensor'" - pio lib -g install adafruit/'Adafruit Unified Sensor' - echo "::debug::Installing https://github.com/soligen2010/Adafruit_ADS1X15.git" - pio lib -g install https://github.com/soligen2010/Adafruit_ADS1X15.git - echo "::debug::Installing adafruit/'Adafruit AM2315'" - pio lib -g install adafruit/'Adafruit AM2315' - echo "::debug::Installing adafruit/'Adafruit BME280 Library'" - pio lib -g install adafruit/'Adafruit BME280 Library' - echo "::debug::Installing adafruit/'DHT sensor library'" - pio lib -g install adafruit/'DHT sensor library' - echo "::debug::Installing adafruit/'Adafruit INA219'" - pio lib -g install adafruit/'Adafruit INA219' - echo "::debug::Installing adafruit/'Adafruit MPL115A2'" - pio lib -g install adafruit/'Adafruit MPL115A2' - echo "::debug::Installing paulstoffregen/OneWire" - pio lib -g install paulstoffregen/OneWire - echo "::debug::Installing milesburton/DallasTemperature" - pio lib -g install milesburton/DallasTemperature - echo "::debug::Installing envirodiy/SDI-12" - pio lib -g install envirodiy/SDI-12 - echo "::debug::Installing northernwidget/MS5803" - pio lib -g install northernwidget/MS5803 - echo "::debug::Installing https://github.com/NorthernWidget-Skunkworks/Tally_Library.git#Dev_I2C" - pio lib -g install https://github.com/NorthernWidget-Skunkworks/Tally_Library.git#Dev_I2C - echo "::debug::Installing envirodiy/SensorModbusMaster" - pio lib -g install envirodiy/SensorModbusMaster - echo "::debug::Installing envirodiy/KellerModbus" - pio lib -g install envirodiy/KellerModbus - echo "::debug::Installing envirodiy/YosemitechModbus" - pio lib -g install envirodiy/YosemitechModbus - echo "::debug::Installing vshymanskyy/StreamDebugger" - pio lib -g install vshymanskyy/StreamDebugger - echo "::debug::Installing https://github.com/EnviroDIY/SoftwareSerial_ExternalInts.git" - pio lib -g install https://github.com/EnviroDIY/SoftwareSerial_ExternalInts.git - echo "::debug::Installing https://github.com/PaulStoffregen/AltSoftSerial.git" - pio lib -g install https://github.com/PaulStoffregen/AltSoftSerial.git - echo "::debug::Installing https://github.com/SRGDamia1/NeoSWSerial.git" - pio lib -g install https://github.com/SRGDamia1/NeoSWSerial.git - echo "::debug::Installing https://github.com/Testato/SoftwareWire.git" - pio lib -g install https://github.com/Testato/SoftwareWire.git - - - name: Update Libraries from Cache - run: pio lib -g update - - # # We want to install from exactly the point that we're working on - # # NOTE: We do NOT install to the global directory so it's not cached! - # - name: Install ModularSensors as current state - # run: | - # ls - # mkdir -p ${{ github.workspace }}/lib - # ls - # pio lib -d ${{ github.workspace }}/lib install https://github.com/${{ github.repository }}.git#$GITHUB_SHA - - name: Run PlatformIO run: platformio ci --project-conf="continuous_integration/platformio.ini" env: diff --git a/.github/workflows/build_menu.yaml b/.github/workflows/build_menu.yaml new file mode 100644 index 000000000..175f0a639 --- /dev/null +++ b/.github/workflows/build_menu.yaml @@ -0,0 +1,45 @@ +name: Build Examples + +# Triggers the workflow on push or pull request events +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + env: + PLATFORMIO_SRC_DIR: temp/menu_a_la_carte + if: "!contains(github.event.head_commit.message, 'ci skip')" + + steps: + - uses: actions/checkout@v2 + + - name: Restore or Cache pip + uses: actions/cache@v2.1.4 + with: + path: ~/.cache/pip + # if requirements.txt hasn't changed, then it will be a "cache hit" and pip will be restored + # if requirements.txt HAS changed, it will be a "cache miss" and a new cache of pip will be created if the job completes successfully + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: ${{ runner.os }}-pip- + + - name: Restore or Cache PlatformIO and Libraries + uses: actions/cache@v2.1.4 + with: + path: ~/.platformio + # if nothing in the lock files has changed, then it will be a "cache hit" and pip will be restored + # otherwise, it will be a "cache miss" and a new cache of libraries will be created if the job completes successfully + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + + - name: Set up Python + uses: actions/setup-python@v2 + + # This should be pulled from cache, if there's not a new version + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + + - name: Test all configurations + run: | + chmod +x continuous_integration/build-menu-configurations.sh + sh continuous_integration/build-menu-configurations.sh diff --git a/.github/workflows/prepare_release.yaml b/.github/workflows/prepare_release.yaml index 67995d8d4..64e7b81d6 100644 --- a/.github/workflows/prepare_release.yaml +++ b/.github/workflows/prepare_release.yaml @@ -151,12 +151,16 @@ jobs: pio lib -g uninstall adafruit/Adafruit ILI9341 # zip up all the installed libraries + # need to cd into the pio directory so we don't get extra junk directories - name: Zip libraries run: | echo "::debug::Listing global libraries" pio lib -g list echo "::debug::Zipping global libraries" + cd ~/.platformio zip ${{ env.ZIP_NAME }}.zip -r ~/.platformio/lib + mv ${{ env.ZIP_NAME }}.zip $GITHUB_WORKSPACE + cd $GITHUB_WORKSPACE # Remove some extras from the zip - name: Remove git files from the zip diff --git a/ChangeLog.md b/ChangeLog.md index f87d36c66..090893fc4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Downloads -**[ModularSensors_Dependencies_0.28.0.zip](https://github.com/EnviroDIY/ModularSensors/releases/download/v0.28.0/ModularSensors_Dependencies_0.28.0.zip)** +**[ModularSensors_Dependencies_v0.28.0.zip](https://github.com/EnviroDIY/ModularSensors/releases/download/v0.28.0/ModularSensors_Dependencies_v0.28.0.zip)** - contains this version of ModularSensors _and the proper versions of all of its dependencies_. ### New Features @@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Downloads -**[ModularSensors_Dependencies_0.27.8.zip](https://github.com/EnviroDIY/ModularSensors/releases/download/v0.27.8/ModularSensors_Dependencies_0.27.8.zip)** contains this version of ModularSensors _and the proper versions of all of its dependencies_. +**[ModularSensors_Dependencies_v0.27.8.zip](https://github.com/EnviroDIY/ModularSensors/releases/download/v0.27.8/ModularSensors_Dependencies_v0.27.8.zip)** contains this version of ModularSensors _and the proper versions of all of its dependencies_. ### Bug Fixes - Just fixes an error in the github action to post a release diff --git a/continuous_integration/build-menu-configurations.sh b/continuous_integration/build-menu-configurations.sh new file mode 100644 index 000000000..444d05ee0 --- /dev/null +++ b/continuous_integration/build-menu-configurations.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +for modemFlag in \ + MS_BUILD_TEST_XBEE_CELLULAR \ + MS_BUILD_TEST_XBEE_LTE_B \ + MS_BUILD_TEST_XBEE_3G_B \ + MS_BUILD_TEST_XBEE_WIFI \ + MS_BUILD_TEST_ESP8266 \ + MS_BUILD_TEST_BG96 \ + MS_BUILD_TEST_MONARCH \ + MS_BUILD_TEST_SIM800 \ + MS_BUILD_TEST_SIM7000 \ + MS_BUILD_TEST_S2GB \ + MS_BUILD_TEST_UBEE_R410M \ + MS_BUILD_TEST_UBEE_U201 + +do + sed -i '1s/^/#define MS_BUILD_TEST_PRE_NAMED_VARS\n#define $modemFlag\n/' examples/menu_a_la_carte/menu_a_la_carte.ino > temp/menu_a_la_carte/main.cpp + + head temp/menu_a_la_carte/main.cpp + + platformio run --project-conf="continuous_integration/platformio.ini" +done + +for sensorFlag in \ + MS_BUILD_TEST_AM2315 \ + MS_BUILD_TEST_DHT \ + MS_BUILD_TEST_SQ212 \ + MS_BUILD_TEST_ATLASCO2 \ + MS_BUILD_TEST_ATLASDO \ + MS_BUILD_TEST_ATLASORP \ + MS_BUILD_TEST_ATLASPH \ + MS_BUILD_TEST_ATLASRTD \ + MS_BUILD_TEST_ATLASEC \ + MS_BUILD_TEST_BME280 \ + MS_BUILD_TEST_OBS3 \ + MS_BUILD_TEST_ES2 \ + MS_BUILD_TEST_VOLTAGE \ + MS_BUILD_TEST_MPL115A2 \ + MS_BUILD_TEST_INSITURDO \ + MS_BUILD_TEST_ACCULEVEL \ + MS_BUILD_TEST_NANOLEVEL \ + MS_BUILD_TEST_MAXBOTIX \ + MS_BUILD_TEST_DS18 \ + MS_BUILD_TEST_MS5803 \ + MS_BUILD_TEST_5TM \ + MS_BUILD_TEST_CTD \ + MS_BUILD_TEST_TEROS11 \ + MS_BUILD_TEST_PALEOTERRA \ + MS_BUILD_TEST_RAINI2C \ + MS_BUILD_TEST_TALLY \ + MS_BUILD_TEST_INA219 \ + MS_BUILD_TEST_CYCLOPS \ + MS_BUILD_TEST_ANALOGEC \ + MS_BUILD_TEST_Y504 \ + MS_BUILD_TEST_Y510 \ + MS_BUILD_TEST_Y511 \ + MS_BUILD_TEST_Y514 \ + MS_BUILD_TEST_Y520 \ + MS_BUILD_TEST_Y532 \ + MS_BUILD_TEST_Y533 \ + MS_BUILD_TEST_Y550 \ + MS_BUILD_TEST_Y4000 \ + MS_BUILD_TEST_DOPTO \ + +do + sed -i '1s/^/#define MS_BUILD_TEST_XBEE_CELLULAR\n#define MS_BUILD_TEST_PRE_NAMED_VARS\n#define $sensorFlag\n/' examples/menu_a_la_carte/menu_a_la_carte.ino > temp/menu_a_la_carte/main.cpp + + head temp/menu_a_la_carte/main.cpp + + platformio run --project-conf="continuous_integration/platformio.ini" +done + +for publisherFlag in \ + MS_BUILD_TEST_MMW \ + MS_BUILD_TEST_DREAMHOST \ + MS_BUILD_TEST_THINGSPEAK \ + +do + sed -i '1s/^/#define MS_BUILD_TEST_XBEE_CELLULAR\n#define MS_BUILD_TEST_PRE_NAMED_VARS\n#define $publisherFlag\n/' examples/menu_a_la_carte/menu_a_la_carte.ino > temp/menu_a_la_carte/main.cpp + + head temp/menu_a_la_carte/main.cpp + + platformio run --project-conf="continuous_integration/platformio.ini" +done \ No newline at end of file diff --git a/continuous_integration/platformio.ini b/continuous_integration/platformio.ini index 342cfb36d..f64cf8202 100644 --- a/continuous_integration/platformio.ini +++ b/continuous_integration/platformio.ini @@ -14,16 +14,17 @@ ; [platformio] +build_cache_dir = cache [env] framework = arduino lib_ldf_mode = deep+ build_flags = - -DSDI12_EXTERNAL_PCINT - -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 + -D SDI12_EXTERNAL_PCINT + -D NEOSWSERIAL_EXTERNAL_PCINT + -D MQTT_MAX_PACKET_SIZE=240 + -D TINY_GSM_RX_BUFFER=64 + -D TINY_GSM_YIELD_MS=2 lib_ignore = Adafruit NeoPixel Adafruit GFX Library @@ -41,6 +42,28 @@ platform = atmelavr lib_ignore = ${env.lib_ignore} RTCZero + Adafruit Zero DMA Library +build_flags = + ${env.build_flags} + -D MS_BUILD_TEST_ALTSOFTSERIAL + -D MS_BUILD_TEST_NEOSWSERIAL + -D MS_BUILD_TEST_SOFTSERIAL + -D MS_USE_COMPLEX_LOOP + + +[env:mega] +platform = atmelavr +board = megaatmega2560 +lib_ignore = + ${env.lib_ignore} + RTCZero + Adafruit Zero DMA Library +build_flags = + ${env.build_flags} + -D MS_ATLAS_SOFTWAREWIRE + -D MS_RAIN_SOFTWAREWIRE + -D MS_PALEOTERRA_SOFTWAREWIRE + -D MS_SDI12_NON_CONCURRENT [env:adafruit_feather_m0] @@ -54,8 +77,8 @@ lib_ignore = SoftwareWire build_flags = ${env.build_flags} - -DMS_USE_ADS1015 -build_unflags = -DUSE_TINYUSB + -D MS_USE_ADS1015 +build_unflags = -D USE_TINYUSB [env:autonomo] @@ -71,188 +94,6 @@ lib_ignore = SoftwareWire build_flags = ${env.build_flags} - -DENABLE_SERIAL2 - -DENABLE_SERIAL3 - -DMS_SAMD_DS3231 - - -[env:mega] -platform = atmelavr -board = megaatmega2560 -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -DMS_ATLAS_SOFTWAREWIRE - -DMS_RAIN_SOFTWAREWIRE - -DMS_PALEOTERRA_SOFTWAREWIRE - - -[env:mayfly_xb3c] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_XBEE_CELLULAR - - -[env:mayfly_xb3lteb] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_XBEE_LTE_B - - -[env:mayfly_xb3gb] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_XBEE_3G_B - - -[env:mayfly_xbw] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_XBEE_WIFI - - -[env:mayfly_esp] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_ESP8266 - - -[env:mayfly_bg96] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_BG96 - - -[env:mayfly_monarch] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_MONARCH - - -[env:mayfly_sim800] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_SIM800 - - -[env:mayfly_sim7000] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_SIM7000 - - -[env:mayfly_s2gb] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_S2GB - - -[env:mayfly_ub410] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_UBEE_R410M - - -[env:mayfly_ub200] -board = mayfly -platform = atmelavr -lib_ignore = - ${env.lib_ignore} - RTCZero - Adafruit Zero DMA Library -build_flags = - ${env.build_flags} - -Wextra - -DMS_BUILD_TESTING - -DMS_BUILD_TEST_UBEE_U201 + -D ENABLE_SERIAL2 + -D ENABLE_SERIAL3 + -D MS_SAMD_DS3231 \ No newline at end of file diff --git a/docs/Doxyfile b/docs/Doxyfile index 193d5fc4b..de7f6b998 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -2295,7 +2295,6 @@ PREDEFINED = DOXYGEN=1 \ STANDARD_SERIAL_OUTPUT=Serial \ DEBUGGING_SERIAL_OUTPUT=Serial \ DEEP_DEBUGGING_SERIAL_OUTPUT=Serial \ - MS_BUILD_TESTING \ TINY_GSM_MODEM_HAS_GPRS \ TINY_GSM_MODEM_HAS_WIFI \ TINY_GSM_MODEM_HAS_BATTERY \ diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 47f82498f..2ca2f247e 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -28,13 +28,14 @@ ___ - [Defines for the Arduino IDE](#defines-for-the-arduino-ide) - [Library Includes](#library-includes) - [Logger Settings](#logger-settings) - - [Extra Serial Ports](#extra-serial-ports) + - [Creating Extra Serial Ports](#creating-extra-serial-ports) - [AVR Boards](#avr-boards) - [AltSoftSerial](#altsoftserial) - [NeoSWSerial](#neoswserial) - [SoftwareSerial with External Interrupts](#softwareserial-with-external-interrupts) - [Software I2C/Wire](#software-i2cwire) - [SAMD Boards](#samd-boards) + - [Assigning Serial Port Functionality](#assigning-serial-port-functionality) - [Logging Options](#logging-options) - [Wifi/Cellular Modem Options](#wificellular-modem-options) - [Digi XBee Cellular - Transparent Mode](#digi-xbee-cellular---transparent-mode) @@ -168,8 +169,8 @@ ___ [//]: # ( @section menu_logger_and_modem_settings Logger Settings ) ## Logger Settings -[//]: # ( @subsection menu_serial_ports Extra Serial Ports ) -### Extra Serial Ports +[//]: # ( @subsection menu_serial_ports Creating Extra Serial Ports ) +### Creating Extra Serial Ports This section of the example has all the code to create and link to serial ports for both AVR and SAMD based boards. The EnviroDIY Mayfly, the Arduino Mega, UNO, and Leonardo are all AVR boards. @@ -261,6 +262,16 @@ NOTE: The SAMD51 board has an amazing _8_ available SERCOM's, but I do not have --- +[//]: # ( @subsection menu_serial_func Assigning Serial Port Functionality ) +### Assigning Serial Port Functionality + +This section just assigns all the serial ports from the @ref menu_serial_ports section above to specific functionality. +For a board with the option of up to 4 hardware serial ports, like the SAMD21 or Arduino Mega, we use the Serial1 to talk to the modem, Serial2 for modbus, and Serial3 for the Maxbotix. +For an AVR board where we're relying on a mix of hardware and software ports, we use hardware Serial 1 for the modem, AltSoftSerial for modbus, and NeoSWSerial for the Maxbotix. +Depending on how you rank the importance of each component, you can adjust these to your liking. + +--- + [//]: # ( @subsection menu_logger_opts Logging Options ) ### Logging Options @@ -779,6 +790,9 @@ The Arduino pin controlling the receive and data enable on your RS485-to-TTL ada (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. In tests on these sensors, SoftwareSerial_ExtInts _did not work_ to communicate with these sensors, because it isn't stable enough. AltSoftSerial and HardwareSerial work fine. + +The serial ports for this example are created in the @ref menu_serial_ports section and then assigned to modbus functionality in the @ref menu_serial_func section. + Up to two power pins are provided so that the RS485 adapter, the sensor and/or an external power relay can be controlled separately. If the power to everything is controlled by the same pin, use -1 for the second power pin or omit the argument. If they are controlled by different pins _and no other sensors are dependent on power from either pin_ then the order of the pins doesn't matter. @@ -810,7 +824,10 @@ ___ ### Maxbotix HRXL Ultrasonic Range Finder The Arduino pin controlling power on/off, a stream instance for received data (ie, `Serial`), and the Arduino pin controlling the trigger are required for the sensor constructor. -(Use -1 for the trigger pin if you do not have it connected.) Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. +(Use -1 for the trigger pin if you do not have it connected.) +Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. + +The serial ports for this example are created in the @ref menu_serial_ports section and then assigned to the sonar functionality in the @ref menu_serial_func section. @see @ref sensor_maxbotix @@ -892,7 +909,7 @@ The constructors for the software I2C implementation requires either the SCL and All variants of the constructor require the Arduino power pin. The I2C address can be given if it the sensor is not set to the default of 0x68. A number of readings to average can also be given. - +**** @warning Either all or none of your attached redox probes may use software I2C. Using some with software I2C and others with hardware I2C is not supported. @@ -992,6 +1009,11 @@ The Arduino pin controlling the receive and data enable on your RS485-to-TTL ada (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) For most of the sensors, Yosemitech strongly recommends averaging multiple (in most cases 10) readings for each measurement. Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. +In tests on these sensors, SoftwareSerial_ExtInts _did not work_ to communicate with these sensors, because it isn't stable enough. +AltSoftSerial and HardwareSerial work fine. +NeoSWSerial is a bit hit or miss, but can be used in a pinch. + +The serial ports for this example are created in the @ref menu_serial_ports section and then assigned to modbus functionality in the @ref menu_serial_func section. @see @ref yosemitech_group diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index bde1d97b2..f426d5a85 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -51,7 +51,7 @@ // ========================================================================== -// Settings for Additional Serial Ports +// Creating Additional Serial Ports // ========================================================================== // The modem and a number of sensors communicate over UART/TTL - often called // "serial". "Hardware" serial ports (automatically controlled by the MCU) are @@ -63,6 +63,7 @@ // Unfortunately, most AVR boards have only one or two hardware serial ports, // so we'll set up three types of extra software serial ports to use +#ifdef MS_BUILD_TEST_ALTSOFTSERIAL // AltSoftSerial by Paul Stoffregen // (https://github.com/PaulStoffregen/AltSoftSerial) is the most accurate // software serial port for AVR boards. AltSoftSerial can only be used on one @@ -72,10 +73,12 @@ #include AltSoftSerial altSoftSerial; /** End [altsoftserial] */ +#endif // #ifdef MS_BUILD_TEST_ALTSOFTSERIAL +#ifdef MS_BUILD_TEST_NEOSWSERIAL // NeoSWSerial (https://github.com/SRGDamia1/NeoSWSerial) is the best software // serial that can be used on any pin supporting interrupts. -// You can use as many instances of NeoSWSerial as you want. +// You can use as many instances of NeoSWSerial as you need. // Not all AVR boards are supported by NeoSWSerial. /** Start [neoswserial] */ #include // for the stream communication @@ -88,13 +91,16 @@ void neoSSerial1ISR() { NeoSWSerial::rxISR(*portInputRegister(digitalPinToPort(neoSSerial1Rx))); } /** End [neoswserial] */ +#endif // #ifdef MS_BUILD_TEST_NEOSWSERIAL +#ifdef MS_BUILD_TEST_SOFTSERIAL // The "standard" software serial library uses interrupts that conflict // with several other libraries used within this program. I've created a // [version of software serial that has been stripped of // interrupts](https://github.com/EnviroDIY/SoftwareSerial_ExtInts) but it is // still far from ideal. // NOTE: Only use if necessary. This is not a very accurate serial port! +// You can use as many instances of SoftwareSerial as you need. /** Start [softwareserial] */ const int8_t softSerialRx = A3; // data in pin const int8_t softSerialTx = A4; // data out pin @@ -102,9 +108,11 @@ const int8_t softSerialTx = A4; // data out pin #include // for the stream communication SoftwareSerial_ExtInts softSerial1(softSerialRx, softSerialTx); /** End [softwareserial] */ -#endif // End software serial for avr boards +#endif // #ifdef MS_BUILD_TEST_SOFTSERIAL +#if defined MS_PALEOTERRA_SOFTWAREWIRE || defined MS_ATLAS_SOFTWAREWIRE || \ + defined MS_RAIN_SOFTWAREWIRE /** Start [softwarewire] */ // A software I2C (Wire) instance using Testato's SoftwareWire // To use SoftwareWire, you must also set a define for the sensor you want to @@ -116,16 +124,16 @@ SoftwareSerial_ExtInts softSerial1(softSerialRx, softSerialTx); // `-D MS_ATLAS_SOFTWAREWIRE` // `-D MS_RAIN_SOFTWAREWIRE` // `-D MS_PALEOTERRA_SOFTWAREWIRE` -#if defined MS_PALEOTERRA_SOFTWAREWIRE || defined MS_ATLAS_SOFTWAREWIRE || \ - defined MS_RAIN_SOFTWAREWIRE #include // Testato's Software I2C const int8_t softwareSDA = 5; const int8_t softwareSCL = 4; SoftwareWire softI2C(softwareSDA, softwareSCL); -#endif /** End [softwarewire] */ +#endif // #if defined MS_PALEOTERRA_SOFTWAREWIRE ... +#endif // End software serial for avr boards +#if defined ARDUINO_ARCH_SAMD /** Start [serial_ports_SAMD] */ // The SAMD21 has 6 "SERCOM" ports, any of which can be used for UART // communication. The "core" code for most boards defines one or more UART @@ -146,8 +154,6 @@ SoftwareWire softI2C(softwareSDA, softwareSCL); // #define ENABLE_SERIAL2 // #define ENABLE_SERIAL3 - -#if defined ARDUINO_ARCH_SAMD #include // Needed for SAMD pinPeripheral() function #ifndef ENABLE_SERIAL2 @@ -180,8 +186,58 @@ void SERCOM2_Handler() { } #endif -#endif // End hardware serial on SAMD21 boards /** End [serial_ports_SAMD] */ +#endif // End hardware serial on SAMD21 boards + + +// ========================================================================== +// Assigning Serial Port Functionality +// ========================================================================== +#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 +/** Start [assign_ports_hw] */ +// If there are additional hardware Serial ports possible - use them! + +// We give the modem first priority and assign it to hardware serial +// All of the supported processors have a hardware port available named Serial1 +#define modemSerial Serial1 + +// Define the serial port for modbus +// Modbus (at 9600 8N1) is used by the Keller level loggers and Yosemitech +// sensors +#define modbusSerial Serial2 + +// The Maxbotix sonar is the only sensor that communicates over a serial port +// but does not use modbus +#define sonarSerial Serial3 + +/** End [assign_ports_hw] */ +#else +/** Start [assign_ports_sw] */ + +// We give the modem first priority and assign it to hardware serial +// All of the supported processors have a hardware port available named Serial1 +#define modemSerial Serial1 + +// Define the serial port for modbus +// Modbus (at 9600 8N1) is used by the Keller level loggers and Yosemitech +// sensors +// Since AltSoftSerial is the best software option, we use it for modbus +// If AltSoftSerial (or its pins) aren't avaiable, use NeoSWSerial +// SoftwareSerial **WILL NOT** work for modbus! +#define modbusSerial altSoftSerial // For AltSoftSerial +// #define modbusSerial neoSSerial1 // For Neo software serial +// #define modbusSerial softSerial1 // For software serial + +// The Maxbotix sonar is the only sensor that communicates over a serial port +// but does not use modbus +// Since the Maxbotix only needs one-way communication and sends a simple text +// string repeatedly, almost any software serial port will do for it. +// #define sonarSerial altSoftSerial // For AltSoftSerial +#define sonarSerial neoSSerial1 // For Neo software serial +// #define sonarSerial softSerial1 // For software serial + +/** End [assign_ports_sw] */ +#endif // ========================================================================== @@ -219,7 +275,7 @@ const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power // Delete the sections you are not using! // ========================================================================== -#if not defined MS_BUILD_TESTING || defined MS_BUILD_TEST_XBEE_CELLULAR +#if defined MS_BUILD_TEST_XBEE_CELLULAR /** Start [xbee_cell_transparent] */ // For any Digi Cellular XBee's // NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) can be used @@ -227,12 +283,8 @@ const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power // The Telit based Digi XBees (LTE Cat1) can only use this mode. #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // All XBee's use 9600 by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -264,19 +316,15 @@ DigiXBeeCellularTransparent modem = modemXBCT; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_XBEE_LTE_B +#elif defined MS_BUILD_TEST_XBEE_LTE_B /** Start [xbee3_ltem_bypass] */ // For the u-blox SARA R410M based Digi LTE-M XBee3 // NOTE: According to the manual, this should be less stable than transparent // mode, but my experience is the complete reverse. #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // All XBee's use 9600 by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -305,19 +353,15 @@ DigiXBeeLTEBypass modem = modemXBLTEB; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_XBEE_3G_B +#elif defined MS_BUILD_TEST_XBEE_3G_B /** Start [xbee_3g_bypass] */ // For the u-blox SARA U201 based Digi 3G XBee with 2G fallback // NOTE: According to the manual, this should be less stable than transparent // mode, but my experience is the complete reverse. #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // All XBee's use 9600 by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -346,17 +390,13 @@ DigiXBee3GBypass modem = modemXB3GB; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_XBEE_WIFI +#elif defined MS_BUILD_TEST_XBEE_WIFI /** Start [xbee_wifi] */ // For the Digi Wifi XBee (S6B) #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // All XBee's use 9600 by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -386,18 +426,14 @@ DigiXBeeWifi modem = modemXBWF; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_ESP8266 +#elif defined MS_BUILD_TEST_ESP8266 /** Start [esp8266] */ // For almost anything based on the Espressif ESP8266 using the // AT command firmware #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 115200; // Communication speed of the modem // NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The // module should be programmed to a slower baud rate or set to auto-baud using @@ -435,17 +471,13 @@ EspressifESP8266 modem = modemESP; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_BG96 +#elif defined MS_BUILD_TEST_BG96 /** Start [bg96] */ // For the Dragino, Nimbelink or other boards based on the Quectel BG96 #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 115200; // Communication speed of the modem // NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The // module should be programmed to a slower baud rate or set to auto-baud using @@ -473,18 +505,14 @@ QuectelBG96 modem = modemBG96; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_MONARCH +#elif defined MS_BUILD_TEST_MONARCH /** Start [monarch] */ // For the Nimbelink LTE-M Verizon/Sequans or other boards based on the Sequans // Monarch series #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 921600; // Default baud rate of SVZM20 is 921600 // NOTE: This baud rate is much too fast for many Arduinos! The module should // be programmed to a slower baud rate or set to auto-baud using the AT+IPR @@ -512,18 +540,14 @@ SequansMonarch modem = modemSVZM; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_SIM800 +#elif defined MS_BUILD_TEST_SIM800 /** Start [sim800] */ // For almost anything based on the SIMCom SIM800 EXCEPT the Sodaq 2GBee R6 and // higher #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // SIM800 does auto-bauding by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -548,17 +572,13 @@ SIMComSIM800 modem = modemS800; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_SIM7000 +#elif defined MS_BUILD_TEST_SIM7000 /** Start [sim7000] */ // For almost anything based on the SIMCom SIM7000 #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // SIM7000 does auto-bauding by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -582,18 +602,14 @@ SIMComSIM7000 modem = modem7000; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_S2GB +#elif defined MS_BUILD_TEST_S2GB /** Start [gprsbee] */ // For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 // NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // SIM800 does auto-bauding by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -617,17 +633,13 @@ Sodaq2GBeeR6 modem = modem2GB; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_UBEE_R410M +#elif defined MS_BUILD_TEST_UBEE_R410M /** Start [sara_r410m] */ // For the Sodaq UBee based on the 4G LTE-M u-blox SARA R410M #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 115200; // Default baud rate of the SARA R410M is 115200 // NOTE: The SARA R410N DOES NOT save baud rate to non-volatile memory. After // every power loss, the module will return to the default baud rate of 115200. @@ -658,17 +670,13 @@ SodaqUBeeR410M modem = modemR410; // ========================================================================== -#elif defined MS_BUILD_TESTING && defined MS_BUILD_TEST_UBEE_U201 +#elif defined MS_BUILD_TEST_UBEE_U201 /** Start [sara_u201] */ // For the Sodaq UBee based on the 3G u-blox SARA U201 #include -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const long modemBaud = 9600; // SARA U2xx module does auto-bauding by default // Modem Pins - Describe the physical pin connection of your modem to your board @@ -732,6 +740,7 @@ Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( /** End [processor_sensor] */ +#if defined ARDUINO_ARCH_AVR || defined MS_SAMD_DS3231 // ========================================================================== // Maxim DS3231 RTC (Real Time Clock) // ========================================================================== @@ -745,8 +754,10 @@ MaximDS3231 ds3231(1); Variable* ds3231Temp = new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-ef00-1234567890ab"); /** End [ds3231] */ +#endif +#if defined MS_BUILD_TEST_AM2315 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // AOSong AM2315 Digital Humidity and Temperature Sensor // ========================================================================== @@ -764,8 +775,10 @@ Variable* am2315Humid = Variable* am2315Temp = new AOSongAM2315_Temp(&am2315, "12345678-abcd-1234-ef00-1234567890ab"); /** End [am2315] */ +#endif +#if defined MS_BUILD_TEST_DHT || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // AOSong DHT 11/21 (AM2301)/22 (AM2302) Digital Humidity and Temperature // ========================================================================== @@ -787,8 +800,10 @@ Variable* dhtTemp = new AOSongDHT_Temp(&dht, Variable* dhtHI = new AOSongDHT_HI(&dht, "12345678-abcd-1234-ef00-1234567890ab"); /** End [dht] */ +#endif +#if defined MS_BUILD_TEST_SQ212 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Apogee SQ-212 Photosynthetically Active Radiation (PAR) Sensor // ========================================================================== @@ -808,8 +823,10 @@ Variable* sq212PAR = Variable* sq212voltage = new ApogeeSQ212_Voltage(&SQ212, "12345678-abcd-1234-ef00-1234567890ab"); /** End [sq212] */ +#endif +#if defined MS_BUILD_TEST_ATLASCO2 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-CO2 Embedded NDIR Carbon Dioxide Sensor // ========================================================================== @@ -838,8 +855,10 @@ Variable* atlasCO2CO2 = new AtlasScientificCO2_CO2( Variable* atlasCO2Temp = new AtlasScientificCO2_Temp( &atlasCO2, "12345678-abcd-1234-ef00-1234567890ab"); /** End [atlas_co2] */ +#endif +#if defined MS_BUILD_TEST_ATLASDO || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-DO Dissolved Oxygen Sensor // ========================================================================== @@ -868,8 +887,10 @@ Variable* atlasDOconc = new AtlasScientificDO_DOmgL( Variable* atlasDOpct = new AtlasScientificDO_DOpct( &atlasDO, "12345678-abcd-1234-ef00-1234567890ab"); /** End [atlas_do] */ +#endif +#if defined MS_BUILD_TEST_ATLASORP || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-ORP Oxidation/Reduction Potential Sensor // ========================================================================== @@ -896,8 +917,10 @@ AtlasScientificORP atlasORP(AtlasORPPower); Variable* atlasORPot = new AtlasScientificORP_Potential( &atlasORP, "12345678-abcd-1234-ef00-1234567890ab"); /** End [atlas_orp] */ +#endif +#if defined MS_BUILD_TEST_ATLASPH || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-pH Sensor // ========================================================================== @@ -924,8 +947,10 @@ AtlasScientificpH atlaspH(AtlaspHPower); Variable* atlaspHpH = new AtlasScientificpH_pH(&atlaspH, "12345678-abcd-1234-ef00-1234567890ab"); /** End [atlas_ph] */ +#endif +#if defined MS_BUILD_TEST_ATLASRTD || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-RTD Temperature Sensor // ========================================================================== @@ -952,8 +977,10 @@ AtlasScientificRTD atlasRTD(AtlasRTDPower); Variable* atlasTemp = new AtlasScientificRTD_Temp( &atlasRTD, "12345678-abcd-1234-ef00-1234567890ab"); /** End [atlas_rtd] */ +#endif +#if defined MS_BUILD_TEST_ATLASEC || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Atlas Scientific EZO-EC Conductivity Sensor // ========================================================================== @@ -993,10 +1020,9 @@ Variable* atlasGrav = new AtlasScientificEC_SpecificGravity( // **DO NOT** use your logger board temperature (ie, from the DS3231) to // calculate specific conductance! float calculateAtlasSpCond(void) { - float spCond = -9999; // Always safest to start with a bad value - float waterTemp = atlasTemp->getValue(); - float rawCond = atlasCond->getValue(); - float temperatureCoef = 0.019; + float spCond = -9999; // Always safest to start with a bad value + float waterTemp = atlasTemp->getValue(); + float rawCond = atlasCond->getValue(); // ^^ Linearized temperature correction coefficient per degrees Celsius. // The value of 0.019 comes from measurements reported here: // Hayashi M. Temperature-electrical conductivity relation of water for @@ -1006,6 +1032,7 @@ float calculateAtlasSpCond(void) { if (waterTemp != -9999 && rawCond != -9999) // make sure both inputs are good { + float temperatureCoef = 0.019; spCond = rawCond / (1 + temperatureCoef * (waterTemp - 25.0)); } return spCond; @@ -1028,8 +1055,10 @@ Variable* atlasSpCond = new Variable(calculateAtlasSpCond, atlasSpCondResolution, atlasSpCondName, atlasSpCondUnit, atlasSpCondCode, atlasSpCondUUID); /** End [atlas_ec] */ +#endif +#if defined MS_BUILD_TEST_BME280 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Bosch BME280 Environmental Sensor // ========================================================================== @@ -1054,8 +1083,10 @@ Variable* bme280Press = Variable* bme280Alt = new BoschBME280_Altitude(&bme280, "12345678-abcd-1234-ef00-1234567890ab"); /** End [bme280] */ +#endif +#if defined MS_BUILD_TEST_OBS3 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== @@ -1079,9 +1110,9 @@ CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, // Create turbidity and voltage variable pointers for the low range of the OBS3 Variable* obs3TurbLow = new CampbellOBS3_Turbidity( - &osb3low, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* obs3VoltLow = - new CampbellOBS3_Voltage(&osb3low, "12345678-abcd-1234-ef00-1234567890ab"); + &osb3low, "12345678-abcd-1234-ef00-1234567890ab", "TurbLow"); +Variable* obs3VoltLow = new CampbellOBS3_Voltage( + &osb3low, "12345678-abcd-1234-ef00-1234567890ab", "TurbLowV"); const int8_t OBSHighADSChannel = 1; // ADS channel for *high* range output @@ -1097,12 +1128,14 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, // Create turbidity and voltage variable pointers for the high range of the OBS3 Variable* obs3TurbHigh = new CampbellOBS3_Turbidity( - &osb3high, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* obs3VoltHigh = - new CampbellOBS3_Voltage(&osb3high, "12345678-abcd-1234-ef00-1234567890ab"); + &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHigh"); +Variable* obs3VoltHigh = new CampbellOBS3_Voltage( + &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHighV"); /** End [obs3] */ +#endif +#if defined MS_BUILD_TEST_ES2 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Decagon ES2 Conductivity and Temperature Sensor // ========================================================================== @@ -1117,14 +1150,16 @@ const uint8_t ES2NumberReadings = 5; // Create a Decagon ES2 sensor object DecagonES2 es2(*ES2SDI12address, ES2Power, ES2Data, ES2NumberReadings); -// Create conductivity and temperature variable pointers for the ES2 +// Create specific conductance and temperature variable pointers for the ES2 Variable* es2Cond = new DecagonES2_Cond(&es2, "12345678-abcd-1234-ef00-1234567890ab"); Variable* es2Temp = new DecagonES2_Temp(&es2, "12345678-abcd-1234-ef00-1234567890ab"); /** End [es2] */ +#endif +#if defined MS_BUILD_TEST_VOLTAGE || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // External Voltage via TI ADS1115 // ========================================================================== @@ -1145,8 +1180,10 @@ ExternalVoltage extvolt(ADSPower, ADSChannel, dividerGain, evADSi2c_addr, Variable* extvoltV = new ExternalVoltage_Volt(&extvolt, "12345678-abcd-1234-ef00-1234567890ab"); /** End [ext_volt] */ +#endif +#if defined MS_BUILD_TEST_MPL115A2 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Freescale Semiconductor MPL115A2 Barometer // ========================================================================== @@ -1165,8 +1202,10 @@ Variable* mplPress = Variable* mplTemp = new MPL115A2_Temp(&mpl115a2, "12345678-abcd-1234-ef00-1234567890ab"); /** End [mpl115a2] */ +#endif +#if defined MS_BUILD_TEST_INSITURDO || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // InSitu RDO PRO-X Rugged Dissolved Oxygen Probe // ========================================================================== @@ -1178,7 +1217,7 @@ const int8_t RDOPower = sensorPowerPin; // Power pin (-1 if unconnected) const int8_t RDOData = 7; // The SDI12 data pin const uint8_t RDONumberReadings = 3; -// Create an RDO PRO-X dissolved oxygen sensor object +// Create an In-Situ RDO PRO-X dissolved oxygen sensor object InSituRDO insituRDO(*RDOSDI12address, RDOPower, RDOData, RDONumberReadings); // Create dissolved oxygen percent, dissolved oxygen concentration, temperature, @@ -1192,23 +1231,18 @@ Variable* rdoTemp = new InSituRDO_Temp(&insituRDO, Variable* rdoO2pp = new InSituRDO_Pressure(&insituRDO, "12345678-abcd-1234-ef00-1234567890ab"); /** End [insitu_rdo] */ +#endif +#if defined MS_BUILD_TEST_ACCULEVEL || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Keller Acculevel High Accuracy Submersible Level Transmitter // ========================================================================== /** Start [acculevel] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& acculevelSerial = Serial2; // Use hardware serial if possible -#else -// AltSoftSerial& acculevelSerial = altSoftSerial; // For AltSoftSerial -NeoSWSerial& acculevelSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte acculevelModbusAddress = 0x01; // The modbus address of KellerAcculevel const int8_t alAdapterPower = sensorPowerPin; // RS485 adapter power pin @@ -1219,8 +1253,8 @@ const uint8_t acculevelNumberReadings = 5; // The manufacturer recommends taking and averaging a few readings // Create a Keller Acculevel sensor object -KellerAcculevel acculevel(acculevelModbusAddress, acculevelSerial, - alAdapterPower, acculevelPower, al485EnablePin, +KellerAcculevel acculevel(acculevelModbusAddress, modbusSerial, alAdapterPower, + acculevelPower, al485EnablePin, acculevelNumberReadings); // Create pressure, temperature, and height variable pointers for the Acculevel @@ -1231,22 +1265,18 @@ Variable* acculevTemp = new KellerAcculevel_Temp( Variable* acculevHeight = new KellerAcculevel_Height( &acculevel, "12345678-abcd-1234-ef00-1234567890ab"); /** End [acculevel] */ +#endif + +#if defined MS_BUILD_TEST_NANOLEVEL || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Keller Nanolevel High Accuracy Submersible Level Transmitter // ========================================================================== /** Start [nanolevel] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& nanolevelSerial = Serial2; // Use hardware serial if possible -#else -// AltSoftSerial& nanolevelSerial = altSoftSerial; // For AltSoftSerial -NeoSWSerial& nanolevelSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte nanolevelModbusAddress = 0x01; // The modbus address of KellerNanolevel const int8_t nlAdapterPower = sensorPowerPin; // RS485 adapter power pin @@ -1257,8 +1287,8 @@ const uint8_t nanolevelNumberReadings = 5; // The manufacturer recommends taking and averaging a few readings // Create a Keller Nanolevel sensor object -KellerNanolevel nanolevel(nanolevelModbusAddress, nanolevelSerial, - nlAdapterPower, nanolevelPower, nl485EnablePin, +KellerNanolevel nanolevel(nanolevelModbusAddress, modbusSerial, nlAdapterPower, + nanolevelPower, nl485EnablePin, nanolevelNumberReadings); // Create pressure, temperature, and height variable pointers for the Nanolevel @@ -1269,26 +1299,21 @@ Variable* nanolevTemp = new KellerNanolevel_Temp( Variable* nanolevHeight = new KellerNanolevel_Height( &nanolevel, "12345678-abcd-1234-ef00-1234567890ab"); /** End [nanolevel] */ +#endif +#if defined MS_BUILD_TEST_MAXBOTIX || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Maxbotix HRXL Ultrasonic Range Finder // ========================================================================== /** Start [maxbotics] */ #include -// Create a reference to the serial port for the sonar // A Maxbotix sonar with the trigger pin disconnect CANNOT share the serial port // A Maxbotix sonar using the trigger may be able to share but YMMV -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& sonarSerial = Serial3; // Use hardware serial if possible -#else -// AltSoftSerial &sonarSerial = altSoftSerial; // For AltSoftSerial -NeoSWSerial& sonarSerial = neoSSerial1; // For software serial -// SoftwareSerial_ExtInts& sonarSerial = softSerial1; // For software serial -#endif + +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section const int8_t SonarPower = sensorPowerPin; // Excite (power) pin (-1 if unconnected) @@ -1304,8 +1329,10 @@ MaxBotixSonar sonar1(sonarSerial, SonarPower, Sonar1Trigger, Variable* sonar1Range = new MaxBotixSonar_Range(&sonar1, "12345678-abcd-1234-ef00-1234567890ab"); /** End [maxbotics] */ +#endif +#if defined MS_BUILD_TEST_DS18 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Maxim DS18 One Wire Temperature Sensor // ========================================================================== @@ -1331,8 +1358,10 @@ MaximDS18 ds18(OneWireAddress1, OneWirePower, OneWireBus, ds18NumberReadings); Variable* ds18Temp = new MaximDS18_Temp(&ds18, "12345678-abcd-1234-ef00-1234567890ab"); /** End [ds18] */ +#endif +#if defined MS_BUILD_TEST_MS5803 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Measurement Specialties MS5803-14BA pressure sensor // ========================================================================== @@ -1356,8 +1385,10 @@ Variable* ms5803Press = Variable* ms5803Temp = new MeaSpecMS5803_Temp(&ms5803, "12345678-abcd-1234-ef00-1234567890ab"); /** End [ms5803] */ +#endif +#if defined MS_BUILD_TEST_5TM || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Meter ECH2O Soil Moisture Sensor // ========================================================================== @@ -1380,8 +1411,10 @@ Variable* fivetmVWC = Variable* fivetmTemp = new Decagon5TM_Temp(&fivetm, "12345678-abcd-1234-ef00-1234567890ab"); /** End [fivetm] */ +#endif +#if defined MS_BUILD_TEST_CTD || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Meter Hydros 21 Conductivity, Temperature, and Depth Sensor // ========================================================================== @@ -1404,8 +1437,10 @@ Variable* ctdTemp = new DecagonCTD_Temp(&ctd, Variable* ctdDepth = new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-ef00-1234567890ab"); /** End [hydros21] */ +#endif +#if defined MS_BUILD_TEST_TEROS11 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Meter Teros 11 Soil Moisture Sensor // ========================================================================== @@ -1430,8 +1465,10 @@ Variable* teros11Temp = Variable* teros11VWC = new MeterTeros11_VWC(&teros11, "12345678-abcd-1234-ef00-1234567890ab"); /** End [teros] */ +#endif +#if defined MS_BUILD_TEST_PALEOTERRA || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // PaleoTerra Redox Sensors // ========================================================================== @@ -1448,15 +1485,17 @@ PaleoTerraRedox ptRedox(&softI2C, paleoTerraPower, paleoI2CAddress); // PaleoTerraRedox ptRedox(paleoTerraPower, softwareSDA, softwareSCL, // paleoI2CAddress); #else -PaleoTerraRedox ptRedox(paleoTerraPower, paleoI2CAddress); +PaleoTerraRedox ptRedox(paleoTerraPower, paleoI2CAddress); #endif // Create the voltage variable for the redox sensor Variable* ptVolt = new PaleoTerraRedox_Volt(&ptRedox, "12345678-abcd-1234-ef00-1234567890ab"); /** End [pt_redox] */ +#endif +#if defined MS_BUILD_TEST_RAINI2C || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // External I2C Rain Tipping Bucket Counter // ========================================================================== @@ -1473,7 +1512,7 @@ RainCounterI2C tbi2c(&softI2C, RainCounterI2CAddress, depthPerTipEvent); // RainCounterI2C tbi2c(softwareSDA, softwareSCL, RainCounterI2CAddress, // depthPerTipEvent); #else -RainCounterI2C tbi2c(RainCounterI2CAddress, depthPerTipEvent); +RainCounterI2C tbi2c(RainCounterI2CAddress, depthPerTipEvent); #endif // Create number of tips and rain depth variable pointers for the tipping bucket @@ -1482,8 +1521,10 @@ Variable* tbi2cTips = Variable* tbi2cDepth = new RainCounterI2C_Depth(&tbi2c, "12345678-abcd-1234-ef00-1234567890ab"); /** End [i2c_rain] */ +#endif +#if defined MS_BUILD_TEST_TALLY || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Tally I2C Event Counter for rain or wind reed-switch sensors // ========================================================================== @@ -1513,8 +1554,10 @@ Variable* tallyEvents = new TallyCounterI2C_Events( // 2.5 mph/Hz & 1.60934 kmph/mph and 2.5 mph/Hz conversion factor from // web: Inspeed-Version-II-Reed-Switch-Anemometer-Sensor-Only-WS2R /** End [i2c_wind_tally] */ +#endif +#if defined MS_BUILD_TEST_INA219 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // TI INA219 High Side Current/Voltage Sensor (Current mA, Voltage, Power) // ========================================================================== @@ -1538,8 +1581,10 @@ Variable* inaVolt = new TIINA219_Volt(&ina219, Variable* inaPower = new TIINA219_Power(&ina219, "12345678-abcd-1234-ef00-1234567890ab"); /** End [ina219] */ +#endif +#if defined MS_BUILD_TEST_CYCLOPS || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Turner Cyclops-7F Submersible Fluorometer // ========================================================================== @@ -1597,8 +1642,10 @@ Variable* cyclopsTryptophan = new TurnerCyclops_Tryptophan( Variable* cyclopsRedChloro = new TurnerCyclops_RedChlorophyll( &cyclops, "12345678-abcd-1234-ef00-1234567890ab"); /** End [cyclops] */ +#endif +#if defined MS_BUILD_TEST_ANALOGEC || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Analog Electrical Conductivity using the Processor's Analog Pins // ========================================================================== @@ -1657,23 +1704,18 @@ Variable* analogEc_spcond = new Variable( calculateAnalogSpCond, analogSpCondResolution, analogSpCondName, analogSpCondUnit, analogSpCondCode, analogSpCondUUID); /** End [analog_cond] */ +#endif +#if defined MS_BUILD_TEST_Y504 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y504 Dissolved Oxygen Sensor // ========================================================================== /** Start [y504] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y504modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y504modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y504modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y504ModbusAddress = 0x04; // The modbus address of the Y504 const int8_t y504AdapterPower = @@ -1685,7 +1727,7 @@ const uint8_t y504NumberReadings = 5; // power consumption // Create a Yosemitech Y504 dissolved oxygen sensor object -YosemitechY504 y504(y504ModbusAddress, y504modbusSerial, y504AdapterPower, +YosemitechY504 y504(y504ModbusAddress, modbusSerial, y504AdapterPower, y504SensorPower, y504EnablePin, y504NumberReadings); // Create the dissolved oxygen percent, dissolved oxygen concentration, and @@ -1697,23 +1739,18 @@ Variable* y504DOmgL = Variable* y504Temp = new YosemitechY504_Temp(&y504, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y504] */ +#endif +#if defined MS_BUILD_TEST_Y510 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y510 Turbidity Sensor // ========================================================================== /** Start [y510] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y510modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y510modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y510modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y510ModbusAddress = 0x0B; // The modbus address of the Y510 const int8_t y510AdapterPower = @@ -1725,7 +1762,7 @@ const uint8_t y510NumberReadings = 5; // power consumption // Create a Y510-B Turbidity sensor object -YosemitechY510 y510(y510ModbusAddress, y510modbusSerial, y510AdapterPower, +YosemitechY510 y510(y510ModbusAddress, modbusSerial, y510AdapterPower, y510SensorPower, y510EnablePin, y510NumberReadings); // Create turbidity and temperature variable pointers for the Y510 @@ -1734,23 +1771,18 @@ Variable* y510Turb = Variable* y510Temp = new YosemitechY510_Temp(&y510, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y510] */ +#endif +#if defined MS_BUILD_TEST_Y511 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y511 Turbidity Sensor with Wiper // ========================================================================== /** Start [y511] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y511modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y511modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y511modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y511ModbusAddress = 0x1A; // The modbus address of the Y511 const int8_t y511AdapterPower = @@ -1762,7 +1794,7 @@ const uint8_t y511NumberReadings = 5; // power consumption // Create a Y511-A Turbidity sensor object -YosemitechY511 y511(y511ModbusAddress, y511modbusSerial, y511AdapterPower, +YosemitechY511 y511(y511ModbusAddress, modbusSerial, y511AdapterPower, y511SensorPower, y511EnablePin, y511NumberReadings); // Create turbidity and temperature variable pointers for the Y511 @@ -1771,23 +1803,18 @@ Variable* y511Turb = Variable* y511Temp = new YosemitechY511_Temp(&y511, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y511] */ +#endif +#if defined MS_BUILD_TEST_Y514 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y514 Chlorophyll Sensor // ========================================================================== /** Start [y514] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y514modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y514modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y514modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y514ModbusAddress = 0x14; // The modbus address of the Y514 const int8_t y514AdapterPower = @@ -1799,7 +1826,7 @@ const uint8_t y514NumberReadings = 5; // power consumption // Create a Y514 chlorophyll sensor object -YosemitechY514 y514(y514ModbusAddress, y514modbusSerial, y514AdapterPower, +YosemitechY514 y514(y514ModbusAddress, modbusSerial, y514AdapterPower, y514SensorPower, y514EnablePin, y514NumberReadings); // Create chlorophyll concentration and temperature variable pointers for the @@ -1809,23 +1836,18 @@ Variable* y514Chloro = new YosemitechY514_Chlorophyll( Variable* y514Temp = new YosemitechY514_Temp(&y514, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y514] */ +#endif +#if defined MS_BUILD_TEST_Y520 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y520 Conductivity Sensor // ========================================================================== /** Start [y520] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y520modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y520modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y520modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y520ModbusAddress = 0x20; // The modbus address of the Y520 const int8_t y520AdapterPower = @@ -1837,7 +1859,7 @@ const uint8_t y520NumberReadings = 5; // power consumption // Create a Y520 conductivity sensor object -YosemitechY520 y520(y520ModbusAddress, y520modbusSerial, y520AdapterPower, +YosemitechY520 y520(y520ModbusAddress, modbusSerial, y520AdapterPower, y520SensorPower, y520EnablePin, y520NumberReadings); // Create specific conductance and temperature variable pointers for the Y520 @@ -1846,23 +1868,18 @@ Variable* y520Cond = Variable* y520Temp = new YosemitechY520_Temp(&y520, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y520] */ +#endif +#if defined MS_BUILD_TEST_Y532 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y532 pH // ========================================================================== /** Start [y532] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y532modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y532modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y532modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y532ModbusAddress = 0x32; // The modbus address of the Y532 const int8_t y532AdapterPower = sensorPowerPin; // RS485 adapter power pin @@ -1873,7 +1890,7 @@ const uint8_t y532NumberReadings = 1; // The manufacturer actually doesn't mention averaging for this one // Create a Yosemitech Y532 pH sensor object -YosemitechY532 y532(y532ModbusAddress, y532modbusSerial, y532AdapterPower, +YosemitechY532 y532(y532ModbusAddress, modbusSerial, y532AdapterPower, y532SensorPower, y532EnablePin, y532NumberReadings); // Create pH, electrical potential, and temperature variable pointers for the @@ -1885,23 +1902,18 @@ Variable* y532pH = Variable* y532Temp = new YosemitechY532_Temp(&y532, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y532] */ +#endif +#if defined MS_BUILD_TEST_Y533 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y533 Oxidation Reduction Potential (ORP) // ========================================================================== /** Start [y533] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y533modbusSerial = Serial2; // Use hardware serial if possible -#else -// AltSoftSerial& y533modbusSerial = altSoftSerial; // For AltSoftSerial -NeoSWSerial& y533modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y533ModbusAddress = 0x32; // The modbus address of the Y533 const int8_t y533AdapterPower = sensorPowerPin; // RS485 adapter power pin @@ -1912,7 +1924,7 @@ const uint8_t y533NumberReadings = 1; // The manufacturer actually doesn't mention averaging for this one // Create a Yosemitech Y533 pH sensor object -YosemitechY533 y533(y533ModbusAddress, y533modbusSerial, y533AdapterPower, +YosemitechY533 y533(y533ModbusAddress, modbusSerial, y533AdapterPower, y533SensorPower, y533EnablePin, y533NumberReadings); // Create pH, electrical potential, and temperature variable pointers for the @@ -1924,23 +1936,18 @@ Variable* y533pH = Variable* y533Temp = new YosemitechY533_Temp(&y533, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y533] */ +#endif +#if defined MS_BUILD_TEST_Y550 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y550 COD Sensor with Wiper // ========================================================================== /** Start [y550] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y550modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y550modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y550modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y550ModbusAddress = 0x50; // The modbus address of the Y550 const int8_t y550AdapterPower = @@ -1952,7 +1959,7 @@ const uint8_t y550NumberReadings = 5; // power consumption // Create a Y550 conductivity sensor object -YosemitechY550 y550(y550ModbusAddress, y550modbusSerial, y550AdapterPower, +YosemitechY550 y550(y550ModbusAddress, modbusSerial, y550AdapterPower, y550SensorPower, y550EnablePin, y550NumberReadings); // Create COD, turbidity, and temperature variable pointers for the Y550 @@ -1963,8 +1970,10 @@ Variable* y550Turbid = Variable* y550Temp = new YosemitechY550_Temp(&y550, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y550] */ +#endif +#if defined MS_BUILD_TEST_Y4000 || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Yosemitech Y4000 Multiparameter Sonde (DOmgL, Turbidity, Cond, pH, Temp, // ORP, Chlorophyll, BGA) @@ -1972,15 +1981,8 @@ Variable* y550Temp = /** Start [y4000] */ #include -// Create a reference to the serial port for modbus -// Extra hardware and software serial ports are created in the "Settings for -// Additional Serial Ports" section -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 -HardwareSerial& y4000modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& y4000modbusSerial = altSoftSerial; // For AltSoftSerial -// NeoSWSerial& y4000modbusSerial = neoSSerial1; // For software serial -#endif +// NOTE: Extra hardware and software serial ports are created in the "Settings +// for Additional Serial Ports" section byte y4000ModbusAddress = 0x05; // The modbus address of the Y4000 const int8_t y4000AdapterPower = @@ -1992,7 +1994,7 @@ const uint8_t y4000NumberReadings = 5; // power consumption // Create a Yosemitech Y4000 multi-parameter sensor object -YosemitechY4000 y4000(y4000ModbusAddress, y4000modbusSerial, y4000AdapterPower, +YosemitechY4000 y4000(y4000ModbusAddress, modbusSerial, y4000AdapterPower, y4000SensorPower, y4000EnablePin, y4000NumberReadings); // Create all of the variable pointers for the Y4000 @@ -2013,16 +2015,17 @@ Variable* y4000Chloro = new YosemitechY4000_Chlorophyll( Variable* y4000BGA = new YosemitechY4000_BGA(&y4000, "12345678-abcd-1234-ef00-1234567890ab"); /** End [y4000] */ +#endif +#if defined MS_BUILD_TEST_DOPTO || defined MS_BUILD_TEST_ALL_SENSORS // ========================================================================== // Zebra Tech D-Opto Dissolved Oxygen Sensor // ========================================================================== /** Start [dopto] */ #include -const char* DOptoSDI12address = - "5"; // The SDI-12 Address of the Zebra Tech D-Opto +const char* DOptoSDI12address = "5"; // The SDI-12 Address of the D-Opto const int8_t ZTPower = sensorPowerPin; // Power pin (-1 if unconnected) const int8_t ZTData = 7; // The SDI12 data pin @@ -2038,6 +2041,7 @@ Variable* dOptoDOmgL = Variable* dOptoTemp = new ZebraTechDOpto_Temp(&dopto, "12345678-abcd-1234-ef00-1234567890ab"); /** End [dopto] */ +#endif // ========================================================================== @@ -2073,13 +2077,14 @@ const char* calculatedVarCode = "calcVar"; // The (optional) universallly unique identifier const char* calculatedVarUUID = "12345678-abcd-1234-ef00-1234567890ab"; -// Finally, Create a calculated variable and return a pointer to it +// Finally, Create a calculated variable and return a variable pointer to it Variable* calculatedVar = new Variable( calculateVariableValue, calculatedVarResolution, calculatedVarName, calculatedVarUnit, calculatedVarCode, calculatedVarUUID); /** End [calculated_variables] */ +#if defined MS_BUILD_TEST_CREATE_IN_ARRAY // ========================================================================== // Creating the Variable Array[s] and Filling with Variable Objects // NOTE: This shows three differnt ways of creating the same variable array @@ -2109,6 +2114,7 @@ int variableCount = sizeof(variableList) / sizeof(variableList[0]); // Create the VariableArray object VariableArray varArray(variableCount, variableList); /** End [variables_create_in_array] */ +#endif // ========================================================================== @@ -2146,10 +2152,210 @@ VariableArray varArray(variableCount, variableList, UUIDs); #if defined MS_BUILD_TEST_PRE_NAMED_VARS /** Start [variables_pre_named] */ // Version 3: Fill array with already created and named variable pointers -Variable* variableList[] = {mcuBoardBatt, mcuBoardAvailableRAM, mcuBoardSampNo, - modemRSSI, modemSignalPct, - // ... Add all of your variables! - calculatedVar} +Variable* variableList[] = { + mcuBoardSampNo, +#if defined MS_BUILD_TEST_AM2315 || defined MS_BUILD_TEST_ALL_SENSORS + am2315Humid, + am2315Temp, +#endif +#if defined MS_BUILD_TEST_DHT || defined MS_BUILD_TEST_ALL_SENSORS + dhtHumid, + dhtTemp, + dhtHI, +#endif +#if defined MS_BUILD_TEST_SQ212 || defined MS_BUILD_TEST_ALL_SENSORS + sq212PAR, + sq212voltage +#endif +#if defined MS_BUILD_TEST_ATLASCO2 || defined MS_BUILD_TEST_ALL_SENSORS + atlasCO2CO2, + atlasCO2Temp, +#endif +#if defined MS_BUILD_TEST_ATLASDO || defined MS_BUILD_TEST_ALL_SENSORS + atlasDOconc, + atlasDOpct, +#endif +#if defined MS_BUILD_TEST_ATLASORP || defined MS_BUILD_TEST_ALL_SENSORS + atlasORPot, +#endif +#if defined MS_BUILD_TEST_ATLASPH || defined MS_BUILD_TEST_ALL_SENSORS + atlaspHpH, +#endif +#if defined MS_BUILD_TEST_ATLASRTD || defined MS_BUILD_TEST_ALL_SENSORS + atlasTemp, +#endif +#if defined MS_BUILD_TEST_ATLASEC || defined MS_BUILD_TEST_ALL_SENSORS + atlasCond, + atlasTDS, + atlasSal, + atlasGrav, + atlasSpCond, +#endif +#if defined MS_BUILD_TEST_BME280 || defined MS_BUILD_TEST_ALL_SENSORS + bme280Temp, + bme280Humid, + bme280Press, + bme280Alt, +#endif +#if defined MS_BUILD_TEST_OBS3 || defined MS_BUILD_TEST_ALL_SENSORS + obs3TurbLow, + obs3VoltLow, + obs3TurbHigh, + obs3VoltHigh, +#endif +#if defined MS_BUILD_TEST_ES2 || defined MS_BUILD_TEST_ALL_SENSORS + es2Cond, + es2Temp, +#endif +#if defined MS_BUILD_TEST_VOLTAGE || defined MS_BUILD_TEST_ALL_SENSORS + extvoltV, +#endif +#if defined MS_BUILD_TEST_MPL115A2 || defined MS_BUILD_TEST_ALL_SENSORS + mplTemp, + mplPress, +#endif +#if defined MS_BUILD_TEST_INSITURDO || defined MS_BUILD_TEST_ALL_SENSORS + rdoTemp, + rdoDOpct, + rdoDOmgL, + rdoO2pp, +#endif +#if defined MS_BUILD_TEST_ACCULEVEL || defined MS_BUILD_TEST_ALL_SENSORS + acculevPress, + acculevTemp, + acculevHeight, +#endif +#if defined MS_BUILD_TEST_NANOLEVEL || defined MS_BUILD_TEST_ALL_SENSORS + nanolevPress, + nanolevTemp, + nanolevHeight, +#endif +#if defined MS_BUILD_TEST_MAXBOTIX || defined MS_BUILD_TEST_ALL_SENSORS + sonar1Range, +#endif +#if defined MS_BUILD_TEST_DS18 || defined MS_BUILD_TEST_ALL_SENSORS + ds18Temp, +#endif +#if defined MS_BUILD_TEST_MS5803 || defined MS_BUILD_TEST_ALL_SENSORS + ms5803Temp, + ms5803Press, +#endif +#if defined MS_BUILD_TEST_5TM || defined MS_BUILD_TEST_ALL_SENSORS + fivetmEa, + fivetmVWC, + fivetmTemp, +#endif +#if defined MS_BUILD_TEST_CTD || defined MS_BUILD_TEST_ALL_SENSORS + ctdCond, + ctdTemp, + ctdDepth, +#endif +#if defined MS_BUILD_TEST_TEROS11 || defined MS_BUILD_TEST_ALL_SENSORS + teros11Ea, + teros11Temp, + teros11VWC, +#endif +#if defined MS_BUILD_TEST_PALEOTERRA || defined MS_BUILD_TEST_ALL_SENSORS + ptVolt, +#endif +#if defined MS_BUILD_TEST_RAINI2C || defined MS_BUILD_TEST_ALL_SENSORS + tbi2cTips, + tbi2cDepth, +#endif +#if defined MS_BUILD_TEST_TALLY || defined MS_BUILD_TEST_ALL_SENSORS + tallyEvents, +#endif +#if defined MS_BUILD_TEST_INA219 || defined MS_BUILD_TEST_ALL_SENSORS + inaVolt, + inaCurrent, + inaPower, +#endif +#if defined MS_BUILD_TEST_CYCLOPS || defined MS_BUILD_TEST_ALL_SENSORS + cyclopsVoltage, + cyclopsChloro, + cyclopsRWT, + cyclopsFluoroscein, + cyclopsPhycocyanin, + cyclopsPhycoerythrin, + cyclopsCDOM, + cyclopsCrudeOil, + cyclopsBrighteners, + cyclopsTurbidity, + cyclopsPTSA, + cyclopsBTEX, + cyclopsTryptophan, + cyclopsRedChloro, +#endif +#if defined MS_BUILD_TEST_ANALOGEC || defined MS_BUILD_TEST_ALL_SENSORS + analogEc_cond, + analogEc_spcond, +#endif +#if defined MS_BUILD_TEST_Y504 || defined MS_BUILD_TEST_ALL_SENSORS + y504DOpct, + y504DOmgL, + y504Temp, +#endif +#if defined MS_BUILD_TEST_Y510 || defined MS_BUILD_TEST_ALL_SENSORS + y510Turb, + y510Temp, +#endif +#if defined MS_BUILD_TEST_Y511 || defined MS_BUILD_TEST_ALL_SENSORS + y511Turb, + y511Temp, +#endif +#if defined MS_BUILD_TEST_Y514 || defined MS_BUILD_TEST_ALL_SENSORS + y514Chloro, + y514Temp, +#endif +#if defined MS_BUILD_TEST_Y520 || defined MS_BUILD_TEST_ALL_SENSORS + y520Cond, + y520Temp, +#endif +#if defined MS_BUILD_TEST_Y532 || defined MS_BUILD_TEST_ALL_SENSORS + y532Voltage, + y532pH, + y532Temp, +#endif +#if defined MS_BUILD_TEST_Y533 || defined MS_BUILD_TEST_ALL_SENSORS + y533Voltage, + y533pH, + y533Temp, +#endif +#if defined MS_BUILD_TEST_Y550 || defined MS_BUILD_TEST_ALL_SENSORS + y550COD, + y550Turbid, + y550Temp, +#endif +#if defined MS_BUILD_TEST_Y4000 || defined MS_BUILD_TEST_ALL_SENSORS + y4000DO, + y4000Turb, + y4000Cond, + y4000pH, + y4000Temp, + y4000ORP, + y4000Chloro, + y4000BGA, +#endif +#if defined MS_BUILD_TEST_DOPTO || defined MS_BUILD_TEST_ALL_SENSORS + dOptoDOpct, + dOptoDOmgL, + dOptoTemp, +#endif + mcuBoardAvailableRAM, + mcuBoardBatt, + ds3231Temp, + modemRSSI, + modemSignalPct, + calculatedVar, +#ifdef TINY_GSM_MODEM_HAS_BATTERY + modemBatteryState, + modemBatteryPct, + modemBatteryVoltage, +#endif +#ifdef TINY_GSM_MODEM_HAS_TEMPERATURE + modemTemperature, +#endif +}; // Count up the number of pointers in the array int variableCount = sizeof(variableList) / sizeof(variableList[0]); // Create the VariableArray object @@ -2167,6 +2373,7 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); /** End [loggers] */ +#if defined MS_BUILD_TEST_MMW // ========================================================================== // A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal // ========================================================================== @@ -2183,8 +2390,10 @@ const char* samplingFeature = EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); /** End [monitormw] */ +#endif +#if defined MS_BUILD_TEST_DREAMHOST // ========================================================================== // A Publisher to DreamHost // ========================================================================== @@ -2199,13 +2408,15 @@ const char* DreamHostPortalRX = "xxxx"; DreamHostPublisher DreamHostGET(dataLogger, &modem.gsmClient, DreamHostPortalRX); /** End [dreamhost] */ +#endif +#if defined MS_BUILD_TEST_THINGSPEAK // ========================================================================== // ThingSpeak Data Publisher // ========================================================================== /** Start [thingspeak] */ -// Create a channel with fields on ThingSpeak in advance +// Create a channel with fields on ThingSpeak in advance. // The fields will be sent in exactly the order they are in the variable array. // Any custom name or identifier given to the field on ThingSpeak is irrelevant. // No more than 8 fields of data can go to any one channel. Any fields beyond @@ -2222,6 +2433,7 @@ const char* thingSpeakChannelKey = ThingSpeakPublisher TsMqtt(dataLogger, &modem.gsmClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); /** End [thingspeak] */ +#endif // ========================================================================== @@ -2296,19 +2508,15 @@ void setup() { // Start the serial connection with the modem modemSerial.begin(modemBaud); -// Start the stream for the modbus sensors; -// all currently supported modbus sensors use 9600 baud -#if defined ARDUINO_ARCH_SAMD || defined ATMEGA2560 - Serial2.begin(9600); // Use hardware serial if possible -#else - altSoftSerial.begin(9600); // For all modbus serial streams or other serial - - // neoSSerial1.begin(9600); // For software serial -#endif + // Start the stream for the modbus sensors; + // all currently supported modbus sensors use 9600 baud + modbusSerial.begin(9600); +#if defined MS_BUILD_TEST_MAXBOTIX || defined MS_BUILD_TEST_ALL_SENSORS // Start the SoftwareSerial stream for the sonar; it will always be at 9600 // baud sonarSerial.begin(9600); +#endif /** End [setup_serial_begins] */ // Assign pins SERCOM functionality for SAMD boards @@ -2375,12 +2583,12 @@ void setup() { /** End [setup_esp] */ #endif -#if defined MS_BUILD_TESTING && defined MS_BUILD_TEST_SKYWIRE +#if defined MS_BUILD_TEST_SKYWIRE /** Start [setup_skywire] */ modem.setModemStatusLevel(LOW); // If using CTS, LOW modem.setModemWakeLevel(HIGH); // Skywire dev board inverts the signal modem.setModemResetLevel(HIGH); // Skywire dev board inverts the signal - /** End [setup_skywire] */ + /** End [setup_skywire] */ #endif #if defined MS_BUILD_TEST_XBEE_CELLULAR