Data from string is showing 0 (It's not supposed to)

I have four sensors hooked up to an Arduino Uno Compatible board, one of the sensors measures electrical conductivity. The sensor reads fine until I put it into salt water (with a conductivity many time higher than fresh water) at which it outputs 0. I think this could be an overflow error, the sample code I based my project around is from a company called Atlas Scientific. BTW, I can’t simply change the integer to a long because they defined it as a String and it causes issues when you change it, anyway here’s my code.

//******** Libraries ***********
#include <SparkFun_Qwiic_Relay.h>
#include <U8glib.h>
#include "SparkFun_Qwiic_Relay.h"
#include "U8glib.h"
#include <Wire.h>
#include <SoftwareSerial.h>
#define RELAY_ADDR 0x18
#include <SPI.h>
#include <SD.h>

Qwiic_Relay relay(RELAY_ADDR); 
File myFile;

int burndelay = 15; //CHANGE THIS --- The time in seconds before the relay executes.
#define TOTAL_CIRCUITS 4                       // <-- CHANGE THIS | set how many I2C circuits are attached to the Tentacle

const unsigned int baud_host  = 9600;        // set baud rate for host serial monitor(pc/mac/other)
const unsigned int send_readings_every = 2500; // set at what intervals the readings are sent to the computer (NOTE: this is not the frequency of taking the readings!)
unsigned long next_serial_time;

char sensordata[30];                          // A 30 byte character array to hold incoming data from the sensors
byte sensor_bytes_received = 0;               // We need to know how many characters bytes have been received
byte code = 0;                                // used to hold the I2C response code.
byte in_char = 0;                             // used as a 1 byte buffer to store in bound bytes from the I2C Circuit.

int channel_ids[] = {100, 101, 102, 103};        // <-- CHANGE THIS. A list of I2C ids that you set your circuits to.
char *channel_names[] = {"EC", "PH", "DO", "PT"};   // <-- CHANGE THIS. A list of channel names (must be the same order as in channel_ids[]) - only used to designate the readings in serial communications
char *channel_units[] = {"μS/cm","pH","mg/L","Celcius"};
String readings[TOTAL_CIRCUITS];               // an array of strings to hold the readings of each channel
int channel = 0;                              // INT pointer to hold the current position in the channel_ids/channel_names array

const unsigned int reading_delay = 1000;      // time to wait for the circuit to process a read command. datasheets say 1 second.
unsigned long next_reading_time;              // holds the time when the next reading should be ready from the circuit
boolean request_pending = false;              // wether or not we're waiting for a reading

const unsigned int blink_frequency = 250;     // the frequency of the led blinking, in milliseconds
unsigned long next_blink_time;                // holds the next time the led should change state
boolean led_state = LOW;                      // keeps track of the current led state

void setup() {
  pinMode(13, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(baud_host);	              // Set the hardware serial port.
  Wire.begin();			              // enable I2C port.
  next_serial_time = millis() + send_readings_every;  // calculate the next point in time we should do serial communications
    Serial.println("Check connections to Qwiic Relay.");
    Serial.println("Ready to flip some switches.");
    float version = relay.singleRelayVersion();
    Serial.print("Firmware Version: ");

  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");

void loop() {

  if (millis() == burndelay*1000){


// do serial communication in a "asynchronous" way
void do_serial() {
  if (millis() >= next_serial_time) {                // is it time for the next serial communication?
    myFile ="Output.txt", FILE_WRITE);
    Serial.println(" Seconds since program start");
    myFile.println(" Seconds since program start");
    for (int i = 0; i < TOTAL_CIRCUITS; i++) {       // loop through all the sensors
      Serial.print(channel_names[i]);                // print channel name
      Serial.print(readings[i]);                     // print the actual reading
      Serial.print(" ");
      myFile.print(channel_names[i]);                // print channel name
      myFile.print(readings[i]);                   // print the actual reading
      myFile.print(" ");
    next_serial_time = millis() + send_readings_every;

// take sensor readings in a "asynchronous" way
void do_sensor_readings() {
  if (request_pending) {                          // is a request pending?
    if (millis() >= next_reading_time) {          // is it time for the reading to be taken?
      receive_reading();                          // do the actual I2C communication
  } else {                                        // no request is pending,
    channel = (channel + 1) % TOTAL_CIRCUITS;     // switch to the next channel (increase current channel by 1, and roll over if we're at the last channel using the % modulo operator)
    request_reading();                            // do the actual I2C communication

// Request a reading from the current channel
void request_reading() {
  request_pending = true;
  Wire.beginTransmission(channel_ids[channel]); // call the circuit by its ID number.
  Wire.write('r');        		        // request a reading by sending 'r'
  Wire.endTransmission();          	        // end the I2C data transmission.
  next_reading_time = millis() + reading_delay; // calculate the next time to request a reading

// Receive data from the I2C bus
void receive_reading() {
  sensor_bytes_received = 0;                        // reset data counter
  memset(sensordata, 0, sizeof(sensordata));        // clear sensordata array;

  Wire.requestFrom(channel_ids[channel], 48, 1);    // call the circuit and request 48 bytes (this is more then we need).
  code =;

  while (Wire.available()) {          // are there bytes to receive?
    in_char =;            // receive a byte.

    if (in_char == 0) {               // if we see that we have been sent a null command.
      Wire.endTransmission();         // end the I2C data transmission.
      break;                          // exit the while loop, we're done here
    else {
      sensordata[sensor_bytes_received] = in_char;  // load this byte into our array.

  switch (code) {                  	    // switch case based on what the response code is.
    case 1:                       	    // decimal 1  means the command was successful.
      readings[channel] = sensordata;
      break;                        	    // exits the switch case.

    case 2:                        	    // decimal 2 means the command has failed.
      readings[channel] = "error: command failed";
      break;                         	    // exits the switch case.

    case 254:                      	    // decimal 254  means the command has not yet been finished calculating.
      readings[channel] = "reading not ready";
      break;                         	    // exits the switch case.

    case 255:                      	    // decimal 255 means there is no further data to send.
      readings[channel] = "error: no data";
      break;                         	    // exits the switch case.
  request_pending = false;                  // set pending to false, so we can continue to the next sensor

Can you please provide some documentation on the electrical conductivity sensor?

Which sensor are you using?