Excel datastreamer not working with Arduino Wifi R4

Im trying to setup a datastream between my arduino and Excel. When I connect the Serial port to Excel no data is printed, not even a timestamp. Ive read some other forums about this and some solutions seemed to work. One of those was to use a library "#include <HID.h>" and use the function "Serial.dtr();". Well I tried this and when I included the library both arduino IDE and Excel stopped recognizing the Serial port. The RX light on my arduino stopped blinking and I got the error "no supported device on "COM7". Im wondering if theres another way to fix datastreamer or to get the HID.h library to work.

Just google datastreamer. You need a subscription to office365 (only $100/year)
Have you configured excel for datastreamer?

Yes I have, it seems like its a problem with the new arduino R4 since I have seen alot of other people on this forum with the same problem with the same board. But they seemed to get it to work with writing "Serial.dtr();" but including "HID.h" seems to stop all serial communication for me.

When you say "stopped recognizing the Serial port", do you mean that you no longer see a port for the board when you open Arduino IDE's Tools > Port menu?

Or is there still a port and you are only referring to the fact that uploads to the board now fail with the "No device found on ... " error, as we already discussed in your other topic?:

Please provide a sketch that demonstrates the problem.

I just gave it a try with this simple test sketch:

#include <HID.h>

void setup() {
  Serial.begin(9600);
  Serial.dtr();
}

void loop() {
  Serial.println("hello");
  delay(1000);
}

I see "hello" printed in the Arduino IDE Serial Monitor at 0.5 Hz, just as expected.

You did not say whether you were using an Uno R4 WiFi, or an Uno R4 Minima, so I decided to do some tests using both.

I used some code that had been tested and was working on an Arduino Uno R3. This code just took a reading from an analogue pin and printed the raw data to the serial output.

Although this code would work on an Uno R3 and Excel Data Streamer, It would not work with an Uno R4 WiFi, or Uno R4 Minima.

This was not what I found when I did a similar test in Dec 2023:
forum.arduino.cc/t/uno-r4-wifi-not-working-with-excel-data-streamer/1198001/2

Arduino Uno R4s have a second serial port Serial1.
I added a line to the code to send the data to both Serial and Serial1.

Using an oscilloscope I could now see data being transmitted from pin 1.
By connecting a UART to USB converter to pin 1, I was able to use Serial1 with Excel Data Streamer.

Code here
int inputPin = A0;
unsigned int raw = 0;

unsigned long previousMillis = 0;
const long interval = 1000;

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = previousMillis + interval;
    raw = analogRead(inputPin);
    Serial.println(raw);
    Serial1.println(raw);
  }
}

Here is a 20mHz, 4V peak to peak sinewave from a function generator connected to analogue input A0:


Uno R4 Minima on COM13 does not work with Data Streamer.
Uno R4 WiFi on COM20 does not work with Data Streamer.

UART to USB converter on COM26 connected to either Uno R4 on Serial1 works with Data Streamer.

Using an Arduino Uno R4 with the Serial Monitor isn't a problem for me.

It is when the Uno R4 COM port is connected to Excel Data Streamer (Serial Monitor closed) that no data is transferred.

I can now confirm that adding:

#include <HID.h>

and

 Serial.dtr();

to my code enables it to work with Excel Data Streamer on both the Uno R4 Minima and Uno R4 WiFi.

Is the necessity to do this documented anywhere?

#include <Wire.h>
#include <Adafruit_INA219.h>
#include <HID.h>

Adafruit_INA219 ina219;


void setup(void) 
{
  Serial.begin(9600);
  Serial.dtr();
  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  if (! ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) { delay(10); }
  }
  // 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) 
{
  Serial.dtr();
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  
  Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");

  delay(50);
}

This is my current code. What I mean with the serial connection seems to be lost is not just that I get the no device found message but the Serial monitor doesnt get any values. Also the TX light on the arduino does not blink. Also I get a disconnect noise from windows as soon as I upload the code. It does give me values without including HID.h but that doesnt work with datastreamer. (Ignore the Serial.drt(); in the loop just forgot to remove it).

Thanks to everyone who responded here, finally got it to work after some hours.