Bit banging HX711 24-bit ADC with ESP8266?
Posted: Fri May 15, 2015 11:18 pm
Hi all. I am trying to figure out a way to get my esp-07 running nodeMCU to communicate with an HX711 ADC for weighing purposes. The way I used the HX711 with an Arduino was by bit banging the DOUT AND CLK pins on the board , but am not having much luck getting it to work with the implementation translated into LUA.
Page 4 of the DATA SHEET describes the process. First DT must be read LOW when SCK is LOW to know the ADC is ready to be read. I cannot seem to read DT as anything but HIGH, signifying that the ADC is not ready, and when I attempt to toggle SCK HIGH and LOW DT remains HIGH according to output in LUA. I have the ADC powered by 5v and the data lines bi-directional logic shifted between 5v and 3.3.
Here's a code snippet:
Basically DT is always HIGH so the while loop never terminates and the MCU reboots.
Is there something wrong with the speed of LUA when trying to read/toggle these data lines? I hope this makes sense, as I have only recenctly started working in this framework. I appreciate any feedback/advice regarding this situation or bit banging with NodeMCU in general.
Thanks!
Page 4 of the DATA SHEET describes the process. First DT must be read LOW when SCK is LOW to know the ADC is ready to be read. I cannot seem to read DT as anything but HIGH, signifying that the ADC is not ready, and when I attempt to toggle SCK HIGH and LOW DT remains HIGH according to output in LUA. I have the ADC powered by 5v and the data lines bi-directional logic shifted between 5v and 3.3.
Here's a code snippet:
Code: Select all
DT = 3
SCK = 4
gpio.mode(DT, gpio.INPUT)
gpio.mode(SCK, gpio.OUTPUT)
out = "" -- 24 bit word
while gpio.read(DT) == 1 do end -- wait until DT goes LOW and ADC is ready to be read
for i=1,24 do
gpio.write(SCK, gpio.HIGH)
out = out .. gpio.read(DT)
gpio.write(SCK, gpio.LOW)
end
print(tonumber(out, 2))
Basically DT is always HIGH so the while loop never terminates and the MCU reboots.
Is there something wrong with the speed of LUA when trying to read/toggle these data lines? I hope this makes sense, as I have only recenctly started working in this framework. I appreciate any feedback/advice regarding this situation or bit banging with NodeMCU in general.
Thanks!