Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSingleConversionRaw() not working #25

Closed
jpk73 opened this issue Apr 4, 2019 · 2 comments
Closed

getSingleConversionRaw() not working #25

jpk73 opened this issue Apr 4, 2019 · 2 comments

Comments

@jpk73
Copy link

jpk73 commented Apr 4, 2019

Hi! I am successfully using your lib with an ADS1231, but I can't get getSingleConversionRaw() to work, it seems it is missing in the cpp file...? Regards and Thanks!!!

@jpk73
Copy link
Author

jpk73 commented Apr 4, 2019

Also getSingleConversion() is missing...

@olkal
Copy link
Owner

olkal commented Apr 25, 2019

Hi, sorry for the delayed response...
getSingleConversionRaw() and getSingleConversion() was not working as intended and was therefore removed. I just forgot to remove them in the .h file, I will fix that.
If you need single conversion you can use samples = 1 in the config file.
Raw data conversion is not supported at the time, but you can try the code below.

//HX711 conversion, raw data

int doutPin = 2;
int sckPin = 3;

unsigned long conversionData;
unsigned long t;

unsigned long getConversionData() {
  unsigned long data = 0;
  byte dout;
  for (uint8_t i = 0; i < (24 + 1); i++) { //read 24 bit data + set gain and start next conversion
    delayMicroseconds(1);
    digitalWrite(sckPin, 1);
    delayMicroseconds(1);
    if (i < (24)) {
      dout = digitalRead(doutPin);
      data = data << 1;
      if (dout) {
        data++;
      }
    }
    digitalWrite(sckPin, 0);
  }
  data = data ^ 0x800000; // if out of range (min), change to 0
  return data;
}

void setup() {
  Serial.begin(9600);
  pinMode(doutPin, INPUT);
  pinMode(sckPin, OUTPUT);
}

void loop() {
  byte dout = digitalRead(doutPin);
  if (dout == 0) { //dout low, new conversion ready
    conversionData = getConversionData();
    Serial.println(conversionData);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants