Hi, I have a 4-20ma water level sensor (head pressure sensor) hooked up to an Arduino Mega and am seeing some unexpected results. The sensor is sitting at the bottom of my homes water cistern located ~ 60ft away from the home. There is a copper wire pair that runs out there for the sensor from a utility room in the house where the Arduino and power supplies are mounted. Below is a trend indicating the unexpected behavior. The voltage change between the valley and the peak on the trend is about 1 volt on the analog pin. But no water was added to the cistern in that time and usage was pretty mild, I would expect the level to slowly trend down over the month not rise and fall over a couple day period
Here is my wiring schematic, I'm using a 12V Mean Well power supply to power the 4-20ma loop, that same power supply is also powering the Arduino on the barrel jack. (lets pretend the drawing is of an Arduino Mega and not the Uno)
The Sensor is ranged 0-5M depth
I tried a 24v power supply aswell and didn't have very good luck, the sensor was very close to saturated even though the level in the cistern was only about 3M deep. It was reading ~4.8 volts at the Analog pin. Which I thought to be out to lunch, I don't think the sensor right now being powered by the 12 supply is wildly out to lunch i just expected to see a really steady level slowly decline over the month, not increase 20% ish over a couple days and then fall back and repeat.
Below is my code, I was wondering if any one had any comments or suggestions on any part of the setup on what you would do differently and also why I maybe seeing this rise and fall in the voltage reading on the analog pin when the level should have been near dead steady through that time period or if anything slowly be dropping as we use water in the house. Its weird I had an issue running the sensor part of the loop on 24V aswell, the sensor I purchased was sold as a 24V sensor.
Troubleshooting done:
- I've removed the sensor from the loop and hooked up a 4-20ma signal generator in its place and tested that section of the loop including through the resistor and there was no issue with what the Arduino kicked back. at 20ma it was 5V and at 4ma 1V and made sense through the range.
- I've played around with grounds, connecting the ground from the AC side of the power supply to the grounds on the Arduino and sensor loop, didn't seem to affect anything.
- I've tried powering the Arduino from the USB and the 12V supply, seemed to make minimal difference over the same time period as the attached trend
- Ive thought maybe temperature was effecting the reading but the cistern is buried below ground and I don't think its changing much in there, the peaks on the trend are at 10pm and 3pm, it doesnt match up with heat of the day or anything along those lines
Any criticism or advice would be welcome, Thanks!
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#include <BlynkMultiClient.h>
byte ETH_MAC[] =        {  };
#include <SPI.h>
#include <Ethernet.h>  
#include <math.h>
#include <DHT.h>
#define W5100_CS   10
#define SDCARD_CS  4
#define ANALOG_PIN A0
#define RANGE 5000 // Depth measuring range 5000mm (for water)
#define VREF 5000 // ADC's reference voltage on your Arduino,typical value:5000mV
#define CURRENT_INIT 4.00 // Current @ 0mm (uint: mA)
#define DENSITY_WATER 1  // Pure water density normalized to 1
int16_t dataVoltage;
float Val2, Val3;
static EthernetClient blynkEthernetClient;
void connectEthernet()
{
  if (Ethernet.begin(ETH_MAC, 5000L, 500L)) {
    Serial.print("Ethernet IP: ");
    Serial.println(Ethernet.localIP());
  } else if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.");
  } else if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  } else {
    Serial.println("Ethernet: DHCP configuration failed.");
  }
}
void setup()
{
  // Debug console
  Serial.begin(9600);
  // Deselect the SD card
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH);
  // Initialize Ethernet shield
  Ethernet.init(W5100_CS);
  delay(1000); // Give the Ethernet shield a second to initialize
  connectEthernet();
  // Setup Blynk
  Blynk.addClient("ETH", blynkEthernetClient, 80);
  Blynk.config(BLYNK_AUTH_TOKEN);
  pinMode(ANALOG_PIN, INPUT);
 
}
void loop()
{
dataVoltage = analogRead(ANALOG_PIN)/ 1024.0 * VREF;
Val2 = map(dataVoltage,0,5000,0,10000);
Val3 = Val2/100;
  Blynk.virtualWrite(V0, dataVoltage);
  Blynk.virtualWrite(V1, Val3);
  Blynk.run();
  Ethernet.maintain();
 delay(2000);
 
}


 
  
  
 