OceanographyforEveryone / OpenCTD

The OpenCTD is a low-cost, open-source CTD for researchers and citizen scientists.
http://www.oceanographyforeveryone.com
MIT License
179 stars 52 forks source link

Independent System Not taking values #25

Closed MattChace closed 3 years ago

MattChace commented 4 years ago

Uploading the code from my computer Arduino IDE and opening the Serial Monitor I am seeing the sensor take values and store them to the SD Card, I remove the SD Card and read the txt file on my computer and confirm that the values were saved. However, when the MCU is powered by a battery and I did a test cast, I open the txt file and find it empty. Not sure why the code is not running when it is turned on by the battery. Any assistance would be greatly appreciated!!

IanTBlack commented 4 years ago

Hi Matt, Which version of the OpenCTD are you working with? If you have modified you code, can you attach it?

Thanks,

MattChace commented 4 years ago

Hi Ian!! Thanks for the quick response! We are working with the Version of the CTD that is within the Construction/Operation Manual and followed all the steps within that text, I have attached my Arduino Code below.

Thanks!

Matthew Chace

Bachelors of Science in Electrical Engineering

Wentworth Institute of Technology

Boston, Massachusetts


From: Ian Black notifications@github.com Sent: Monday, June 22, 2020 4:56 PM To: OceanographyforEveryone/OpenCTD OpenCTD@noreply.github.com Cc: Chace, Matthew chacem@wit.edu; Author author@noreply.github.com Subject: Re: [OceanographyforEveryone/OpenCTD] Independent System Not taking values (#25)

Hi Matt, Which version of the OpenCTD are you working with? If you have modified you code, can you attach it?

Thanks,

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOceanographyforEveryone%2FOpenCTD%2Fissues%2F25%23issuecomment-647765013&data=02%7C01%7Cchacem%40wit.edu%7C9eeb2c6c926d4610b63008d816eeab90%7C2af16cc576494528bc4d3d9b6f64c066%7C0%7C1%7C637284561625681827&sdata=VTpCfLFcW%2FHmazVqNQzGzvyp292V34v8nIRZoO84STA%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQBM4EQKFD4763RF5SANSJLRX7AOBANCNFSM4OFAZ5DQ&data=02%7C01%7Cchacem%40wit.edu%7C9eeb2c6c926d4610b63008d816eeab90%7C2af16cc576494528bc4d3d9b6f64c066%7C0%7C1%7C637284561625681827&sdata=CtuboaWUreJpqGYgR%2BO7HwwCMBQ9YwHxBsjTaqShhqs%3D&reserved=0.

IanTBlack commented 4 years ago

Hi Matt, Doesn't look like it attached properly. You might have to do it directly through the GitHub website.

Couple more questions.

1) If you add an empty SD card, is the text file created, but remains empty?

2) Is the SD card seated properly? -If you operate it under battery on the bench, you could try tying the EC EZO LED to turn on/off if the SD card is not detected. See lines 140-144 here: https://github.com/IanTBlack/CTDizzle/blob/master/Adafruit_M0_Mk5/2019-04-29_Profile.ino

3) What battery are you using?

Unfortunately I don't have an M0 Adalogger, but I do have a BLE M0 Feather + Adalogger featherwing, so I will see if I can recreate your problem once I get your code.

MattChace commented 4 years ago

My Code is pasted below, I put a new micro sd into the board and turned it on. The MCU doesnt create a txt file at all.

``//Date and time functions using a DS3231 RTC connected via I2C and Wire lib

include

include "RTClib.h"

//serial peripheral interface and library for SD card reader

include //serial peripheral interface for SD card reader

include //library for SD card reader

//communication protocols for temperature sensors

include

include

//Software libary for the pressure sensor

include

//EC Circuit uses software serial

include

RTC_DS3231 rtc; //define real-time clock

const int chipSelect = 4; //sets chip select pin for SD card reader

MS_5803 sensor = MS_5803(512); // Define pressure sensor.

OneWire oneWire(6); // Define the OneWire port for temperature. DallasTemperature sensors(&oneWire); //Define DallasTemperature input based on OneWire.

