Convert Flow Sensor analog 5v signal to +/-5 value

Hi all, I've managed to read (using the analog pin) the voltage output of a Flow Meter.

The Flow Meter has a display that shows a value between -6 and +6.

The output voltage goes from 1v to +5v and when the display shows me 0.00 (nothing flowing throug the sensor) I read analog value 620 from 0 to 1023 and 3v (using a multimeter I get 3v too).

Now, how can I convert this voltage value (or analog value) to the value that the display will show me?

Assuming that 3v is equal to 0.00 in a scale that goes from -6 to +6, of course.

Using this code:

void setup() {
  Serial.begin(9600);
}
void loop()
{

  int raw = analogRead(A0);
  float val = fmap(raw, 0, 1023, -6.0, 6.0);
  Serial.println(val); //voltage
  delay(1000);
}

float fmap(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

It gives me a 1.2 value when the sensor display is on 0.00 (because the analog read from 0 to 5, instead it should read from 1 to 5)

Thanks for any help!

Replace the "0" in your map function with 205 which represents 1V.

dlloyd:
Replace the "0" in your map function with 205 which represents 1V.

thank you! that's exactly what I needed!