Closed r3v1 closed 4 months ago
At the end, it wall all about wrong gpio init. This is the original implementation:
esp_err_t hx711_init(hx711_t *dev)
{
CHECK_ARG(dev);
CHECK(gpio_set_direction(dev->dout, GPIO_MODE_INPUT));
CHECK(gpio_set_direction(dev->pd_sck, GPIO_MODE_OUTPUT));
CHECK(hx711_power_down(dev, false));
return hx711_set_gain(dev, dev->gain);
}
But this initialitation works better:
esp_err_t hx711_init(hx711_t *dev)
{
CHECK_ARG(dev);
// CHECK(gpio_set_direction(dev->dout, GPIO_MODE_INPUT));
// CHECK(gpio_set_direction(dev->pd_sck, GPIO_MODE_OUTPUT));
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL<<dev->pd_sck);
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
gpio_config(&io_conf);
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.pin_bit_mask = (1ULL<<dev->dout);
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 0;
gpio_config(&io_conf);
CHECK(hx711_power_down(dev, false));
return hx711_set_gain(dev, dev->gain);
}
Should I pull request?
Should I pull request?
No, thanks!
The issue
I've been using this HX711 Arduino library without any issues, but now I'm moving to this repo, and the readings are always 0 with any change. In the Arduino library the weights are almost perfect.
I tried to mimic the behaviour of the HX711 component but with no fortune.
I run the HX711 example, both reading average data and raw data, and no one can.
Which SDK are you using?
esp-idf
Which version of SDK are you using?
0.9.4
Which build target have you used?
Component causing the issue
hx711
Anything in the logs that might be useful for us?
Additional information or context
No response
Confirmation