You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Thanks - that is interesting... The 2x difference in readings may be because the gain is set differently - the number of clocks sent specifies the gain and channel to be used for the next reading. I have no idea what 24 clocks does as it's not in the datasheet, but 25 clocks would be 128x gain and 27 clocks is 64x gain. Of course it could be to do with the serial data as well...

    What I'm doing with 0b10101010 is I'm using the data line as a clock, since if I used the actual clock line it'd only be able to output a multiple of 8 clocks.

    Sadly the JS execution speed isn't fast enough to simply clock the data in using JS code at the moment (as if it's too slow the ADC will just reset itself).

    Could you try copying the module code out of https://github.com/espruino/EspruinoDocs­/blob/master/devices/HX711.js into the IDE and changing:

    function ex(x) { return ((x&128)?8:0)|((x&32)?4:0)|((x&8)?2:0)|(­(x&2)?1:0); }
    

    to

    function ex(x) { return ((x&64)?8:0)|((x&16)?4:0)|((x&4)?2:0)|((­x&1)?1:0); }
    

    That'll change the point at which the data line is sampled (as it might have been read too quickly).

    Maybe you could also print readRaw().toString(2) for your and my code as seeing what binary data is received might flag up what's wrong with my code.

About

Avatar for Gordon @Gordon started