ModSensorConfig.h file

This file is used to configure the clock and other library settings/preferences for the Modular Sensors Library.

For the Arduino IDE, this is the only way to configure these settings. If you are using PlatformIO, you have the option of using this file or changing your configuration using build flags in your platformio.ini. Compile times will be shorter if you use this file instead of build flags, but it is much easier to track changes in your platformio.ini file than in this file.

Defines

#define MS_LOGGERBASE_BUTTON_BENCH_TEST = false
Enable bench testing mode for the testing button.
#define SDCARD_SPI = SPI
The SPI port to use for the SD card.
#define MS_LOGGER_EPOCH
The epoch start to use for the logger.
#define EARLIEST_SANE_UNIX_TIMESTAMP = 1735689600
The earliest unix timestamp that can be considered sane.
#define LATEST_SANE_UNIX_TIMESTAMP = 2051222400
The latest unix timestamp that can be considered sane.
#define MAX_NUMBER_VARS = 21
The largest number of variables from a single sensor.
#define MS_PROCESSOR_ADC_RESOLUTION = 10
Select or adjust the processor analog resolution.
#define PROCESSOR_ADC_MAX = ((1 <<
The maximum possible value of the ADC - one less than the resolution shifted up one bit.
#define PROCESSOR_ADC_RANGE = (1 <<
The maximum possible range of the ADC - the resolution shifted up one bit.
#define MS_PROCESSOR_ADC_REFERENCE_MODE = DEFAULT
The voltage reference mode for the processor's ADC.
#define MS_PROCESSOR_ADC_REFERENCE_MODE = AR_DEFAULT
The voltage reference mode for the processor's ADC.
#define MAX_NUMBER_SENDERS = 4
The largest number of publishers that can be attached to a logger.
#define MS_ALWAYS_FLUSH_PUBLISHERS = false
Set this to true to always force publishers to attempt to transmit data. If false, publishers will only transmit data at the sendEveryX interval or when the buffer fills.
#define MS_SEND_BUFFER_SIZE = 1360
Send Buffer.
#define MS_MQTT_MAX_PACKET_SIZE = 1536
Configure the size of the PubSubClient buffer for MQTT publishers.
#define MS_AWS_IOT_PUBLISHER_SUB_COUNT = 4
The maximum number of extra subscriptions that can be added to the AWS IoT Core publisher.
#define MS_AWS_IOT_PUBLISHER_PUB_COUNT = 4
The maximum number of extra publish messages that can be added to the AWS IoT Core publisher.
#define MS_AWS_IOT_MAX_CONNECTION_TIME = 30000L
The maximum time to wait for subscriptions after publishing data to AWS IoT Core.
#define S3_DEFAULT_FILE_EXTENSION = ".jpg"
The default file extension to use to send to S3: ".jpg".

Define documentation

#define MS_LOGGERBASE_BUTTON_BENCH_TEST = false

Enable bench testing mode for the testing button.

When enabled, the testing button uses the benchTestingMode() function to repeatedly read and print out sensor data. When disabled (default), the testing button causes a reading to be taken and transmitted immediately using the normal procedure.


#define SDCARD_SPI = SPI

The SPI port to use for the SD card.

This is typically defined in the board variant file.


#define EARLIEST_SANE_UNIX_TIMESTAMP = 1735689600

The earliest unix timestamp that can be considered sane.

January 1, 2025


#define LATEST_SANE_UNIX_TIMESTAMP = 2051222400

The latest unix timestamp that can be considered sane.

January 1, 2035


#define MAX_NUMBER_VARS = 21

The largest number of variables from a single sensor.

Every sensor will create a buffer of this length for holding variable values. Decrease this value to save a memory.


#define MS_PROCESSOR_ADC_RESOLUTION = 10

Select or adjust the processor analog resolution.

This is the resolution of the built-in processor ADC and it cannot be set higher than what your processor actually supports. This does not apply to the TI ADS1115 or ADS1015 external ADS.

The default for AVR boards is 10 and for other boards is 12.

Future note: The ESP32 has a 12 bit ADC and the ESP8266 has a 10 bit ADC.


#define MS_PROCESSOR_ADC_REFERENCE_MODE = DEFAULT

The voltage reference mode for the processor's ADC.

