@beardedinventor: Can you help me with the hardware hookup on your blog post. I can not find any documentation on the Aria board you used in the blog. I am using an Imp002 EVB(https://electricimp.com/docs/hardware/imp002evb/), and I do not know which pins of the EVB to connect the HX711 for the SPI-like data transfer to work. I assume I have to replace spi257 with spi189 since Pin 2 is also connected to the Red led on the board. I am not sure about the clk and the data pins though. Any help in this matter would be appreciated.

@MobileWave, you can still use spi257, but you may see the LED flash during pin 2's use. Looking at the code, I’d say you can connect the EVB using the same pins as the Aria-based example, ie. 1, 2 and 7.

Hi Guys,I have a follow up to the code provided in the blog post. I can see in the read_weight function that the imp is pulsing the clk pin 24 times and converting the 24 bit data received from HX711 to a decimal number. This works fine when the output from HX711 is positive. How should I modify it to handle 2's complemented negative output from HX711. Typical Arduino libraries XOR the leading bit of the 24 bit output with 1 and handle the data in an unsigned integer. Any help would be appreciated.

You should be seeing 25 pulses. I actually think there might be a bug in my original code as rereading the datasheet you need to do 25 pulses but only the first 24 produce valid data. I think it should be something like:` for(local i = 23; i >= 0; i--){ sw(PULSE); val += dr() ? math.pow(2, i) : 0; } sw(PULSE); // Extra pulse to reset DOUT

I also included a line which sign extends val to make it a 32-bit signed number. Since the sign bit is at bit 24 rather than 32, we shift it up by 8 to put it into the sign position then we shift it back down by 8 and Squirrel automatically sign extends for us so the upper 8 bits will match the sign bit. This yields a properly signed number. Here was my test case:

Thanks. I am trying to run this code and will tweak to adjust the gain and offset. In the meanwhile can you confirm that I have to typecast the variable val as int to get but shifting to work. I tried to run your code as is and was getting an error that was fixed by modifying to the following code

function read_weight(){ //This is bit banged so we //bind calls to local variables //to speed things up. //Takes about 2.2mS to do the read local sw = spi.write.bindenv(spi); local dr = data.read.bindenv(data); local val = 0;

Guys. Thanks for the response. I had bought two electric scales from Ebay and had pulled a load cell out of one of the electric scales for this experiment. After fixing the code as suggested by @brandon, and empirically finding out the values of offset and gain, I am measuring the same weight with the electric scale and the load cell + hx711 + electric imp.

Hey , I was trying to port the library from dfrobot.com/image/data/SEN0160/Arduino%20sample%20code.zipThis is the code I have converted so far , I am using pin257(spi) and pin 1(data) ` const uint8_t pindout; const uint8_t pinslk; long _offset; float _scale; Hx711(uint8_t pin_din, uint8_t pin_slk);

Thanks, Hugo. For some reason, perhaps my not using a trailing slash, it wasn't finding it for me. I saw the gist still there, but I figured perhaps there as a repo outside the bbharris user. Reading the run-down (at least for a coding neophyte like myself), it makes more sense what the pictly stuff was doing in there. I can flip it out for a simple https put to a web server for my needs.