Trouble understanding some arithmetic in my code for an EC sensor A1003v1

I tried to contact the distributor but there contact tab doesn't seem to be functional

Can some one please help me understand the values used to convert from analogInPin to analogRead

My end goal is to convert this EC value into PPM

void setup() {

const int analogInPin = A1;  
const int analogOutPin = 9; 

int sensorValue = 0;        
int outputValue = 0;       


void loop() {
sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
                                                               outputValue = map(sensorValue, 0, 1023, 0, 5000);  
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print("\t EC = ");      
                                                                Serial.println(analogRead(1)* 5.00 / 1024, 2);  

  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:

You've used code tags correctly before. How did you get it so wrong this time?
And changing the text colour to yellow is a disaster. It's unreadable.


lol yeah I noticed and im not sure how I screwed that code tag up so hard.

Where did you get that code from? It doesn't compile, so maybe the conversions are rubbish.
This bit doesn't make sense:

  outputValue = map(sensorValue, 0, 1023, 0, 5000);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

it is converting the sensor value from a range of 0-1023 to a range of 0-5000 and then outputting that value with analogWrite. The problem is that analogWrite only takes an 8-bit value on 328-based Arduinos. So which Arduino is this written for?


For NaCl solutions, EC 1 mS/cm is approx. 500 ppm.

For typical hydroponic fertiliser solutions, EC 1 mS/cm is approx 700 ppm.