• 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?


    var w = new Waveform(128/* your buffer size */,{doubleBuffer:false, bits:16});
    var first = true;
    setInterval(function() {
      if (!first) {
        var myarr = w.buffer;
        // cut off first and last 2 elements
        var view = new Uint16Array(myarr.buffer, 2/*sizeof(uint16)*/*2, myarr.length-4);
        var vOut = E.getAnalogVRef() * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao
        var vZero = 0.4;
        var tCoeff = 19.5 / 1000;
        var tempinc = (vOut - vZero) / tCoeff;
        var tempinf = tempinc * (9 / 5) + 32;
        console.log("Temp in C: " + tempinc);
        console.log("Temp in F: " + tempinf);
      } else first = false;
      // start it again
      w.startInput(A0,2000 /* Samples per second */);
    }, 200);
  • 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?

  • 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?

  • Finally - you realize there will always be jitter of at least 1/4096,
    as it's a 12-bit dac, right?

    I do now :)

  • 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..

  • 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 :-/

  • 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.

  • @Gordon

    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.34653038471

    Temp in F: 106.42375469248

    Temp in C: 41.30234757616
    Temp in F: 106.34422563710

    Temp in C: 41.51487649546
    Temp in F: 106.72677769184

    Temp in C: 41.55840707979
    Temp in F: 106.80513274363

    Temp in C: 41.22329070578
    Temp in F: 106.20192327040

    Temp in C: 40.82283922169
    Temp in F: 105.48111059904

    Temp in C: 42.56068147354
    Temp in F: 108.60922665237

    Temp in C: 41.90883827124
    Temp in F: 107.43590888824

    Temp in C: 42.11013715285
    Temp in F: 107.79824687513

    Temp in C: 41.61748517983
    Temp in F: 106.91147332370

    Temp in C: 41.74432203951
    Temp in F: 107.13977967112

    Temp in C: 41.35120766480
    Temp in F: 106.43217379665

    Temp in C: 41.92938665155
    Temp in F: 107.47289597280

    Temp in C: 41.80511869209
    Temp in F: 107.24921364577

    Temp in C: 41.53246010569
    Temp in F: 106.75842819024

    Temp in C: 43.58086790083
    Temp in F: 110.44556222151

    Temp in C: 41.64385517750
    Temp in F: 106.95893931950

    Temp in C: 41.74612988558
    Temp in F: 107.14303379405

    Temp in C: 41.99619187463
    Temp in F: 107.59314537434

    Temp in C: 41.66354537383
    Temp in F: 106.99438167290

    Temp in C: 40.64783023314
    Temp in F: 105.16609441966

    Temp in C: 41.62779064556
    Temp in F: 106.93002316202

    Temp in C: 41.50174732836
    Temp in F: 106.70314519106

    Temp in C: 40.55533498825
    Temp in F: 104.99960297885

    Temp in C: 41.71990880225
    Temp in F: 107.09583584405

    Temp in C: 43.50436386718
    Temp in F: 110.30785496093

    Temp in C: 41.60630366626
    Temp in F: 106.89134659928

    Temp in C: 41.74936786270
    Temp in F: 107.14886215287

    Temp in C: 41.39160510339
    Temp in F: 106.50488918610

  • @Gordon

    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.

  • 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!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Pull unused analog pins to gnd to help minimize noise?

Posted by Avatar for d0773d @d0773d