Running an Arduino Nano BLE Sense. Reads 4 sensors, analogWrites them to 4 PWM pins (Not sure if that's relevant), and in the meantime, prints all 4 to the serial monitor. They print to the serial monitor fine, and the analogWrite signals are working ok, but i need to kind of tune them so they are in the range i need. To do that i want to use Data Streamer to collect long-term data over time.
I can connect to the COM Port, and start the data, but nothing populates. Here's my code:
#include <Arduino_BMI270_BMM150.h> //Tilt
#include <Arduino_LPS22HB.h> //Pressure
#include <Arduino_HS300x.h> //Humidity
#include <Arduino_APDS9960.h> //Color
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
// Initialize sensors
IMU.begin();/////Tilt
BARO.begin();////Pressure
HS300x.begin();//Humidity
APDS.begin();/////Color
int r, g, b;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
//////////////////////////////////////////////// Read Pressure data///////////////////////////////////////////////////////
float initialPressure = BARO.readPressure();
delay(10000);//////////////////////////////////////////////////////// DELAY ////////////////////////
float finalPressure = BARO.readPressure();
float pressureDifference = abs(finalPressure - initialPressure);
Serial.print(pressureDifference*25500);
Serial.print(",");
Serial.print("\t");
//////////////////////////////////////////////////////Send Pressure Difference to pin 4////////////
analogWrite(4, (pressureDifference*25500));
////////////////////////////////////////////////////////// Read Tilt data//////////////////////////////////////////
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
// Compile data for pin 2
float compiledData = abs(((x + y) + (y + z) + (z + x)) / 3.0);
int tilt = (compiledData * 255);
////////////// Print Tilt//////////////
Serial.print(tilt);
Serial.print(",");
Serial.print("\t");
////////////////////////////////////////////////////// Send Tilt data to pin 2//////////////////
analogWrite(2, tilt);
}
////////////////////////////////////////////////Read Humidity data//////////////////////////////////////////////////
int humidity = HS300x.readHumidity();
/////////////////////////////////////////////////////// Send Humidity to pin 3////////////////
analogWrite(3, float(map(humidity, 0, 100, 0, 3300) / 1000.0));
///////////// Print Humidity////////////////////
Serial.print(map(humidity, 0, 100, 0, 255));
Serial.print(",");
Serial.print("\t");
////////////////////////////////////////////////////// Read Red light data////////////////////////////////////////////////
while (! APDS.colorAvailable()) {
delay(5);
}
int r, g, b;
APDS.readColor(r, g, b);
//////////Print Red Light Amount/////////////
Serial.print(map(r,0,4097,0,255));
Serial.println();
///////////////////////////////////////////////////////////Send Red Light to pin 5//////////
analogWrite(5, int(map(r,0,4097,0,255)));
}
Things I've tried:
-Restart the computer
-Restart the arduino
-Turned off the serial monitor
-matched the baud rates,
-reinstalled my COM driver
-reinstalled Data Streamer
Something to keep in mind: I connected the VBUS points to make 5v out possible, and since then, the COM ports have been a little weird. Usually, it defaults to COM 7 but I can't upload through COM 7. So I have to double click the reset button and go to boot mode every time. That changes it to COM 6 which allows me to upload. I have to do this while connecting in the IDE and in Excel. Could this have something to do with it?