The new Arduino IDE has a lot of powerful features. Unfortunately the plotter app is not one of them. It can be frustrating, but there is a fix.
Out of the box the Arduino 2.x plotter only displays 50 data points at a time. This is not enough for seeing many trends in sensors and other contexts.
This post is all about making the 2.x plotter wider so you can get the most out of this tool.
You have to do this every time you update your Arduino software!
Modding Software
To adjust the plotter we need to follow the solution posted in this Arduino issues thread: https://github.com/arduino/arduino-ide/issues/803, specifically this post: https://github.com/arduino/arduino-ide/issues/803#issuecomment-1338149431 . Hats off to the user Alex-Tsyganok who posted the solution.
NOTE
The posts above gives us the strategy, but the path to the file we need to mod has changed since the solution was first shared. The above solution worked until at least Aug 2023. But as of October 2023 the needed file has moved.
The rest of this post is based on above using the current file structure.
What we need to do
Our goal is to make the plotter 500 points wide not 50. We are going to track down the serial plotter software inside Arduino IDE and mode the file so that 500 points are displayed.
Test COde
Cut, paste and upload the following code using IDE 2.x to test your plotter as you work through this mod. (This is not needed in IDE 1.x).
// simpleSquareWave generator
// plotter test code
unsigned long interval = 50;
unsigned long start = 0;
unsigned long now = 0;
int STATE = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
now = millis();
if ( (now - start) > interval){
STATE = 1 - STATE;
start+= interval;
}
Serial.println(STATE);
delay(10);
}
Video
Here are video instructions — text follows with search terms and paths spelled out.
PATH
Oct 2023 path:
Find the file in question here:
Arduino —> Contents —> Resources —> app —> lib —> backend —> resources —> arduino-serial-plotter-webapp —> static —> js —> main.35ae02cb.chunk.js
ON OSX:
Find the Arduino IDE icon in finder and right click. Then click on SHOW PACKAGE CONTENTS to get to Contents folder then navigate as described above.
ON WINDOWS:
Right click on the Arduino IDE shortcut and select “Open file location”. From there follow the path
\resources\app\lib\backend\resources\arduino-serial-plotter-webapp\static\js
[thanks David Bouchard for confirming the path and the search tip.]
File to FIND:
Once you get to the .js file you are looking for:
main.35ae02cb.chunk.js
Copy it — to back it up.
Then,
Open the original file in a text editor and find/search for the following line:
U=Object(o.useState)(50)
change that line by adding a zero (0) in the brackets to make 50, 500
U=Object(o.useState)(500)
Save the file. Do not change the name.
With some computers / setups you may need to change permissions to save. It will be ok. Go for it.
At this point the plotter is modded — you can test.
Permissions and Saving
You may need to enable ‘Write’ permission on the file to save your changes. If you try to save and it throws a warning about not being allowed, try the following:
OSX
In FINDER, right click the file and click Get Info or simply highlight the file and on keyboard click BUTTERFLY-I (butterfly is command).
The bottom of info window is permissions. Unlock the window (bottom right icon — enter password if you need to) – then for your user name OR everyone select Read and Write. Re-lock window for good measure.
You should now be able to save.
Windows
Navigate to the file we are modding and open settings. Different Windows versions may do this differently …
In File Explorer click on the file and then on keyboard press Alt-ENTER or with mouse ALT-Double-click this should give a settings window.
Link to additional methods if those don’t work (none of these are tested).
Once you have the settings window open … select SECURITY tab.
In that tab — select USERS in Group or user name frame, click EDIT (i don’t know which of those comes first), click the box for WRITE, ALLOW which should now be visible and click OK to save changes.
That should do it (i hope). You should be able to save.
Thanks to Rosalind P from tangible 2023 for help explaining the windows fix and sending along the images. All errors are mine.
Back to Arduino
In the Arduino IDE, with the above test code running, reopen the plotter and if all is well, you will see the 500 point wide plotter dancing before you.
Nailed it. Applaud self — get on with day.
If you have trouble opening the plotter, restart Arduino. And try again.
If it has really gone wrong — i did mess this up once to see what a worst case scenario might look like — you can reinstall Arduino 2.x.x and start again. No harm done.
Going Further
If you have not already done so, you can jump over to this building block and learn the Serial object basics.