Analog to Digital convert

I have a temperature and humidity sensor that generates two 4-20mA signals. Through a resistor I convert/read the signal into Volts.
I measure the signal in Volts with a photon with the following conversion:
sensorU = analogRead (A0);
voltU = (sensorU / 4095) * 3.3;
Photon is powered by USB (pc), if I change pc from a workstation to a laptop the values change.
Does anyone have a suggestion or can explain why?
Thanks Valentino

Have you checked the 3.3V reference between the two scenarios?
BTW, you should divide by 4095.0 to force a float division (unless your sensorU already is a float).
And to reduce rounding errors Iā€™d even do it this way

  voltU = (3.3 * sensorU) / 4095.0;
2 Likes

Hi ScruffR
Thanks for the reply. Now I notice that the cables I use for the breadboard connections and the sensors give some measurement problems. Unfortunately in the next days I am not at home I see anyway in a week to give an answer on the suggested measure. A last question: if on the pin of the photon 3V3 I measure a higher voltage for example 3.4 should I insert this or do I leave 3.3?
Thanks and have a nice day Valentino

The voltage of the 3v3 pin gives you the reference used for any ADC reading.
In order to get a correct reading your calculation should be based on the actual voltage and not the guestimated 3.3V

The voltage of the 3v3 pin gives you the reference used for any ADC reading.
In order to get a correct reading your calculation should be based on the actual voltage and not the guestimated 3.3V

Not sure why you re-posted exactly the same text I wrote in my previous post :confused:

Is there another question about that?

No thank I do mistake thanks and sorry
Valentino

Hello regarding this post I made a print with the connections through soldered wires now the differences on the measures are stable
Thank you for your answers Valentino

1 Like