serial monitor. You can do one or the other, but not both.
To allow MakerPlot to use the link, simply click the
CONNECT switch at the lower left of the user display
(Figure 5) which causes the switch to turn green. That will
give MakerPlot control of the link. To give the link back to
the Arduino later for another program download, simply
click the CONNECT switch again. MakerPlot will give up
control of the link and the switch color will turn red.
If you do forget and leave the link connected to
MakerPlot while simultaneously attempting to download a
new program to the Arduino, no harm will be done.
However, the download will fail and the Arduino IDE will
protest. (I have done this by mistake more times than I can
count!) Many specific examples of coding for
Arduino/MakerPlot data transfer in both directions will be
described later in this article.
Any data acquisition system needs to know real world
time. The Arduino has no built-in facility for this. You
could add an additional RTC module based on (for
example) a DS1307 chip to the system, but you don’t
need to! MakerPlot can provide the PC’s time and date
information to the Arduino program. Additionally, using
the Arduino Time library makes it easy.
The Arduino Time library (contributed by Michael
Margolis) is a key factor in simplifying adding real time
monitoring and control capability to projects such as
this one. You can easily add this optional library to
your library collection from inside the Arduino IDE
(Sketch > Include Libraries > Library Manager ...); refer
to Figure 6.
The library is built around a software clock. It has
all of the functions you would expect to retrieve;
typical date/time variables such as month(), day(),
Because your PC’s clock is almost certainly synced
with an Internet Time Service (or could be), you now have
an excellent real time capable data acquisition and control
system at your fingertips!
As a test, I set the software to sync the Arduino clock
to the PC/MakerPlot clock once per hour and logged the
resulting hourly drift data for an 11 hour period
(SYNC_TIME_INTERVAL = 60). This setting was sufficient to
keep the hourly interval drift errors to one second or less
over the entire period.
Let’s take one trip through a first use scenario. Then,
we will look at software detail.
1. Install the Arduino Time library, and compile and
download the .ino file to the
microcontroller using the Arduino IDE.
2. Assuming you have already installed
MakerPlot on your PC, double-click the
MakerPlot sim.spm file as furnished in the
downloads at the article link. That should
open the user interface for the project on
your PC. (The location of the sim.spm file is
not important. Just put it in an appropriate
place in your Arduino projects folder after
expanding the ZIP file.)
3. For this first test, use the X axis
controls to set the X axis for a 60 sec total
span. (Normally for a 10 hour plot, this
would be set for 600 min.) Also, click the
“Stop Max” button which will freeze the
plot when it reaches the right margin.
4. Click the red CONNECT rocker
44 August 2017
FIGURE 5. User control panel.
FIGURE 6. Use the Library Manager to install a copy of the Arduino Time
library on your PC.