mvrk33 / AgroBot

5 stars 1 forks source link

Power Sensors #4

Open mvrk33 opened 5 months ago

mvrk33 commented 5 months ago
gurukavya123 commented 5 months ago

VOLTAGE SENSOR: Voltage Sensor Module 25V voltage sensor measures the voltage. range=0 to 25V. Voltage Detection Range (V): 0.02445 to 25 The Voltage Sensor Module 25V allows you to use the analog input of a microcontroller to monitor voltages much higher than it capable of sensing. This module is based on the principle of resistive voltage divider design. For example with a 0-5V analog input range, you are able to measure a voltage up to 25V. This voltage sensor module also includes convenient screw terminals for easy and secure connection of a wire.

poojithanagasarapu commented 5 months ago

INA3221

Three-channel, high-side current and bus voltage monitor with an I2C- and SMBUS-compatible interface. Monitors both shunt voltage drops and bus supply voltages, in addition to having programmable conversion times and averaging modes for these signals. The INA3221 offers both critical and warning alerts to detect multiple programmable out-of-range conditions for each channel. The INA3221 senses current on buses that can vary from 0 V to 26 V. The device is powered from a single 2.7-V to 5.5-V supply, and draws 350 µA (typ) of supply current. The INA3221 is specified over the operating temperature range of –40°C to +125°C. The I2C- and SMBUS-compatible interface features four programmable addresses.

gurukavya123 commented 3 months ago

INA219

https://github.com/mvrk33/AgroBot/assets/131512821/66dc21b7-8e91-4c3c-9190-9dcd042c3f9a

When interfacing an INA219 sensor with an RPi4, the displayed output values are incorrect, showing random readings such as 0V or 2V. Additionally, even without supplying power to the circuit, it displays random voltage values. This behavior suggests a short circuit between Vin+ and Vin- when power is applied. Note: Common ground issue (Refer the below Circuit diagram) Before we connected the ground pin of INA219 sensor with Ardunio and Source ground pin to load ground pin differently. But when we gave common ground as per the circuit diagram it was interfaced correctly. Hence, we got Correct output.

gurukavya123 commented 3 months ago

INA219

MobaXterm

Commands to be executed

sudo apt-get install  -pip
sudo pip install adafruit-circuitpython-ina219

To install Rpi.GPIO run the following command

sudo pip install RPi.GPIO

To install i2c tools

sudo apt install i2c-tools

To detect i2c run the following command

i2cdetect -y 1

To open a file run the following command

sudo nano code.py

Insert the following code

from ina219 import INA219
from ina219 import DeviceRangeError
from time import sleep

SHUNT_OHMS = 0.1
MAX_EXPECTED_AMPS = 0.2

def read():
    ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS ,address=0x40)
    ina.configure(ina.RANGE_16V)

    print("Bus Voltage: %.3f V" % ina.voltage())
    try:
        print("Bus Current: %.3f mA" % ina.current())
        print("Power: %.3f mW" % ina.power())
        print("Shunt voltage: %.3f mV" % ina.shunt_voltage())
    except DeviceRangeError as e:
        # Current out of device range with specified shunt resistor
        print(e)

while 1:
    read()
    sleep(2)

OUTPUT

Before giving supply

WhatsApp Image 2024-03-30 at 16 07 00_a444c6d8

After giving supply

WhatsApp Image 2024-03-30 at 16 08 35_dcc8831c

CIRCUIT DIAGRAM

WhatsApp Image 2024-03-31 at 11 49 48_6757b380

DEMO VIDEO

https://github.com/mvrk33/AgroBot/assets/131512821/cb147bc1-85ed-4e47-b592-db030405a8bc