Need Technical Help

Dear Experts,

I need your kind assistances for the following issue, I faced.
Firstly, I do admit that I am not a person from computer programming/coding & electronics background.

However, after being interested on Arduino, I installed the IDE 2.2.1 on my laptop with Windows 10, 64 bit (following the compatibility requirement in the IDE download page of arduino.cc), bought an original Arduino UNO kit and connected it to the laptop and the device (Arduino UNO) was selected and also recognized by the IDE accordingly.

However, being interested about EMG monitoring using Arduino, I bought an EMG Sensor and managed to get the necessary programming which was successfully compiled & uploaded to the board. The program is as follows:

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorValue = analogRead(A1);
  float millivolt = (sensorValue/1023)*5;
  
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);
  
  Serial.print("Voltage: ");
  Serial.print(millivolt*1000);
  Serial.println(" mV");
  Serial.println("");
  delay(1);       
}

However, although I got a nice response in the Serial Monitor, but no graphical output came in the Serial Plotter although it was realized that something is going as the base line values of X-Axis was found to be changing

Next I downloaded and installed IDE 1.8.19 and run & uploaded the above said program and I got the expected output not only in the Serial Monitor (as same as from using IDE 2.2.1) but also in the Serial Plotter (that did not happen while using IDE 2.2.1)

In this regard, I kindly need your help as I can not understand that although IDE 2.2.1 is compatible with Windows 10 as the Arduino website, it can not produce the expected output in the Serial Plotter despite it has been found to be possible through IDE 1.8.19 for the same program.

I also noticed and did not understand that although the Y-Axis base line values in the Serial Plot of the output showed the interval like 0.0-1500.0-3000.0-4500.0 (for IDE 1.8.19 that gave good response) however the same came out as -0.2-0-0.2-0.4-0.6-0.8-1.0-1.2 and did not show any variation/changes sensor values/voltages while using IDE 2.2.1 despite the program being same that was compiled and uploaded successfully for each IDE.

I do hereby attach the screenshots for the issues as described above.

Please guide me to resolve the Serial Plotter issue for IDE 2.2.1

Regards

Souvik Das
West Bengal, India




that's a lot of println for the plotter which wants the samples to be on the same line (you have 3 lines there)

try just

  Serial.print(millivolt*1000);

and then you should see the voltage in the plotter

Thanks for your reply. I tried as per your suggestion but it did not worked. Please find the attached screenshot.

I really do not understand that whereas IDE 1.8.19 works on the program mentioned in my earlier post, but IDE 2.2.1 does not!!!

Now it worked. I missed a line.

However, would please tell me why the same program provided best result without any modification of program (for IDE 1.8.19) as suggested by you for IDE 2.2.1?

the plotter has been entirely rewritten in version 2 of the IDE... so it behaves differently

Hi @souvik1112. You must print the data in a specific machine readable format. Like this:

<label>:<value>,...
<label>:<value>,...

This is an example of correctly formatted data for your application:

Sensor_Value:1.23,Voltage:4.56
Sensor_Value:2.34,Voltage:3.45

This is the format of the data your current sketch is producing:

Sensor Value: 1.23
Voltage: 4.56 mV

Sensor Value: 2.34
Voltage: 3.45 mV

That data format might be OK for a human to read, but it is completely unsuitable for a machine to read!!!

So you must adjust your code to achieve the following things:

  • The label text must not contain any spaces
  • There must not be any spaces between the label and the value
  • There must not be any content following the value
  • You use a comma (or tab if you prefer) as a field delimiter

Make your best attempt at modifying your code to achieve the required data format. If you still have problems, reply here with your updated code and a detailed description of any questions you might have about what I wrote or problems you encountered with your sketch and we'll help you out.

Dear all experts,

Sorry for my late reply for being busy with other issues.

However, I must thank you all for your assistance and my problem is solved.

Thanks & regards

Souvik Das

You are welcome. I'm glad it is working now.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.