SoftwareSerial ecSerial(12, 13); // Define the SoftwareSerial port for conductivity.

double pressure_abs; //define absolute pressure variable

//Declare global temperature variables. float tempA; float tempB; float tempC;

//Declare global variables for eletrical conductivity float EC_float = 0;
char EC_data[48]; // A 48 byte character array to hold incoming data from the conductivity circuit. char *EC; // Character pointer for string parsing. byte received_from_sensor = 0; // How many characters have been received. byte string_received = 0; // Whether it received a string from the EC circuit.

void setup () {

// comment the following three lines out for final deployment

ifndef ESP8266

while (!Serial);   //for Leonardo/Micro/Zero

endif

Serial.begin(9600);

//Initialize SD card reader Serial.print("Initializing SD card...");

if (!SD.begin(chipSelect)) {

Serial.println("Card failed, or not present");
return;

}

Serial.println("card initialized.");

delay(1000);

if (! rtc.begin()) {

Serial.println("Couldn't find RTC");
while (1);

}

File dataFile = SD.open("datalog.txt", FILE_WRITE);

if (dataFile) {

dataFile.println("");
dataFile.println("=== New Cast ===");
dataFile.println("");
dataFile.close();

}

//Initialize real-time clock if (rtc.lostPower()) {

//reset RTC with time when code was compiled if RTC loses power
Serial.println("RTC lost power, lets set the time!"); 
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

}

delay(250); // Wait a quarter second to continue.

//Initialize sensors
sensor.initializeMS_5803(); // Initialize pressure sensor

sensors.begin(); // Intialize the temperature sensors.

ecSerial.begin(9600); // Set baud rate for conductivity circuit.

}

void loop () {

DateTime now = rtc.now(); //check RTC

sensor.readSensor(); //read pressure sensor pressure_abs = sensor.pressure();

//read temperature sensor sensors.requestTemperatures(); tempA = sensors.getTempCByIndex(0); tempB = sensors.getTempCByIndex(1); tempC = sensors.getTempCByIndex(2);

//Read electrical conductivity sensor if (ecSerial.available() > 0) {

received_from_sensor = ecSerial.readBytesUntil(13, EC_data, 48);
EC_data[received_from_sensor] = 0; // Null terminate the data by setting the value after the final character to 0.

}

if ((EC_data[0] >= 48) && (EC_data[0] <=57)) { // Parse data, if EC_data begins with a digit, not a letter (testing ASCII values).

parse_data();

}

//output readings to serial monitor. A whole mess of if/else statements to keep numbers formatted correctly Serial.print(now.year(), DEC); Serial.print('/');

if (now.month()<10) {

Serial.print(0);
Serial.print(now.month(), DEC);

}

else {

Serial.print(now.month(), DEC);

}

Serial.print('/');

if (now.day()<10) {

Serial.print(0);
Serial.print(now.day(), DEC);

}

else {

Serial.print(now.day(), DEC);

}

Serial.print(" ");

if (now.hour()<10) {

Serial.print(0);
Serial.print(now.hour(), DEC);

}

else {

Serial.print(now.hour(), DEC);

}

Serial.print(':');

if (now.minute()<10) {

Serial.print(0);
Serial.print(now.minute(), DEC);

}

else {

Serial.print(now.minute(), DEC);

}

Serial.print(':');

if (now.second()<10) {

Serial.print(0);
Serial.print(now.second(), DEC);

}

else {

Serial.print(now.second(), DEC);

}

Serial.print(" "); Serial.print(pressure_abs); Serial.print(" ");
Serial.print(tempA); Serial.print(" "); Serial.print(tempB); Serial.print(" "); Serial.print(tempC); Serial.print(" "); Serial.println(EC);

//output readings to data file. A whole mess of if/else statements to keep numbers formatted correctly File dataFile = SD.open("datalog.txt", FILE_WRITE);

