카테고리 없음
아두이노 우노 슬립모드 #3
오징어땅콩2
2021. 1. 24. 22:42
반응형
다음으로 찾은 모듈은 INA219이다.
생긴것은 ACS712하고 비슷하고 핀배열도 거의 비슷하다.
단 한가지 차이는 이전 ACS712가 ADC로 측정 했다면 INA219는 I2C통신 방식으로 즉정한다.
자세한 내용은 모르고 일단 Adafruit_INA219라이브러리 설치로 해결 했다.
github.com/adafruit/Adafruit_INA219
adafruit/Adafruit_INA219
INA219 Current Sensor. Contribute to adafruit/Adafruit_INA219 development by creating an account on GitHub.
github.com
대략적으로 측정한 결과는 아두이노 우노와 슬립모드일때와 아닐떄 차이는 5mA정도 차이가 난다.
5mA가 별것 아닐수도 있고 큰값일수도 있다.
본인이 판단하기는 어렵기 때문에 각자판단하기로 하자.
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup(void)
{
Serial.begin(9600);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
Serial.println("Hello!");
// Initialize the INA219.
// By default the initialization will use the largest range (32V, 2A). However
// you can call a setCalibration function to change this range (see comments).
if (! ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) { delay(10); }
}
// To use a slightly lower 32V, 1A range (higher precision on amps):
//ina219.setCalibration_32V_1A();
// Or to use a lower 16V, 400mA range (higher precision on volts and amps):
//ina219.setCalibration_16V_400mA();
Serial.println("Measuring voltage and current with INA219 ...");
}
void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
float power_mW = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");
delay(2000);
}