Hi,
I'm really stuck so any help would be really really appreciated!
The idea of the code is to switch between two TDS sensors (What is tds meter - DFROBOT TDS Meter Sensor With Arduino | DFRobot Electronics) to measure the TDS level before and after I put a salt solution into a pipe. If you have both TDS sensors powered at the same time, they affect each other's readings so I'm trying to get it so that they are powered separately using a relay.
I am using a double relay where the RY-VCC is powered by a separate breadboard (https://www.amazon.co.uk/gp/product/B07DK4RX8R/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1) and the ground is also from this power supply.
The Arduino 5V is connected to the VCC on the relay and also powers both TDS sensors and two temperature sensors (Gravity: Waterproof DS18B20 Temperature Sensor Kit-DFRobot). So the circuit goes Arduino 5V power, TDS in series, TDS in series, 2x temperature sensors in parallel. A breadboard schematic is included if that helps.
The problem is that the Arduino seems to disconnect often immediately after the code is uploaded, or if it does work it does not follow any pattern. I isolated just the relay switching part as shown below and even this simple pattern is not reflected in the switching of the relays. Sometimes one side turns on and off three times in a row, sometimes they alternate as expected and sometimes there is no delay between each side turning on and off.
PLEASE HELP I'M LOSING THE PLOT
const int A = 3;
const int B = 4;
void setup() {
Serial.println("setup");
Serial.begin(115200);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
}
void loop() {
digitalWrite(B, HIGH);
Serial.print("A on");
delay(1000);
digitalWrite(A, LOW);
Serial.print("B LOW");
//Serial.println("HIGH");
delay(1000);
digitalWrite(A, HIGH);
delay(1000);
digitalWrite(B, LOW);
Serial.println("b HIGH, A LOW");
delay(1000);
}
