I need help with the Arduino_BQ24195 library. I installed this library using the Library Manager on the Arduino IDE 2.3.2, but when I try to #include this library from the Manager, it #included Arduino_PMIC, nor Arduino_BQ24195. I left the PMIC library included, and typed in #include Arduino_BQ24195, so I have both. But when I check/compile the sketch,, I keep getting a "No such file or directory" message. This code is intended to be uploaded on an Arduino MKR WiFi 1010, howerver, I have yet to receive them (they will be here next week), so I haven't connected the board to the computer yer. Will that make a difference? Am I doing something wrong. Help!
(also, while y'all are here, can you read through the rest of the code and give any suggestions to format/layout/anything)
#include <WiFiNINA.h>
#include <Arduino_BQ24195.h> //battery utilities************************ will not compile with this library included
#include <Arduino_PMIC.h> //part of BQ24195?
#include <ArduinoIoTCloud.h>
#include "simulationDiag.h"
#include "arduino_secrets.h"
//will also need to #include thingsProperties.h and arduino_secrets.h, but these should be added automatically by the online IDE.
//provide network credentials using the arduino_secrets.h header tab. Header should be included automatically
char cloudSSID[] = cloudNetwork_SSID;
char cloudPASS[] = cloudNetwork_PASS;
char localSSID[] = localNetwork_SSID;
char localPASS[] = localNetwork_PASS;
//the WiFI radio stauts (I just copied this from a tutorial):
int status = WL_IDLE_STATUS;
WiFiServer server(80);
//defining constants:
const int toggleAllButton = 2;
const int toggleDoorButton = 3;
const int numberOfMotorUnits = 11;
bool shutterCommandBool; //this is what changes when the toggleAll button is pressed.
int shutterCommandBin = 0b00000000000; //this is what the other boards will read, then use bitRead to determine its specific command.
int shutterStatus = 0b00000000000; //currently, this is just to figure out what its doing on the simulator. eventually it will read the status of the other boards and update here
bool statusCorrectBool; //this will be used as a check to make sure all motorUnits completed their task properly.
unsigned long cloudUpdatePreviousMillis = 0; //will store the last time ArduinoCloud updates.
const long cloudUpdateInterval = 900000; //interval at which to update ArduinoCloud. 900000millis == 15 min
void setup() {
Serial.begin(9600);
while (!Serial) {} //delay while monitor starts ***Is there a better option, since delay is not reccomended on cloud?
// initProperties(); //Initialize the variables/properties. Header created/maintained by IoT Cloud. Commented out temporarily to test if code will compile before boards arrive.*************************************************
cloudSetup();
localAPSetup();
firmwareVersion();
createLocalAPNetwork();
pinMode(toggleAllButton, INPUT);
pinMode(toggleDoorButton, INPUT);
attachInterrupt(digitalPinToInterrupt(toggleAllButton), toggleAllShutters, RISING);
attachInterrupt(digitalPinToInterrupt(toggleDoorButton), toggleBackDoor, RISING);
setLedOutput(); //simulator diag. Defined in simulatorDiag header. not important for code functionality
}
void loop() {
scheduledCloudUpdate();
diagOutput(shutterCommandBool, shutterCommandBin, numberOfMotorUnits); //simulator diag. Defined in simulatorDiag header. not important for code functionality.
}
void cloudSetup(){
//Cloud debug information (again, just copied from a tutorial):
// ArduinoCloud.begin(ArduinoIoTPreferredConnection); Requires initProperties(). Commented out temporarily to test if code will compile before boards arrive.
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void localAPSetup(){
//local AP information. Copied from tutorial.
Serial.println("Access Point Web Server");
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
//don't continue
while (true); //need to find a way to retry vs staying in a while loop
}
}
void firmwareVersion() {
String firmwareVersion = WiFi.firmwareVersion();
Serial.print("Firmware Version: ");
Serial.println(firmwareVersion);
if (firmwareVersion < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware");
}
else {
Serial.println("Firmware Version is up to date!");
}
}
void createLocalAPNetwork(){
//Create AP with open network
Serial.print("Creating Access Point named: ");
Serial.println(localSSID);
status = WiFi.beginAP(localSSID, localPASS);
if (status != WL_AP_LISTENING) {
Serial.println("Creating Access Point Failed");
while (true); // don't continue. Need to find a way to keep retrying instead of staying in loop.
}
delay(5000); //***code I copied said 10 seconds, but I want to try 5 first, since the cloud documentation says delays aren't the best idea.***
server.begin(); //start the server on port 80 (set in the variable info above).
printWiFiStatus();
}
void scheduledCloudUpdate() {
unsigned long currentMillis = millis();
if (currentMillis-cloudUpdatePreviousMillis >= cloudUpdateInterval) {
cloudUpdatePreviousMillis = currentMillis;
shutterStatusCheck();
ArduinoCloud.update();
}
}
void toggleAllShutters(){
shutterCommandBool = !shutterCommandBool;
for(int i=0; i<numberOfMotorUnits; i++){
bitWrite(shutterCommandBin, i, shutterCommandBool);
}
diagOutput(shutterCommandBool, shutterCommandBin, numberOfMotorUnits);
}
void toggleBackDoor(){
bitWrite(shutterCommandBin, 0, !bitRead(shutterCommandBin,0));
diagOutput(shutterCommandBool, shutterCommandBin, numberOfMotorUnits);
}
void shutterStatusCheck(){
//this function will request the sensor status from each of the MotorUnits, and update shutterStatusBin variable, then check to see if shutterStatusBin==shutterCommandBin.
}
void printWiFiStatus() { //I literally just copied this from a tutorial. Not sure if it is needed.
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}