Current Sensor YHDC HSTS21 400A Output 2.5±0.625V Hall Split

I have connected this sensor to the current pin of pixhawk 6c

https://www.aliexpress.com/item/32656614775.html

Datasheet:

I set up it like this:

BATT_AMP_OFFSET,2.494
BATT_AMP_PERVLT,640

if I set BATT_AMP_OFFSET,2.5 it shows me negative consumption during IDLE (motors disarmed, only radio and FC are powered on).

640 I got : 0.625V - 400A, so 1V → 640A

My results:
test 1:
Consumption displayed by QGC: 11.3Ah,
Battery charged to full - 13.7Ah

test 2
Consumption displayed by QGC: 31.2Ah,
Battery charged to full - 37.5Ah

Questions: is it valid setup, or I need some adapter to translate and provide another measurement range to the FC? If it is valid, how properly adjust to make mesured consumption in Ah and charging information Ah more or less similar?

ChatGPT regarding this datatsheet: ChatGPT - HSTS21 Current Sensor

DO NOT use ChatGPT for technical documentation, it is not reliable.

Pixhawk 6c current input is not 5V tolerant. You need to use voltage divider to bring the sensor output down to 3.3V max.

Analog sensor reading are fairly sensitive to correct 0V (ground) reference.

1 Like

but 2.5+0.625 = 3.125V - it is less than 3.3V,
How properly connect/adgut this sensor based on what we see in the datasheet? do you think it shifts zero point because of 5.2V instead of 5.0V?

The sensor may or may not be ratiometric (I can’t see the datasheet).
You really don’t want the sensor outputting excessive voltage to the FC input pin. At a minimum you should have a clamping diode and possibly a resistor (depending on sourcing capability of the sensor (how much current it can output to.get the desired output voltage).

Pixhawk architecture with current sensor and power ground at the same spot is not ideal but if you avoid long section of ground wire carrying higher current it should be ok.

You really don’t want the sensor outputting excessive voltage to the FC input pin

Why do you think it could be excessive?

Leave the ref pin open.

Build a voltage divider with 2 8K2 resistors. Connect the voltage divider output to the FC current (was voltage) input.

Edited to fix a typo :wink:

1 Like

@amilcarlucas I need a current sensor, so why “to the FC voltage input”? And why to divide output voltage if it is no more than 3.3V (2.5+0.625 = 3.125V)?

I guess the main question is about how to set param BATT_AMP_OFFSET

### BATT_AMP_OFFSET (AP_BattMonitor_Analog): AMP offset[¶](https://ardupilot.org/copter/docs/parameters.html#batt-amp-offset-ap-battmonitor-analog-amp-offset)

Voltage offset at zero current on current sensor for Analog Sensors. For Synthetic Current sensor, this offset is the zero throttle system current and is added to the calculated throttle base current.

Units: volt

"zero throttle system current " - means “armed motors spin on zero throttle” or not?

So it is probably not 2.5V middle point for the HST21 sensor as in this case it displays me negative current and “charging battery” on disarmed system. I guess, it should be set differently. How exactly?

You already did it the way I would do it on your first post.

But you were not happy with the results so I offered a way to lower the offset.

1 Like

Motors do not spin. Calibrate/ configure it at that point.

1 Like