TDS probe SEN0244, I/O pin voltage fluctuation

Hi all,

I'm new to electronics and the Arduino and my experience with code is also minimal. I've been building my first project for monitoring the environment of a hydroponics set up and I've been having some issues with the TDS value spiking and it seems to correspond to fluctuations with the voltage. Other than the spikes the data is very consistent. I've attached an excel document with the data as well. FYI, the spike at point 39 is from changing from USB power to the power supply.

I'm currently running a test with two different TDS probes, both being powered by I/O pins because the end product will have a TDS probe and a pH probe that cannot be running simultaneously. One isn't having any issues and that is powered by pin 13. The other, powered by pin 6, has had some spikes. My sensor is from DF Robot and supposedly has a working current of 3-6mA. The probes are in a deep water culture with an air stone, but no electrical devices. Probe1 powers on for 60 seconds, takes a reading and then powers off. Probe 2 immediately powers on for 60 seconds as well before taking a reading and powering down. These measurements are taken every 5 minutes.

Has anyone encountered similar problems? I have some 3.3V regulators that I thought may help keep the voltage stable, but I wasn't getting power with the I/O pin. Maybe I had something wrong with my wiring or the code, but I thought maybe there wasn't enough current from the I/O pin to use the LD33V. I wasn't seeing a lot of help online for TDS sensors, but what I did find didn't mention needing capacitors or anything like that. I'm assuming that's the direction I need to head. I'm not sure if adding capacitors would require adding transistors to amplify the current as well.

I should note I have a third probe running in a different set up in a different room and that has been spiking much more frequently.

Thanks in advance!

Edit: I guess excel docs aren't allowed...

Excel docs are not allowed.

What is allowed: - a pasted list of the values you want to show. - images of your setup and circuit. - links to the sensor in question. - a copy of the (offending?) code. - your circuit diagram as image.

Allowed and highly recommended even.

Probe: link

As for the circuit, there are three wires that are part of the probe: power, ground, and data. All three wires are connected to a breadboard. The power wire is connected to pin13, the data to A0, and ground to ground. After first noticing spiky data, I later did connect a potentiometer parallel to pin13 to measure the voltage. Probe 2 is connected in the same manner, except to pin6 and pin A3.

  // every 5 minutes check measurements
  if((counter - counter2 > 300000) || counter2 == 0){
    
    //checking water temp
    sensors.requestTemperatures();
    waterCelsius = sensors.getTempCByIndex(0);
    waterFahrenheit = (waterCelsius * 9/5) + 32;

    // powering up first probe and LED
    if (tdsStage == 0){
      digitalWrite(probe1, HIGH); // power LED identifying TDS probe1
      digitalWrite(tdsPower, HIGH); // power TDS probe1
      tdsStage = 1;
      tdsCounter = millis();
    }
    // measuring data after powered for 60 seconds
    if (tdsStage == 1 && counter - tdsCounter > 60000){
      gravityTds.setTemperature(waterCelsius);
      gravityTds.update();
      delay(300);
      tdsValue = gravityTds.getTdsValue();
      ledStart = 1;
      Serial.print("tdsValue: ");
      Serial.println(tdsValue);

      int sensorValue = analogRead(A1);
      float voltage = sensorValue * (5.0/1023.0);
      Serial.print("Voltage: ");
      Serial.println(voltage);
      if (!SD.begin(53)){
        digitalWrite(ledPin, LOW);
        Serial.println("initialization failed!");
      }
      else {
        digitalWrite(ledPin, HIGH);
        myFile = SD.open("test.txt", FILE_WRITE);
        if (myFile){
          myFile.print(waterFahrenheit);
          myFile.print("\t");
          myFile.print(tdsValue,0);
          myFile.print("\t");
          myFile.print(voltage,2);
          myFile.print("\t");
          myFile.close();
        }
      }
      tdsStage = 2;
      digitalWrite(tdsPower, LOW);
      digitalWrite(probe1, LOW);
      tdsCounter = millis();
      digitalWrite(probe2, HIGH); // power LED identifying TDS probe2
      digitalWrite(tdsPower2, HIGH); // power TDS probe2
    }
    /* measure probe2 data after being powered for 60 seconds
    and having probe1 powered down for 60 seconds */
    if (tdsStage == 2 && counter - tdsCounter > 60000){
      gravityTds2.setTemperature(waterCelsius);
      gravityTds2.update();
      delay(300);
      tdsValue2 = gravityTds2.getTdsValue();
      ledStart2 = 1;
      Serial.print("tdsValue2: ");
      Serial.println(tdsValue2);
    
      int sensorValue2 = analogRead(A4);
      float voltage2 = sensorValue2 * (5.0/1023.0);
      Serial.print("Voltage2: ");
      Serial.println(voltage2);
      if (!SD.begin(53)){
        Serial.println("initialization failed!");
        digitalWrite(ledPin, LOW);
      }
      else {
        digitalWrite(ledPin, HIGH);
        myFile = SD.open("test.txt", FILE_WRITE);
        if (myFile){
          myFile.print(tdsValue2,0);
          myFile.print("\t");
          myFile.print(voltage2,2);
          myFile.print("\t");
          myFile.close();
        }
      }
      tdsStage = 3;
      digitalWrite(tdsPower2, LOW);
      digitalWrite(probe2, LOW);
      tdsCounter = millis();
    }
    if (tdsStage == 3){
      digitalWrite(probe3, HIGH);
      gravityTds3.setTemperature(waterCelsius);
      gravityTds3.update();
      delay(300);
      tdsValue3 = gravityTds3.getTdsValue();
      if (ledStart3 == 0){
        ledStage = 0;
      }
      ledStart3 = 1;
      Serial.print("tdsValue3: ");
      Serial.println(tdsValue3);
      digitalWrite(probe3, LOW);

      int sensorValue3 = analogRead(A6);
      float voltage3 = sensorValue3 * (5.0/1023.0);
      Serial.print("Voltage3: ");
      Serial.println(voltage3);
      if (!SD.begin(53)){
        Serial.println("initialization failed!");
        digitalWrite(ledPin, LOW);
      }
      else {
        digitalWrite(ledPin, HIGH);
        myFile = SD.open("test.txt", FILE_WRITE);
        if (myFile){
          myFile.print(tdsValue3,0);
          myFile.print("\t");
          myFile.println(voltage3,2);
          myFile.close();
        }
      }
      Serial.print("Water Temp: ");
      Serial.println(waterFahrenheit);
      tdsStage = 0;
      counter2 = millis();
    }
  }

I’ve attached images of the graphed data. The first is for probe 2 which has the spikes. You’ll have to trust me that the spikes in voltage are at the same time as the spikes in TDS. Probe1 is perfect, though, despite a voltage spike. You’ll notice three plateaus in the data as I’ve changed the environment three times. First in a bath with no air stone and no roots. The second two are two different set ups with air stones and roots in two different rooms.

Breadboards are prone to poor connections - as your voltage spikes and measurement spikes coincide that's the most obvious suspect. Use proper connections or solder your wires.