Hello all,
I have an Arduino Due that controls a motor that outputs a signal in frequency. I also have two adafruit INA260 power sensor connected that reads the input and output voltage, current, and power of the system. This sensors are connected via I2C to the Arduino Due. I checked the wiring to make sure everything was wired properly and that I was not overlooking anything hardware wise. Now I am confused on why my Serial Monitor stops reading the correct voltage when I start the motor. And this error does not start the exact moment I start the motor. It takes a couple seconds of reading and then it changes. Has anyone come across something similar? The code and screenshots of the monitor is below. There are other declared variables in the code but I did not use them. I would also like to add that having some of these pinmode's declared also caused a strange reading as well.
#include <Wire.h>
#include <Adafruit_INA260.h>
// POWER ANALYZERS
Adafruit_INA260 inPwr = Adafruit_INA260();
int startButton = 24;
int decibelMeter = A0;
float inVoltage = 0;
float inCurrent = 0;
float inWatts = 0;
float decibelLevel;
int startRelays = 30;
int heater = 31;
int fan = 9;
int motorFwd = 32;
int motorRev = 33;
int startFanRelay = 34;
void setup(){
inPwr.begin(0x40);
Serial.begin(9600);
//INPUTS
pinMode(startButton, INPUT);
pinMode(decibelMeter, INPUT);
//OUTPUTS
pinMode(startRelays, OUTPUT);
pinMode(heater, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(motorFwd, OUTPUT);
pinMode(motorRev, OUTPUT);
pinMode(startFanRelay, OUTPUT);
}
void loop(){
// NOISE LEVEL
decibelLevel = analogRead(decibelMeter);
decibelLevel = (decibelLevel/1023) * 50;
// START RELAYS
if(digitalRead(startButton) == 1){
digitalWrite(startRelays, HIGH);
digitalWrite(heater, HIGH);
analogWrite(fan, 100);
digitalWrite(motorFwd, HIGH);
digitalWrite(motorRev, LOW);
digitalWrite(startFanRelay, HIGH);
}
else{
digitalWrite(startRelays, LOW);
digitalWrite(heater, LOW);
digitalWrite(fan, HIGH);
digitalWrite(motorRev, HIGH);
digitalWrite(motorFwd, LOW);
digitalWrite(startFanRelay, LOW);
}
// INPUT POWER
inVoltage = inPwr.readBusVoltage()/1000;// V
inCurrent = inPwr.readCurrent()/1000;// A
inWatts = (inVoltage * inCurrent);// W
Serial.print("Voltage In: ");
Serial.print(inVoltage);
Serial.println("V");
Serial.print("Current In: ");
Serial.print(inCurrent);
Serial.println("A");
Serial.print("Power In: ");
Serial.print(inWatts);
Serial.println("W");
Serial.println();
}