Thanks thetahsk and derez for your answer
I have already developed my custom board with hx711 and arduino mini, connected serially with the rapberry.
I meant the only HX711 module connected directly to the rapsberry gpio and managed with B4J
Good day everyone
Based on the Pi4J lib you can use this library
https://www.b4x.com/android/forum/threads/iot-jpi4j-raspberry-pi-gpio-controller.37493/#content
long getValue()
{
byte data[3];
while (digitalRead(DOUT))
;
for (byte j = 3; j--;)
{
for (char i = 8; i--;)
{
digitalWrite(SCK, HIGH);
bitWrite(data[j], i, digitalRead(DOUT));
digitalWrite(SCK, LOW);
}
}
digitalWrite(SCK, HIGH);
digitalWrite(SCK, LOW);
data[2] ^= 0x80;
return ((uint32_t) data[2] << 16) | ((uint32_t) data[1] << 8)
| (uint32_t) data[0] << 1;
}
Sub Capture
datoconv.Initialize
Dim i, y As Int
Dim b(3) As Byte
For y = 2 To 0 Step -1
For i = 1 To 8
Ck.State = True
If Dout.State = False Then
datoconv.Append("0")
Else
datoconv.Append("1")
End If
Ck.State = False
Next
b(y) = Bit.ParseInt(datoconv, 2)
datoconv.Initialize
Next
Ck.State = True
Ck.State = False
b(2) = Bit.Xor(b(2), 0x80)
Dim result As Int = Bit.Or(Bit.ShiftLeft(b(2),16), Bit.ShiftLeft(b(1), 8))
result = Bit.Or(result, Bit.ShiftLeft(b(0), 1))
CallSubDelayed2(mTarget, "VisDato", result)
Log(b(2) & " " & b(1) & " " & b(0))
Sleep(10)
End Sub
datoconv.Initialize
Dim i As Int
For i = 1 To 24
Ck.State = True
If Dout.State = False Then
datoconv.Append("0")
Else
datoconv.Append("1")
End If
Ck.State = False
Next
Ck.State = True
Ck.State = False
CallSubDelayed2(mTarget, "VisDato", Bit.Parseint(datoconv.ToString, 2))
Sleep(10)
Sub Capture As Int
Dim count, i As Int
For i = 1 To 24
Ck.State = True
count = Bit.ShiftLeft(count, 1)
Ck.State = False
If Dout.State Then count = count + 1
Next
count = Bit.Xor(count, 0x800000)
Ck.State = True
Ck.State = False
Ck.State = True
Ck.State = False
Return count
End Sub
Sub Capture As Int
Dim i As Int
datoconv.Initialize
For i = 1 To 24
Ck.State = True
If Dout.State = False Then
datoconv.Append(0)
Else
datoconv.Append(1)
End If
Ck.State = False
Next
Dim result As Int = Bit.ParseInt(datoconv, 2)
result = Bit.Xor(result, 0x800000)
Ck.State = True
Ck.State = False
Ck.State = True
Ck.State = False
Return result
End Sub
It will not be faster with Java.but i think that the direct use of B4J is not appropriate,
Hi ErelWhy not use an Arduino for this? You can develop with B4R
I have already developed my custom board with hx711 and arduino mini, connected serially with the rapberry.