I’ve just setup an INA219B Voltage/Current sensor on my RaspberryPi. Just thought I’d link the tutorials and libraries I used – there’s a lot of really useful info out there.
Install the following library via git: https://github.com/chrisb2/pi_ina219
sudo pip3 install pi-ina219
Follow this tutorial: https://www.rototron.info/raspberry-pi-ina219-tutorial/
- Common ground is required
- Vin – and Vin+ are attached to +, neither goes to ground
Custom Sensor Address
na = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, address=0x41)
Can be configured via the following:
Enable Low Power Between Reads
print "Voltage : %.3f V" % ina.voltage()
If you’re getting the following error:
OSError: [Errno 121] Remote I/O error
Run the following command:
i2cdetect -y 1
And check to ensure that your device is showing up on 40. If it’s a different number you’ll just need to update the address in your code e.g. (0x40, 0x41, etc.)
This is just a quick post to cover how the Duinotech hall effect sensor module (XC-4434) can be hooked up to a RaspberryPi.
The code below will output a zero when the sensor is activated by a magnet, otherwise a zero.
import RPi.GPIO as GPIO
# Define constants
BUCKET_HALL_EFFECT_SIG_PIN = 14
# Setup GPIO pins
GPIO.setup(BUCKET_HALL_EFFECT_SIG_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Important
When near a magnetic field the light on the sensor will turn on. If you’re using the sample code above, a zero will be shown when close to a magnet, otherwise a 1.
Purchased from: https://www.jaycar.com.au/arduino-compatible-hall-effect-sensor-module/p/XC4434
Spec Sheet: Z7275