if (dataFile) {

dataFile.print(now.year(), DEC);
dataFile.print('/');

if (now.month()<10) {

dataFile.print(0);
dataFile.print(now.month(), DEC);

}

else {

 dataFile.print(now.month(), DEC);

}

dataFile.print('/');

if (now.day()<10) {

  dataFile.print(0);
  dataFile.print(now.day(), DEC);

}

else {

  dataFile.print(now.day(), DEC);

}

dataFile.print("  ");

if (now.hour()<10) {

  dataFile.print(0);
  dataFile.print(now.hour(), DEC);

}

else {

  dataFile.print(now.hour(), DEC);

} 

dataFile.print(':');

if (now.minute()<10) {

  dataFile.print(0);
  dataFile.print(now.minute(), DEC);

}

else {

  dataFile.print(now.minute(), DEC);

}  

dataFile.print(':');

if (now.second()<10) {

  dataFile.print(0);
  dataFile.print(now.second(), DEC);

}

else {

 dataFile.print(now.second(), DEC);

}

dataFile.print("  ");
dataFile.print(pressure_abs);
dataFile.print("  ");  
dataFile.print(tempA);
dataFile.print("  ");
dataFile.print(tempB);
dataFile.print("  ");
dataFile.print(tempC);
dataFile.print("  "); 
dataFile.println(EC);
dataFile.close();    

}

delay(50);

}

void parse_data() { // Parses data from the EC Circuit.

EC = strtok(EC_data, ",");

}`

DrAndrewThaler commented 4 years ago

Hello,

Lines 48, 49, and 50...

#ifndef ESP8266 while (!Serial); //for Leonardo/Micro/Zero #endif

...provide diagnostic information during assembly and should be commented out or removed from the code prior to deployment, otherwise the Arduino will look for a serial connection before writing to the SD card.

MattChace commented 4 years ago

That worked!! Thank you so much!

Matthew Chace


From: Andrew Thaler notifications@github.com Sent: Monday, June 22, 2020 8:31 PM To: OceanographyforEveryone/OpenCTD OpenCTD@noreply.github.com Cc: Chace, Matthew chacem@wit.edu; Author author@noreply.github.com Subject: Re: [OceanographyforEveryone/OpenCTD] Independent System Not taking values (#25)

Hello,

Lines 48, 49, and 50...

ifndef ESP8266 while (!Serial); //for Leonardo/Micro/Zero #endif

...provide diagnostic information during assembly and should be commented out or removed from the code prior to deployment, otherwise the Arduino will look for a serial connection before writing to the SD card.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOceanographyforEveryone%2FOpenCTD%2Fissues%2F25%23issuecomment-647836529&data=02%7C01%7Cchacem%40wit.edu%7C8508193d1502410e3c7508d8170cbbef%7C2af16cc576494528bc4d3d9b6f64c066%7C0%7C0%7C637284690745838768&sdata=GoSeKFWDArT74KaB2TsPQP9phME3IZbG5608klfR6UA%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQBM4EUGUMJKQLTE4EBDZHLRX7ZVBANCNFSM4OFAZ5DQ&data=02%7C01%7Cchacem%40wit.edu%7C8508193d1502410e3c7508d8170cbbef%7C2af16cc576494528bc4d3d9b6f64c066%7C0%7C0%7C637284690745838768&sdata=KhF4BtzGcQxWuJA09icdU6HIAY5tw7r%2FGLlXHzJ4qN8%3D&reserved=0.

goldsphininx commented 3 years ago

House cleaning. ;)

On Fri, Sep 25, 2020 at 9:35 AM Andrew Thaler notifications@github.com wrote:

Closed #25 https://github.com/OceanographyforEveryone/OpenCTD/issues/25.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OceanographyforEveryone/OpenCTD/issues/25#event-3807731440, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADT6CXRUH737GMZTAMWY5ALSHSMA7ANCNFSM4OFAZ5DQ .

--

S. Kersey Sturdivant, PhD | Principal Scientist T: (401) 239-6668 | F: (401) 223-6405 [image: INSPIRE Environmental] http://www.inspireenvironmental.com/ [image: INSPIRE on Facebook] https://www.facebook.com/INSPIREenvironmental/ [image: INSPIRE on LinkedIn] https://www.linkedin.com/company-beta/10917021/ [image: INSPIRE on Twitter] https://twitter.com/inspireenviron Replication: It's the n's that Justify the Means.