I am new to arduino (& most coding in general) and working on a project that requires I sample the Current and voltage from a source then catalog it with time and temperature. I am using an adafruit_INA219 to sample the current and voltage with a DS3231 RTC module to accomplish this. The clock is operating properly but I am getting random values from the current/voltage sensor. Catch is that they run at 2 different baud rates but both require I2C and I am running it all on a seeeduino V4.2 which appears to only have 1 I2C connection. I have included my setup portion of my code because I do not think it is correct. Any help would be very much appreciated.
#include <String.h>
#include "FastDigitalPin.h"
#include <SimpleDHT.h>
#include <SoftwareSerial.h>
#include <DS3231.h>
#include <Wire.h>
#include <Adafruit_INA219.h>
#include <SPI.h>
#include <SD.h>
#include <Time.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#define DHTPIN 8
#define DHTTYPE DHT11
//DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial mySerial(12, 11); // RX, TX
const int chipSelect = 4;
DS3231 rtc(SDA, SCL);
Adafruit_INA219 ina219;
int pinDHT11 = 2;
SimpleDHT11 dht11;
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
float voltage[4] ={0};
float current[4]={0};
float temp = 0;
int i=0, j=0;
String Date;
String theTime;
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!");
//Serial port for voltage/current sensor
// 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).
ina219.begin();
// 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 ...");
rtc.begin();
// The following lines set the date and time
rtc.setTime(12, 05, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(6, 5, 2018); // Set the date to June 1st, 2018
//serial port for Micro SD card
// Open serial communications and wait for port to open:
mySerial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
mySerial.print("Initializing SD card...");
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
mySerial.println("Card failed, or not present");
// don't do anything more:
while (1);
}
mySerial.println("card initialized.");
pinMode(2, INPUT); // input trigger pin
}