Forum Replies Created
-
AuthorPosts
-
I have both a pH and a DO sensor working on one of my data loggers., and I’ve had up to four Atlas Scientific sensors working at once using a sensor bridge: https://atlas-scientific.com/carrier-boards/sensor-bridge/ I currently have the sensors connected through the qwiic ports, and they seem to be working fine. Here’s my code, there’s a lot of extraneous stuff that I haven’t had a chance to clean up yet, and it’s sending data to thingspeak instead of MonitorMyWatershed:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502/** =========================================================================* @file DRWI_LTE.ino* @brief Example for DRWI CitSci LTE sites.** This example shows proper settings for the following configuration:** Mayfly v1.1 board* EnviroDIY sim7080 LTE module (with Hologram SIM card)* Hydros21 CTD sensor* Campbell Scientific OBS3+ Turbidity sensor** @author Sara Geleskie Damiano <sdamiano@stroudcenter.org>* @copyright (c) 2017-2020 Stroud Water Research Center (SWRC)* and the EnviroDIY Development Team* This example is published under the BSD-3 license.** Build Environment: Visual Studios Code with PlatformIO* Hardware Platform: EnviroDIY Mayfly Arduino Datalogger** DISCLAIMER:* THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN.* ======================================================================= */// ==========================================================================// Defines for the Arduino IDE// NOTE: These are ONLY needed to compile with the Arduino IDE.// If you use PlatformIO, you should set these build flags in your// platformio.ini// ==========================================================================/** Start [defines] */#ifndef TINY_GSM_RX_BUFFER#define TINY_GSM_RX_BUFFER 64#endif#ifndef TINY_GSM_YIELD_MS#define TINY_GSM_YIELD_MS 2#endif#ifndef MQTT_MAX_PACKET_SIZE#define MQTT_MAX_PACKET_SIZE 256#endif/** End [defines] */// ==========================================================================// Include the libraries required for any data logger// ==========================================================================/** Start [includes] */// The Arduino library is needed for every Arduino program.#include <Arduino.h>// EnableInterrupt is used by ModularSensors for external and pin change// interrupts and must be explicitly included in the main program.#include <EnableInterrupt.h>// To get all of the base classes for ModularSensors, include LoggerBase.// NOTE: Individual sensor definitions must be included separately.#include <LoggerBase.h>// Include the main header for ModularSensors#include <ModularSensors.h>/** End [includes] */// ==========================================================================// Data Logging Options// ==========================================================================/** Start [logging_options] */// The name of this program fileconst char* sketchName = "BWC_ALL_VAR_TS.ino";// Logger ID, also becomes the prefix for the name of the data file on SD cardconst char* LoggerID = "BWC";// How frequently (in minutes) to log dataconst uint8_t loggingInterval = 15;// Your logger's timezone.const int8_t timeZone = -5; // Eastern Standard Time// NOTE: Daylight savings time will not be applied! Please use standard time!// Set the input and output pins for the logger// NOTE: Use -1 for pins that do not applyconst long serialBaud = 115200; // Baud rate for debuggingconst int8_t greenLED = 8; // Pin for the green LEDconst int8_t redLED = 9; // Pin for the red LEDconst int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin)const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep// Mayfly 0.x D31 = A7// Set the wake pin to -1 if you do not want the main processor to sleep.// In a SAMD system where you are using the built-in rtc, set wakePin to 1const int8_t sdCardPwrPin = -1; // MCU SD card power pinconst int8_t sdCardSSPin = 12; // SD card chip select/slave select pinconst int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power/** End [logging_options] */// ==========================================================================// Wifi/Cellular Modem Options// ==========================================================================/** Start [sim7080] */// For almost anything based on the SIMCom SIM7080G#include <modems/SIMComSIM7080.h>// Create a reference to the serial port for the modemHardwareSerial& modemSerial = Serial1; // Use hardware serial if possible// for Additional Serial Ports" sectionconst int32_t modemBaud =9600; // SIM7080 does auto-bauding by default, but I set mine to 9600// Modem Pins - Describe the physical pin connection of your modem to your board// NOTE: Use -1 for pins that do not applyconst int8_t modemVccPin = 18; // MCU pin controlling modem powerconst int8_t modemStatusPin = 19; // MCU pin used to read modem status//const bool useCTSforStatus = false; // Flag to use the modem CTS pin for status//const int8_t modemResetPin = 20; // MCU pin connected to modem reset pinconst int8_t modemSleepRqPin = 23; // MCU pin for modem sleep/wake requestconst int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem// status (-1 if unconnected)// Network connection informationconst char* apn = "hologram"; // The APN for the gprs connection// Create the modem objectSIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin,modemSleepRqPin, apn);// Create an extra reference to the modem by a generic nameSIMComSIM7080 modem = modem7080;/** End [xbee_cell_transparent] */// ==========================================================================// Using the Processor as a Sensor// ==========================================================================/** Start [processor_sensor] */#include <sensors/ProcessorStats.h>// Create the main processor chip "sensor" - for general metadataconst char* mcuBoardVersion = "v1.1b";ProcessorStats mcuBoard(mcuBoardVersion);/** End [processor_sensor] */// ==========================================================================// Maxim DS3231 RTC (Real Time Clock)// ==========================================================================/** Start [ds3231] */#include <sensors/MaximDS3231.h>// Create a DS3231 sensor objectMaximDS3231 ds3231(1);/** End [ds3231] */// ==========================================================================// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor// ==========================================================================/** Start [vue10] */#include <sensors/CampbellClariVUE10.h>const char* ClariVUESDI12address = "2"; // The SDI-12 Address of the ClariVUE10const int8_t ClariVUEPower = sensorPowerPin; // Power pin (-1 if unconnected)const int8_t ClariVUEData = 7; // The SDI12 data pin// NOTE: you should NOT take more than one readings. THe sensor already takes// and averages 8 by default.// Create a Campbell ClariVUE10 sensor objectCampbellClariVUE10 clarivue(*ClariVUESDI12address, ClariVUEPower, ClariVUEData);/** End [vue10] */// ==========================================================================// Meter Hydros 21 Conductivity, Temperature, and Depth Sensor// ==========================================================================/** Start [hydros21] */#include <sensors/MeterHydros21.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const char* hydros21SDI12address = "1"; // The SDI-12 Address of the Hydros21const uint8_t hydros21NumberReadings = 6; // The number of readings to averageconst int8_t hydros21Power = sensorPowerPin; // Power pinconst int8_t hydros21Data = 7; // The SDI12 data pin// Create a Decagon Hydros21 sensor objectMeterHydros21 hydros21(*hydros21SDI12address, hydros21Power, hydros21Data,hydros21NumberReadings);/** End [hydros21] */// ==========================================================================// Decagon CTD-10 Conductivity, Temperature, and Depth Sensor// ==========================================================================/** Start [decagon_ctd] */#include <sensors/DecagonCTD.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const char* CTDSDI12address = "1"; // The SDI-12 Address of the CTDconst uint8_t CTDNumberReadings = 6; // The number of readings to averageconst int8_t SDI12Power = sensorPowerPin; // Power pin (-1 if unconnected)const int8_t SDI12Data = 7; // The SDI12 data pin// Create a Decagon CTD sensor objectDecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings);/** End [decagon_ctd] */#include <sensors/AtlasScientificDO.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const int8_t AtlasDOPower = sensorPowerPin; // Power pinuint8_t AtlasDOi2c_addr = 0x61; // Default for DO is 0x61 (97)// All Atlas sensors have different default I2C addresses, but any of them can// be re-addressed to any 8 bit number. If using the default address for any// Atlas Scientific sensor, you may omit this argument.// Create an Atlas Scientific DO sensor object// AtlasScientificDO atlasDO(AtlasDOPower, AtlasDOi2c_addr);AtlasScientificDO atlasDO(AtlasDOPower);#include <sensors/AtlasScientificEC.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const int8_t AtlasECPower = sensorPowerPin; // Power pinuint8_t AtlasECi2c_addr = 0x64; // Default for pH is 0x63 (99)// All Atlas sensors have different default I2C addresses, but any of them can// be re-addressed to any 8 bit number. If using the default address for any// Atlas Scientific sensor, you may omit this argument.// Create an Atlas Scientific pH sensor object// AtlasScientificpH atlaspH(AtlaspHPower, AtlaspHi2c_addr);AtlasScientificEC atlasEC(AtlasECPower, AtlasECi2c_addr);#include <sensors/AtlasScientificpH.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const int8_t AtlaspHPower = sensorPowerPin; // Power pinuint8_t AtlaspHi2c_addr = 0x63; // Default for pH is 0x63 (99)// All Atlas sensors have different default I2C addresses, but any of them can// be re-addressed to any 8 bit number. If using the default address for any// Atlas Scientific sensor, you may omit this argument.// Create an Atlas Scientific pH sensor object// AtlasScientificpH atlaspH(AtlaspHPower, AtlaspHi2c_addr);AtlasScientificpH atlaspH(AtlaspHPower);#include <sensors/AtlasScientificORP.h>// NOTE: Use -1 for any pins that don't apply or aren't being used.const int8_t AtlasORPPower = sensorPowerPin; // Power pinuint8_t AtlasORPi2c_addr = 0x62; // Default for ORP is 0x62 (98)// All Atlas sensors have different default I2C addresses, but any of them can// be re-addressed to any 8 bit number. If using the default address for any// Atlas Scientific sensor, you may omit this argument.// Create an Atlas Scientific ORP sensor object// AtlasScientificORP atlasORP(AtlasORPPower, AtlasORPi2c_addr);AtlasScientificORP atlasORP(AtlasORPPower);// ==========================================================================// Creating the Variable Array[s] and Filling with Variable Objects// ==========================================================================/** Start [variable_arrays] */Variable* variableList[] = {new MeterHydros21_Temp(&hydros21),new MeterHydros21_Depth(&hydros21),new MeterHydros21_Cond(&hydros21),// new DecagonCTD_Cond(&ctd),// new DecagonCTD_Depth(&ctd),// new DecagonCTD_Temp(&ctd),// new CampbellOBS3_Turbidity(&osb3low, "", "TurbLow"),// new CampbellOBS3_Turbidity(&osb3high, "", "TurbHigh"),new ProcessorStats_Battery(&mcuBoard),// new Modem_SignalPercent(&modem),new MaximDS3231_Temp(&ds3231),new CampbellClariVUE10_Turbidity(&clarivue),new AtlasScientificDO_DOmgL(&atlasDO),//new AtlasScientificDO_DOpct(&atlasDO),// new AtlasScientificEC_Cond(&atlasEC),// new AtlasScientificEC_Salinity(&atlasEC),//new AtlasScientificEC_SpecificGravity(&atlasEC),//new AtlasScientificEC_TDS(&atlasEC),new AtlasScientificpH_pH(&atlaspH),//new AtlasScientificORP_Potential(&atlasORP)};// All UUID's, device registration, and sampling feature information can be// pasted directly from Monitor My Watershed. To get the list, click the "View// token UUID list" button on the upper right of the site page.// *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION ***// Check the order of your variables in the variable list!!!// Be VERY certain that they match the order of your UUID's!// Rearrange the variables in the variable list if necessary to match!// *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION ***const char *UUIDs[] = // UUID array for device sensors{"abcdefgh-1234-1234-1234-abcdefghijkl", // Electrical conductivity (Decagon_CTD-10_Cond)"abcdefgh-1234-1234-1234-abcdefghijkl", // Water depth (Decagon_CTD-10_Depth)"abcdefgh-1234-1234-1234-abcdefghijkl", // Temperature (Decagon_CTD-10_Temp)"abcdefgh-1234-1234-1234-abcdefghijkl", // Battery voltage (EnviroDIY_Mayfly_Batt)"abcdefgh-1234-1234-1234-abcdefghijkl", // Percent full scale (Digi_Cellular_SignalPercent)"abcdefgh-1234-1234-1234-abcdefghijkl", // Temperature (Maxim_DS3231_Temp)"abcdefgh-1234-1234-1234-abcdefghijkl" // Turbidity (Campbell_ClariVUE_Turbidity)};const char *registrationToken = "abcdefgh-1234-1234-1234-abcdefghijkl"; // Device registration tokenconst char *samplingFeature = "abcdefgh-1234-1234-1234-abcdefghijkl"; // Sampling feature UUID// Count up the number of pointers in the arrayint variableCount = sizeof(variableList) / sizeof(variableList[0]);// Create the VariableArray objectVariableArray varArray(variableCount, variableList, UUIDs);/** End [variable_arrays] */// ==========================================================================// The Logger Object[s]// ==========================================================================/** Start [loggers] */// Create a new logger instanceLogger dataLogger(LoggerID, loggingInterval, &varArray);/** End [loggers] */// ==========================================================================// Creating Data Publisher[s]// ==========================================================================/** Start [publishers] */// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint//#include <publishers/EnviroDIYPublisher.h>//EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient,// registrationToken, samplingFeature);// 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// the eighth in the array will be ignored.const char* thingSpeakChannelID ="123456"; // The numeric channel id for your channelconst char* thingSpeakMQTTusername ="abcdefgh-1234-1234-1234-abcdefghijkl"; //Your MQTT usernameconst char* thingSpeakMQTTpassword ="abcdefgh-1234-1234-1234-abcdefghijkl"; //Your MQTT passwordconst char* thingSpeakMQTTclientID ="abcdefgh-1234-1234-1234-abcdefghijkl"; //Your MQTT client ID// Create a data publisher for ThingSpeak#include <publishers/ThingSpeakPublisher.h>ThingSpeakPublisher TsMqtt;/** End [publishers] */// ==========================================================================// Working Functions// ==========================================================================/** Start [working_functions] */// Flashes the LED's on the primary boardvoid greenredflash(uint8_t numFlash = 4, uint8_t rate = 75) {for (uint8_t i = 0; i < numFlash; i++) {digitalWrite(greenLED, HIGH);digitalWrite(redLED, LOW);delay(rate);digitalWrite(greenLED, LOW);digitalWrite(redLED, HIGH);delay(rate);}digitalWrite(redLED, LOW);}// Reads the battery voltage// NOTE: This will actually return the battery level from the previous update!float getBatteryVoltage() {if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update();return mcuBoard.sensorValues[0];}// ==========================================================================// Arduino Setup Function// ==========================================================================/** Start [setup] */void setup() {// Start the primary serial connectionSerial.begin(serialBaud);// Print a start-up note to the first serial portSerial.print(F("Now running "));Serial.print(sketchName);Serial.print(F(" on Logger "));Serial.println(LoggerID);Serial.println();Serial.print(F("Using ModularSensors Library version "));Serial.println(MODULAR_SENSORS_VERSION);Serial.print(F("TinyGSM Library version "));Serial.println(TINYGSM_VERSION);Serial.println();// Start the serial connection with the modemmodemSerial.begin(modemBaud);// Set up pins for the LED'spinMode(22, OUTPUT);digitalWrite(22, HIGH);pinMode(greenLED, OUTPUT);digitalWrite(greenLED, LOW);pinMode(redLED, OUTPUT);digitalWrite(redLED, LOW);// Blink the LEDs to show the board is on and starting upgreenredflash();// Set the timezones for the logger/data and the RTC// Logging in the given time zoneLogger::setLoggerTimeZone(timeZone);// It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0)Logger::setRTCTimeZone(0);// Attach the modem and information pins to the loggerdataLogger.attachModem(modem);modem.setModemLED(modemLEDPin);dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin,greenLED);// Begin the variable array[s], logger[s], and publisher[s]varArray.begin(variableCount, variableList);dataLogger.begin(LoggerID, loggingInterval, &varArray);TsMqtt.begin(dataLogger, &modem.gsmClient,thingSpeakChannelID,thingSpeakMQTTusername,thingSpeakMQTTpassword,thingSpeakMQTTclientID);// Note: Please change these battery voltages to match your battery// Set up the sensors, except at lowest battery levelif (getBatteryVoltage() > 3.4) {Serial.println(F("Setting up sensors..."));varArray.setupSensors();}/** Start [setup_sim7080] */modem.setModemWakeLevel(HIGH); // ModuleFun Bee inverts the signalmodem.setModemResetLevel(HIGH); // ModuleFun Bee inverts the signalSerial.println(F("Waking modem and setting Cellular Carrier Options..."));modem.modemWake(); // NOTE: This will also set up the modemmodem.gsmModem.setBaud(modemBaud); // Make sure we're *NOT* auto-bauding!modem.gsmModem.setNetworkMode(38); // set to LTE only// 2 Automatic// 13 GSM only// 38 LTE only// 51 GSM and LTE onlymodem.gsmModem.setPreferredMode(1); // set to CAT-M// 1 CAT-M// 2 NB-IoT// 3 CAT-M and NB-IoT/** End [setup_sim7080] */// Sync the clock if it isn't valid or we have battery to spareif (getBatteryVoltage() > 3.55 || !dataLogger.isRTCSane()) {// Synchronize the RTC with NIST// This will also set up the modemdataLogger.syncRTC();}// Create the log file, adding the default header to it// Do this last so we have the best chance of getting the time correct and// all sensor names correct// Writing to the SD card can be power intensive, so if we're skipping// the sensor setup we'll skip this too.if (getBatteryVoltage() > 3.4) {Serial.println(F("Setting up file on SD card"));dataLogger.turnOnSDcard(true); // true = wait for card to settle after power updataLogger.createLogFile(true); // true = write a new headerdataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write}// Call the processor sleepSerial.println(F("Putting processor to sleep\n"));dataLogger.systemSleep();}/** End [setup] */// ==========================================================================// Arduino Loop Function// ==========================================================================/** Start [loop] */// Use this short loop for simple data logging and sendingvoid loop() {// Note: Please change these battery voltages to match your battery// At very low battery, just go back to sleepif (getBatteryVoltage() < 3.4) {dataLogger.systemSleep();}// At moderate voltage, log data but don't send it over the modemelse if (getBatteryVoltage() < 3.55) {dataLogger.logData();}// If the battery is good, send the data to the worldelse {dataLogger.logDataAndPublish();}}/** End [loop] *///Michael Daniel//Lynchburg Water ResourcesThank you so much for all your help and hard work! Everything is working perfectly now.
The Mayfly is at least v1.1, but I’m unsure what revision it is. Would it say RevB on the board somewhere?
Also, I should’ve mentioned earlier that I’ve tried to run the address change program when the turbidity sensor wasn’t working and the program couldn’t find the sensor at all, regardless of the amount of times I let it loop through the program. It just listed every address as vacant over and over again. This happened on 2 different mayfly boards with 2 different sensors. The program was able to work once it warmed up.
Would this still indicate an interval issue? Would running TestWarmUp in colder conditions allow me to see how much the interval needs to increase? Or if I changed the intervals in CampbellClariVUE10.h would I be able to test if it’s an interval issue? Would changing this interval have cascading effects that would need to be accounted for?
Or should I just get RevB boards?
I decided to try to make a new site in order to try to work around the problem, but that hasn’t seemed to work either. I’m now getting 504 response codes. The data is still uploading to MMW but not publishing. I have to be missing something obvious, right? The new site is NTNWD in the same spot.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409/** =========================================================================* @file DRWI_LTE.ino* @brief Example for DRWI CitSci LTE sites.** This example shows proper settings for the following configuration:** Mayfly v0.5 board* EnviroDIY sim7080 LTE module (with Hologram SIM card)* Hydros21 CTD sensor* Campbell Scientific OBS3+ Turbidity sensor* @author Sara Geleskie Damiano <sdamiano@stroudcenter.org>* @copyright (c) 2017-2020 Stroud Water Research Center (SWRC)* and the EnviroDIY Development Team* This example is published under the BSD-3 license.** Build Environment: Visual Studios Code with PlatformIO* Hardware Platform: EnviroDIY Mayfly Arduino Datalogger** DISCLAIMER:* THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN.* ======================================================================= */// ==========================================================================// Defines for the Arduino IDE// NOTE: These are ONLY needed to compile with the Arduino IDE.// If you use PlatformIO, you should set these build flags in your// platformio.ini// ==========================================================================/** Start [defines] */#ifndef TINY_GSM_RX_BUFFER#define TINY_GSM_RX_BUFFER 64#endif#ifndef TINY_GSM_YIELD_MS#define TINY_GSM_YIELD_MS 2#endif#ifndef MQTT_MAX_PACKET_SIZE#define MQTT_MAX_PACKET_SIZE 256#endif/** End [defines] */// ==========================================================================// Include the libraries required for any data logger// ==========================================================================/** Start [includes] */// The Arduino library is needed for every Arduino program.#include <Arduino.h>// EnableInterrupt is used by ModularSensors for external and pin change// interrupts and must be explicitly included in the main program.#include <EnableInterrupt.h>// To get all of the base classes for ModularSensors, include LoggerBase.// NOTE: Individual sensor definitions must be included separately.#include <LoggerBase.h>// Include the main header for ModularSensors#include <ModularSensors.h>/** End [includes] */// ==========================================================================// Data Logging Options// ==========================================================================/** Start [logging_options] */// The name of this program fileconst char* sketchName = "DRWI_LTE.ino";// Logger ID, also becomes the prefix for the name of the data file on SD cardconst char* LoggerID = "NTNWD";// How frequently (in minutes) to log dataconst uint8_t loggingInterval = 5;// Your logger's timezone.const int8_t timeZone = -5; // Eastern Standard Time// NOTE: Daylight savings time will not be applied! Please use standard time!// Set the input and output pins for the logger// NOTE: Use -1 for pins that do not applyconst long serialBaud = 115200; // Baud rate for debuggingconst int8_t greenLED = 8; // Pin for the green LEDconst int8_t redLED = 9; // Pin for the red LEDconst int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin)const int8_t wakePin = A7; // MCU interrupt/alarm pin to wake from sleep// Mayfly 0.x D31 = A7// Set the wake pin to -1 if you do not want the main processor to sleep.// In a SAMD system where you are using the built-in rtc, set wakePin to 1const int8_t sdCardPwrPin = -1; // MCU SD card power pinconst int8_t sdCardSSPin = 12; // SD card chip select/slave select pinconst int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power/** End [logging_options] */// ==========================================================================// Wifi/Cellular Modem Options// ==========================================================================/** Start [sim7080] */// For almost anything based on the SIMCom SIM7080G#include <modems/SIMComSIM7080.h>// Create a reference to the serial port for the modemHardwareSerial& modemSerial = Serial1; // Use hardware serial if possible// for Additional Serial Ports" sectionconst int32_t modemBaud =9600; // SIM7080 does auto-bauding by default, but I set mine to 9600// Modem Pins - Describe the physical pin connection of your modem to your board// NOTE: Use -1 for pins that do not applyconst int8_t modemVccPin = -2; // MCU pin controlling modem powerconst int8_t modemStatusPin = 19; // MCU pin used to read modem statusconst bool useCTSforStatus = false; // Flag to use the modem CTS pin for statusconst int8_t modemResetPin = 20; // MCU pin connected to modem reset pinconst int8_t modemSleepRqPin = 23; // MCU pin for modem sleep/wake requestconst int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem// status (-1 if unconnected)// Network connection informationconst char* apn = "hologram"; // The APN for the gprs connection// Create the modem objectSIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin,modemSleepRqPin, apn);// Create an extra reference to the modem by a generic nameSIMComSIM7080 modem = modem7080;/** End [xbee_cell_transparent] */// ==========================================================================// Using the Processor as a Sensor// ==========================================================================/** Start [processor_sensor] */#include <sensors/ProcessorStats.h>// Create the main processor chip "sensor" - for general metadataconst char* mcuBoardVersion = "v0.5b";ProcessorStats mcuBoard(mcuBoardVersion);/** End [processor_sensor] */// ==========================================================================// Maxim DS3231 RTC (Real Time Clock)// ==========================================================================/** Start [ds3231] */#include <sensors/MaximDS3231.h>// Create a DS3231 sensor objectMaximDS3231 ds3231(1);/** End [ds3231] */// ==========================================================================// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor// ==========================================================================/** Start [obs3] */#include <sensors/CampbellOBS3.h>const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected)const uint8_t OBS3NumberReadings = 10;const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC// Campbell OBS 3+ *Low* Range Calibration in Voltsconst int8_t OBSLowADSChannel = 0; // ADS channel for *low* range outputconst float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range]const float OBSLow_B = 1.000E+00; // "B" value (X) [*low* range]const float OBSLow_C = 0.000E+00; // "C" value [*low* range]// Create a Campbell OBS3+ *low* range sensor objectCampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C,ADSi2c_addr, OBS3NumberReadings);// Campbell OBS 3+ *High* Range Calibration in Voltsconst int8_t OBSHighADSChannel = 1; // ADS channel for *high* range outputconst float OBSHigh_A = 0.000E+00; // "A" value (X^2) [*high* range]const float OBSHigh_B = 1.000E+00; // "B" value (X) [*high* range]const float OBSHigh_C = 0.000E+00; // "C" value [*high* range]// Create a Campbell OBS3+ *high* range sensor objectCampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B,OBSHigh_C, ADSi2c_addr, OBS3NumberReadings);/** End [obs3] */// ==========================================================================// Meter Hydros 21 Conductivity, Temperature, and Depth Sensor// ==========================================================================/** Start [decagon_ctd] */#include <sensors/DecagonCTD.h>const char* CTDSDI12address = "1"; // The SDI-12 Address of the CTDconst uint8_t CTDNumberReadings = 6; // The number of readings to averageconst int8_t SDI12Power = sensorPowerPin; // Power pin (-1 if unconnected)const int8_t SDI12Data = 7; // The SDI12 data pin// Create a Decagon CTD sensor objectDecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings);/** End [decagon_ctd] */// ==========================================================================// Creating the Variable Array[s] and Filling with Variable Objects// ==========================================================================/** Start [variable_arrays] */Variable* variableList[] = {new DecagonCTD_Cond(&ctd),new DecagonCTD_Depth(&ctd),new DecagonCTD_Temp(&ctd),// new CampbellOBS3_Turbidity(&osb3low, "", "TurbLow"),// new CampbellOBS3_Turbidity(&osb3high, "", "TurbHigh"),new ProcessorStats_Battery(&mcuBoard),new MaximDS3231_Temp(&ds3231),// new Modem_RSSI(&modem),new Modem_SignalPercent(&modem),};// All UUID's, device registration, and sampling feature information can be// pasted directly from Monitor My Watershed. To get the list, click the "View// token UUID list" button on the upper right of the site page.// *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION ***// Check the order of your variables in the variable list!!!// Be VERY certain that they match the order of your UUID's!// Rearrange the variables in the variable list if necessary to match!// *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION ***const char *UUIDs[] = // UUID array for device sensors{"a619cb5d-5bc6-4c07-8c77-0ed879c22b60", // Electrical conductivity (Decagon_CTD-10_Cond)"377e0676-982e-4dd0-9283-a08eb8ef989b", // Water depth (Decagon_CTD-10_Depth)"0a345b69-848f-4703-9055-361f74b81cd5", // Temperature (Decagon_CTD-10_Temp)"10d9d51d-0227-43f1-bf3b-b445436bdc4d", // Battery voltage (EnviroDIY_Mayfly_Batt)"6dc48d23-2fd7-48fd-890b-478a31223b32", // Temperature (Maxim_DS3231_Temp)"53ca50a0-06d8-491a-ae0e-9b5a36fc6d4f" // Percent full scale (Digi_Cellular_SignalPercent)};const char *registrationToken = "5b119f9c-7f26-4e16-bea9-5f9ad9f568dc"; // Device registration tokenconst char *samplingFeature = "383c6738-cee1-4e22-bb0f-d86dda9d29f0"; // Sampling feature UUID// Count up the number of pointers in the arrayint variableCount = sizeof(variableList) / sizeof(variableList[0]);// Create the VariableArray objectVariableArray varArray(variableCount, variableList, UUIDs);/** End [variable_arrays] */// ==========================================================================// The Logger Object[s]// ==========================================================================/** Start [loggers] */// Create a new logger instanceLogger dataLogger(LoggerID, loggingInterval, &varArray);/** End [loggers] */// ==========================================================================// Creating Data Publisher[s]// ==========================================================================/** Start [publishers] */// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint#include <publishers/EnviroDIYPublisher.h>EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient,registrationToken, samplingFeature);/** End [publishers] */// ==========================================================================// Working Functions// ==========================================================================/** Start [working_functions] */// Flashes the LED's on the primary boardvoid greenredflash(uint8_t numFlash = 4, uint8_t rate = 75) {for (uint8_t i = 0; i < numFlash; i++) {digitalWrite(greenLED, HIGH);digitalWrite(redLED, LOW);delay(rate);digitalWrite(greenLED, LOW);digitalWrite(redLED, HIGH);delay(rate);}digitalWrite(redLED, LOW);}// Reads the battery voltage// NOTE: This will actually return the battery level from the previous update!float getBatteryVoltage() {if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update();return mcuBoard.sensorValues[0];}// ==========================================================================// Arduino Setup Function// ==========================================================================/** Start [setup] */void setup() {// Start the primary serial connectionSerial.begin(serialBaud);// Print a start-up note to the first serial portSerial.print(F("Now running "));Serial.print(sketchName);Serial.print(F(" on Logger "));Serial.println(LoggerID);Serial.println();Serial.print(F("Using ModularSensors Library version "));Serial.println(MODULAR_SENSORS_VERSION);Serial.print(F("TinyGSM Library version "));Serial.println(TINYGSM_VERSION);Serial.println();// Start the serial connection with the modemmodemSerial.begin(modemBaud);// Set up pins for the LED'spinMode(greenLED, OUTPUT);digitalWrite(greenLED, LOW);pinMode(redLED, OUTPUT);digitalWrite(redLED, LOW);// Blink the LEDs to show the board is on and starting upgreenredflash();// Set the timezones for the logger/data and the RTC// Logging in the given time zoneLogger::setLoggerTimeZone(timeZone);// It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0)Logger::setRTCTimeZone(0);// Attach the modem and information pins to the loggerdataLogger.attachModem(modem);modem.setModemLED(modemLEDPin);dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin,greenLED);// Begin the loggerdataLogger.begin();// Note: Please change these battery voltages to match your battery// Set up the sensors, except at lowest battery levelif (getBatteryVoltage() > 3.4) {Serial.println(F("Setting up sensors..."));varArray.setupSensors();}/** Start [setup_sim7080] */modem.setModemWakeLevel(HIGH); // ModuleFun Bee inverts the signalmodem.setModemResetLevel(HIGH); // ModuleFun Bee inverts the signalSerial.println(F("Waking modem and setting Cellular Carrier Options..."));modem.modemWake(); // NOTE: This will also set up the modemmodem.gsmModem.setBaud(modemBaud); // Make sure we're *NOT* auto-bauding!modem.gsmModem.setNetworkMode(38); // set to LTE only// 2 Automatic// 13 GSM only// 38 LTE only// 51 GSM and LTE onlymodem.gsmModem.setPreferredMode(1); // set to CAT-M// 1 CAT-M// 2 NB-IoT// 3 CAT-M and NB-IoT/** End [setup_sim7080] */// Sync the clock if it isn't valid or we have battery to spareif (getBatteryVoltage() > 3.55 || !dataLogger.isRTCSane()) {// Synchronize the RTC with NIST// This will also set up the modemdataLogger.syncRTC();}// Create the log file, adding the default header to it// Do this last so we have the best chance of getting the time correct and// all sensor names correct// Writing to the SD card can be power intensive, so if we're skipping// the sensor setup we'll skip this too.if (getBatteryVoltage() > 3.4) {Serial.println(F("Setting up file on SD card"));dataLogger.turnOnSDcard(true); // true = wait for card to settle after power updataLogger.createLogFile(true); // true = write a new headerdataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write}// Call the processor sleepSerial.println(F("Putting processor to sleep\n"));dataLogger.systemSleep();}/** End [setup] */// ==========================================================================// Arduino Loop Function// ==========================================================================/** Start [loop] */// Use this short loop for simple data logging and sendingvoid loop() {// Note: Please change these battery voltages to match your battery// At very low battery, just go back to sleepif (getBatteryVoltage() < 3.4) {dataLogger.systemSleep();}// At moderate voltage, log data but don't send it over the modemelse if (getBatteryVoltage() < 3.55) {dataLogger.logData();}// If the battery is good, send the data to the worldelse {dataLogger.logDataAndPublish();}}/** End [loop] *///Michael Daniel//Lynchburg Water ResourcesI’m also unable to delete my previous sites or delete sensors.
Thanks for replying so quickly Jim!
I have another station with the underscore that is currently uploading correctly, but I’ll give it a shot.
Edit: I changed the underscore to a dash, but it still isn’t working.
The battery was not replaced again on August 25th, that is the same battery that will no longer charge. Doesn’t the scale of battery loss and gain look extreme. I adjusted the solar panel to get more light, it is in a pretty shady area but it get direct sunlight for a couple of hours everyday.
Do you all think I need a bigger battery or a larger solar panel?
That worked! Thanks Shannon!
Thanks for the suggestion Matt,
It didn’t work very well, here’s the new error message:
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: “Arduino Uno”
Sketch uses 6206 bytes (19%) of program storage space. Maximum is 32256 bytes.
Global variables use 631 bytes (30%) of dynamic memory, leaving 1417 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x50
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x6f
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x77
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x65
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x72
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x69
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x6e
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x67
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x75
An error occurred while uploading the sketchHi all,
I’m new to all this so still using ArduinoIDE for now. I’m getting a similar error when trying to change the address for a Meters CDT sensor. (One of the ones I recently purchased was recalled so I am trying to connect a different one).The error reads “Invalid version ‘0.28.01’ for library in: C:\Users\lillyn\Documents\Arduino\libraries\EnviroDIY_ModularSensors”
Any suggestions on how to fix it?
-
AuthorPosts