Activity Forums Questions & Troubleshooting Interfacing HX710 Differential ADC with Controllino

  • Interfacing HX710 Differential ADC with Controllino

  • Jp_

    Member
    January 26, 2024 at 4:01 pm

    I’m having trouble getting my HX710 pressure sensor to work with my Controllino Mega. When I say “doesn’t work” I mean it displays the same number over and over on the screen no matter if I apply pressure or not to the sensor. The HX710 will work with my arduino uno no problem. Below is my setup with my Controllino Mega and HX710 sensor:

    VIN—–> +5v on RS485 +5v terminal

    OUT—-> A14

    SCK—–> voltage divider point connection (2.2kOhm to GND and 10kOhm to D10)

    GND—-> GND on RS485 GND terminal

    #include <Controllino.h>

    #define SCK_PIN CONTROLLINO_D10 //BLUE WIRE —> SCK

    #define SDI_PIN CONTROLLINO_A14 //WHITE WIRE —> OUT

    void setup() {

    Serial.begin(9600);

    }

    void loop() {

    // wait for the current reading to finish

    while (digitalRead(SDI_PIN)) {}

    // read 24 bits

    long result = 0;

    for (int i = 0; i < 24; i++) {

    digitalWrite(SCK_PIN, HIGH);

    digitalWrite(SCK_PIN, LOW);

    result = result << 1;

    if (digitalRead(SDI_PIN)) {

    result++;

    }

    }

    // get the 2s compliment

    result = result ^ 0x800000;

    // pulse the clock line SCK_PIN times to start the next pressure reading

    for (char i = 0; i < 3; i++) {

    digitalWrite(SCK_PIN, HIGH);

    digitalWrite(SCK_PIN, LOW);

    }

    // display pressure

    Serial.println(result);

    }

    Other things I’ve tried that did NOT work:

    Connect 1-Channel PC817 Optocoupler Isolation Module to the “OUT” on the sensor in hopes to the signal and amplify it to 24V scale

    Connect 2X 1-Channel PC817 Optocoupler Isolation Module one to “OUT” and another to “SCK” on the sensor in hopes to < the signal and amplify it to 24V scale and reduce/isolate the in to +5V without the use of voltage divider.

    Here is more where I got sample code and more on how the sensor operates: https://swharden.com/blog/2022-11-14-hx710b-arduino/

    It works just fine on my UNO with the code in the above link just not my Controllino Mega.

    • This discussion was modified 11 months ago by  Jp_.
  • Jp_

    Member
    February 1, 2024 at 12:39 pm

    For anyone else that is looking for a solution, I finally got it to work with suggestions from Pedro Marquez @ Controllino ! Thanks!

    Basically I had to use the the pin headers since they operate at 5V logic (which I didn’t realize) and only have to hook the SCK and OUT lines straight to the (digital) header pins and the 5v power from the top of the header pins. There are many libraries for the HX710 but I ended up using the above code.

    Good Luck!

Viewing 1 - 2 of 2 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now