For an AVR board, this must be one of:

  • DEFAULT: the default built-in analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the Arduino Mega)
  • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
  • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
  • EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.

If not set on an AVR board DEFAULT is used.

For the best accuracy, use an EXTERNAL reference with the AREF pin connected to the power supply for the EC sensor.

For a SAMD board, this must be one of:

  • AR_DEFAULT: the default built-in analog reference of 3.3V
  • AR_INTERNAL: a built-in 2.23V reference
  • AR_INTERNAL1V0: a built-in 1.0V reference
  • AR_INTERNAL1V65: a built-in 1.65V reference
  • AR_INTERNAL2V23: a built-in 2.23V reference
  • AR_EXTERNAL: the voltage applied to the AREF pin is used as the reference

If not set on an SAMD board AR_DEFAULT is used.

For the best accuracy, use an AR_EXTERNAL reference with the AREF pin connected to the power supply for the EC sensor. On most Adafruit SAMD51 boards, there is an optional solder jumper to connect the AREF pin to the 3.3V supply. I suggest you close the jumper! On an EnviroDIY Stonefly, there is also a solder jumper, but on the Stonefly the jumper is closed by default.


#define MS_PROCESSOR_ADC_REFERENCE_MODE = AR_DEFAULT

The voltage reference mode for the processor's ADC.

For an AVR board, this must be one of:

  • DEFAULT: the default built-in analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the Arduino Mega)
  • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
  • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
  • EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.

If not set on an AVR board DEFAULT is used.

For the best accuracy, use an EXTERNAL reference with the AREF pin connected to the power supply for the EC sensor.

For a SAMD board, this must be one of:

  • AR_DEFAULT: the default built-in analog reference of 3.3V
  • AR_INTERNAL: a built-in 2.23V reference
  • AR_INTERNAL1V0: a built-in 1.0V reference
  • AR_INTERNAL1V65: a built-in 1.65V reference
  • AR_INTERNAL2V23: a built-in 2.23V reference
  • AR_EXTERNAL: the voltage applied to the AREF pin is used as the reference

If not set on an SAMD board AR_DEFAULT is used.

For the best accuracy, use an AR_EXTERNAL reference with the AREF pin connected to the power supply for the EC sensor. On most Adafruit SAMD51 boards, there is an optional solder jumper to connect the AREF pin to the 3.3V supply. I suggest you close the jumper! On an EnviroDIY Stonefly, there is also a solder jumper, but on the Stonefly the jumper is closed by default.


#define MS_SEND_BUFFER_SIZE = 1360

Send Buffer.

This determines how many characters to set out at once over the TCP connection. Increasing this may decrease data use by a logger, while decreasing it will save memory. Do not make it smaller than 32 or bigger than TINY_GSM_SEND_MAX_SIZE for you module if using TinyGSM or 1500 (a typical TCP Maximum Transmission Unit) if you aren't using TinyGSM.

When using the ThingSpeak publisher, make sure this is at least 240 bytes.

This can be changed by setting the build flag MS_SEND_BUFFER_SIZE when compiling.


#define MS_MQTT_MAX_PACKET_SIZE = 1536

Configure the size of the PubSubClient buffer for MQTT publishers.

This is the maximum size of any single MQTT message - incoming or outgoing. The same value applies to all MQTT publishers. The default within PubSubClient is 256 bytes, but to receive long S3 URLs from AWS IoT Core, we need to jack this way up. Incoming pre-signed S3 URLs are >1200 bytes. If you're not using both AWS IoT Core and S3, you should drop this down. When using the ThingSpeak publisher, ~240 bytes should suffice. If you're not using any MQTT publishers, you can ignore this or set it to 256.


#define MS_AWS_IOT_PUBLISHER_SUB_COUNT = 4

The maximum number of extra subscriptions that can be added to the AWS IoT Core publisher.


#define MS_AWS_IOT_MAX_CONNECTION_TIME = 30000L

The maximum time to wait for subscriptions after publishing data to AWS IoT Core.


#define S3_DEFAULT_FILE_EXTENSION = ".jpg"

The default file extension to use to send to S3: ".jpg".

This assumes you are using S3 to send images. If you want to put your basic numeric data into S3, you should use the IoT publisher and create a rule and corresponding lambda function to transfer the json data from IoT Core to S3.