-
• #2
Also, out of curiousity I cut the old leads off the cable to strip new leads since the leads looked dirty and corroded. I noticed a red, black, white, a bare wire and the foil shield. What do I hook the bare wire too? Or is that wire a rip cord?
-
• #3
A bypass cap goes between supply and ground, right next to the device in question.
Sometimes people also put a small cap between an analog input and ground, to smooth out noise; this isn't appropriate for all sources of analog input, though.
Finally - you realize there will always be jitter of at least 1/4096, as it's a 12-bit dac, right?
-
• #4
Finally - you realize there will always be jitter of at least 1/4096,
as it's a 12-bit dac, right?I do now :)
-
• #5
The bare wire is the electrical connection to the shield. You should connect it to signal GND at one end (the Espruino) and leave it unconnected at the other end.
To reduce noise on the analog inputs you could add an RC low pass filter. A resistor in series with the wire and a ceramic capacitor from the analog input to signal GND.
To filter out noise and get more stable readings I use to collect a series of at least five readings, throw out the two highest and the two lowest readings and use the remaining reading (the median value). There will always be the jitter caused by the 12 bit ADC, but you can reduce it by taking for example eight readings, throwing out the two highest and two lowest values and calculating the average of the remaining four values.. -
• #6
I made the leads as short as possible and I am getting better readings without using a bypass cap or a RC low pass filter. I will need to go to frys electronics tomorrow to pickup some caps and resisters.
I freaking hate analog :-/
-
• #7
Another thing to add -
E.getAnalogVRef()
is just another ADC reading internally, so even though you're taking a bunch of readings for the temp, you'll still have the jitter caused by changes in the values from that.As you're not expecting that to change much, you could just keep some kind of running average of it:
var vRef = E.getAnalogVRef(); //... vRef = vRef*0.95 + E.getAnalogVRef()*0.05; var vOut = vRef * E.sum(view)/(view.length*65536);
You could also experiment with just using a constant value instead, like
3.3
. -
• #8
As you're not expecting that to change much, you could just keep some
kind of running average of it:Right, I will expect the temperature of my aquaponics fish tank to be: 72-74 degrees F.
What I am afraid of is, turning the water heater on or off when its not supposed to due to the fluctuations and then in-turn causing the heater to break :-/
I'm getting values between 104F - 110F(Hot water demo)
The values that I am getting(using hot water as a demo):
Temp in F: 105.52142546252
Temp in C: 41.34653038471Temp in F: 106.42375469248
Temp in C: 41.30234757616
Temp in F: 106.34422563710Temp in C: 41.51487649546
Temp in F: 106.72677769184Temp in C: 41.55840707979
Temp in F: 106.80513274363Temp in C: 41.22329070578
Temp in F: 106.20192327040Temp in C: 40.82283922169
Temp in F: 105.48111059904Temp in C: 42.56068147354
Temp in F: 108.60922665237Temp in C: 41.90883827124
Temp in F: 107.43590888824Temp in C: 42.11013715285
Temp in F: 107.79824687513Temp in C: 41.61748517983
Temp in F: 106.91147332370Temp in C: 41.74432203951
Temp in F: 107.13977967112Temp in C: 41.35120766480
Temp in F: 106.43217379665Temp in C: 41.92938665155
Temp in F: 107.47289597280Temp in C: 41.80511869209
Temp in F: 107.24921364577Temp in C: 41.53246010569
Temp in F: 106.75842819024Temp in C: 43.58086790083
Temp in F: 110.44556222151Temp in C: 41.64385517750
Temp in F: 106.95893931950Temp in C: 41.74612988558
Temp in F: 107.14303379405Temp in C: 41.99619187463
Temp in F: 107.59314537434Temp in C: 41.66354537383
Temp in F: 106.99438167290Temp in C: 40.64783023314
Temp in F: 105.16609441966Temp in C: 41.62779064556
Temp in F: 106.93002316202Temp in C: 41.50174732836
Temp in F: 106.70314519106Temp in C: 40.55533498825
Temp in F: 104.99960297885Temp in C: 41.71990880225
Temp in F: 107.09583584405Temp in C: 43.50436386718
Temp in F: 110.30785496093Temp in C: 41.60630366626
Temp in F: 106.89134659928Temp in C: 41.74936786270
Temp in F: 107.14886215287Temp in C: 41.39160510339
Temp in F: 106.50488918610 -
• #9
Well, using 3.3 seems to be steady. My water temp, as it is much cooler now, is staying at a 95 - 96F range.
I
console.log(E.getAnalogVRef());
and the value fluctuates. Now I understand why I was getting those fluctuations as I mentioned earlier. I though getAnalogVRef() was a constant 3.3v, OOOOPS. -
• #10
Great! I'll update the docs on it so others don't fall into the same trap :)
It's actually reading the value of an internal (1.6v?) voltage reference with the ADC to give you that value, so unfortunately it's just as noisy as everything else!
I believe I have done everything I can in software to minimize the temp fluctuations. Does anyone have any ideas obout how to minimize analog noise? I did search Google and multiple people recommended to pull all the unused analog pins to gnd. Also people recommended to use a 0.1 bypass cap. However Im not sure where to place the cap..? Does anyone have recommondations?
Code: