Skip to content

Commit 2b1f907

Browse files
authored
[Hx711] Improvements in documentation (#494)
1 parent b3a40c9 commit 2b1f907

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

devices/Hx711/Hx711.Sample/Program.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@
1111
// When connecting to an ESP32 device, need to configure the SPI GPIOs
1212
// The following mapping is used in order to connect the WEIGTH module
1313
// to a M5Core device using the Grove port A
14-
// MOSI: connects to Grove pin 1 (PD_SCK)
15-
// MISO: connects to Grove pin 2 (DOUT)
14+
// For more details on the connections, please refer to the following
15+
// https://github.com/nanoframework/nanoFramework.IoT.Device/tree/develop/devices/Hx711#signals-and-connections
16+
// MOSI: connects to WEIGHT Grove pin 2 (PD_SCK)
17+
// MISO: connects to WEIGHT Grove pin 1 (DOUT)
1618
// CLOCK: connect to any free port as it's not used at all
1719
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
1820
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
1921
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
2022

2123
// setup SPI connection settings
2224
// the clock value was adjusted in order to get the typical duration expected by the PD_SCK ~1us
23-
var spisettings = new SpiConnectionSettings(1, 19)
25+
var spisettings = new SpiConnectionSettings(1)
2426
{
2527
ClockFrequency = Scale.DefaultClockFrequency
2628
};

devices/Hx711/README.md

+25-4
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,48 @@ This is a library to interact with the Hx711 ADC. This is conveniently assembled
1111

1212
## Usage
1313

14-
**Important**: make sure you setup the SPI pins for ESP32 before creating the `Scale`. For this, make sure you install the `nanoFramework.Hardware.ESP32` NuGet:
14+
### Signals and connections
15+
16+
Check the connections for the WEIGTH module at the [product page](https://docs.m5stack.com/en/unit/weight).
17+
From the schematic one can see these signals:
18+
19+
* DOUT: Grove connector pin 1
20+
* PDSCK: Grove connector pin 2
21+
22+
Our code is using SPI to generate the clock signals and read back data from the HX711, so the connections need to match the SPI signals like this:
23+
24+
* MOSI -> PDSCK
25+
* MISO -> DOUT
26+
27+
SPI clock is not used so feel free to route to an unused GPIO.
28+
There is also no need for the CS signal so no need to define a pin for it.
29+
30+
**Important**: make sure you setup the SPI pins for ESP32 before creating the `Scale`. For this, make sure you install the `nanoFramework.Hardware.ESP32` NuGet.
1531

1632
```csharp
1733
///////////////////////////////////////////////////////////////////////
1834
// When connecting to an ESP32 device, need to configure the SPI GPIOs
1935
// The following mapping is used in order to connect the WEIGTH module
2036
// to a M5Core device using the Grove port A
21-
// MOSI: connects to Grove pin 1
22-
// MISO: connects to Grove pin 2
37+
// MOSI: connects to WEIGHT Grove pin 2
38+
// MISO: connects to WEIGHT Grove pin 1
2339
// CLOCK: connect to any free port as it's not used at all
2440
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
2541
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
2642
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
2743
```
2844

45+
> **Warning**
46+
> Make sure to follow the instructions above. At first glance they can look contrary to the naming of the signals and schematics in M5Stack documentation. That's because the GROVE connectors are meant to use I2C and their implementation of the driver is different from ours.
47+
2948
For other devices, like STM32, please make sure you're using the pins for the UART you want to use.
3049

50+
### Configuring SPI
51+
3152
```csharp
3253
// setup SPI connection settings
3354
// the clock value was adjusted in order to get the typical duration expected by the PD_SCK ~1us
34-
var spisettings = new SpiConnectionSettings(1, 19)
55+
var spisettings = new SpiConnectionSettings(1)
3556
{
3657
ClockFrequency = Scale.DefaultClockFrequency
3758
};

0 commit comments

Comments
 (0)