Hallo,
Ik heb een vreemd probleem.
Ik het een programma gemaakt om 4 power sensoren (INA219) uit te lezen. Dit werkt goed op een Uno. Alleen omdat het straks op een Due moet draaien had ik hetzelfde programma op een Due gezet en dan werkt deze maar een paar seconden.
Ik kom er niet uit en heb geen idee waar ik dit moet zoeken.
Moet je voor I2C nog iets extra's doen op een Due?
Hieronder staat me code:
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 SensorU24; //0x40
Adafruit_INA219 SensorU12(0x41);
Adafruit_INA219 SensorU5(0x44);
Adafruit_INA219 SensorU3(0x45);
void setup(void)
{
Serial.begin(115200);
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 (! SensorU24.begin()) {
Serial.println("Failed to find SensorU24");
}
if (! SensorU12.begin()) {
Serial.println("Failed to find SensorU12");
}
if (! SensorU5.begin()) {
Serial.println("Failed to find SensorU5");
}
if (! SensorU3.begin()) {
Serial.println("Failed to find SensorU3");
}
// 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 U24_shuntvoltage = 0;
float U24_busvoltage = 0;
float U24_current_mA = 0;
float U24_loadvoltage = 0;
float U24_power_mW = 0;
float U12_shuntvoltage = 0;
float U12_busvoltage = 0;
float U12_current_mA = 0;
float U12_loadvoltage = 0;
float U12_power_mW = 0;
float U5_shuntvoltage = 0;
float U5_busvoltage = 0;
float U5_current_mA = 0;
float U5_loadvoltage = 0;
float U5_power_mW = 0;
float U3_shuntvoltage = 0;
float U3_busvoltage = 0;
float U3_current_mA = 0;
float U3_loadvoltage = 0;
float U3_power_mW = 0;
U24_shuntvoltage = SensorU24.getShuntVoltage_mV();
U24_busvoltage = SensorU24.getBusVoltage_V();
U24_current_mA = SensorU24.getCurrent_mA();
U24_power_mW = SensorU24.getPower_mW();
U24_loadvoltage = U24_busvoltage + (U24_shuntvoltage / 1000);
U12_shuntvoltage = SensorU12.getShuntVoltage_mV();
U12_busvoltage = SensorU12.getBusVoltage_V();
U12_current_mA = SensorU12.getCurrent_mA();
U12_power_mW = SensorU12.getPower_mW();
U12_loadvoltage = U12_busvoltage + (U12_shuntvoltage / 1000);
U5_shuntvoltage = SensorU5.getShuntVoltage_mV();
U5_busvoltage = SensorU5.getBusVoltage_V();
U5_current_mA = SensorU5.getCurrent_mA();
U5_power_mW = SensorU5.getPower_mW();
U5_loadvoltage = U5_busvoltage + (U5_shuntvoltage / 1000);
U3_shuntvoltage = SensorU3.getShuntVoltage_mV();
U3_busvoltage = SensorU3.getBusVoltage_V();
U3_current_mA = SensorU3.getCurrent_mA();
U3_power_mW = SensorU3.getPower_mW();
U3_loadvoltage = U3_busvoltage + (U3_shuntvoltage / 1000);
Serial.println("===========================================================");
Serial.println("POWER 24V: ");
Serial.print("Bus Voltage: "); Serial.print(U24_busvoltage); Serial.println(" V ");
Serial.print("Shunt Voltage: "); Serial.print(U24_shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(U24_loadvoltage); Serial.println(" V ");
Serial.print("Current: "); Serial.print(U24_current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(U24_power_mW); Serial.println(" mW");
Serial.println("===========================================================");
Serial.println("POWER 12V: ");
Serial.print("Bus Voltage: "); Serial.print(U12_busvoltage); Serial.println(" V ");
Serial.print("Shunt Voltage: "); Serial.print(U12_shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(U12_loadvoltage); Serial.println(" V ");
Serial.print("Current: "); Serial.print(U12_current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(U12_power_mW); Serial.println(" mW");
Serial.println("===========================================================");
Serial.println("POWER 5V: ");
Serial.print("Bus Voltage: "); Serial.print(U5_busvoltage); Serial.println(" V ");
Serial.print("Shunt Voltage: "); Serial.print(U5_shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(U5_loadvoltage); Serial.println(" V ");
Serial.print("Current: "); Serial.print(U5_current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(U5_power_mW); Serial.println(" mW");
Serial.println("===========================================================");
Serial.println("POWER 3V: ");
Serial.print("Bus Voltage: "); Serial.print(U3_busvoltage); Serial.println(" V ");
Serial.print("Shunt Voltage: "); Serial.print(U3_shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(U3_loadvoltage); Serial.println(" V ");
Serial.print("Current: "); Serial.print(U3_current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(U3_power_mW); Serial.println(" mW");
delay(2000);
}