Skip to content

Commit

Permalink
Change DOUT type only for ESPRESSIF boards
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonas0 committed Nov 14, 2021
1 parent 8115aee commit c646a33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/HX711.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ uint8_t shiftInSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
#define SHIFTIN_WITH_SPEED_SUPPORT(data,clock,order) shiftIn(data,clock,order)
#endif

#ifdef ARCH_ESPRESSIF
// ESP8266 doesn't read values between 0x20000 and 0x30000 when DOUT is pulled up.
#define DOUT_MODE INPUT
#else
#define DOUT_MODE INPUT_PULLUP
#endif


HX711::HX711() {
}
Expand All @@ -73,7 +80,7 @@ void HX711::begin(byte dout, byte pd_sck, byte gain) {
DOUT = dout;

pinMode(PD_SCK, OUTPUT);
pinMode(DOUT, INPUT);
pinMode(DOUT, DOUT_MODE);

set_gain(gain);
}
Expand Down

1 comment on commit c646a33

@nschurando
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduced a bug, where for non espressif board the input will not be set to pullup. Line 64 should be #if and not #ifdef.

Please sign in to comment.