switch at the lower left to give the Arduino/MakerPlot
communications link to MakerPlot, which will then
establish a connection to the Arduino Uno and cause your
sketch’s setup() code to run. You should see the Arduino
time field update after a few seconds, and the system state
should show IDLE.
Arduino old timers will be familiar with the F-Macro.
Newcomers may benefit from this short explanation.
Arduino microcontrollers have three kinds of memory:
5. The Event Log will open to the right of the plot, and
prompt you to enter a plot start time.
Flash memory (program memory) which is relatively
plentiful (the Uno has 32K); EEPROM; and SRAM, which is
fast but relatively scarce. (The Uno has only 2,048 bytes of
6. Press the “Start in 30 sec” button. It should turn
bright blue and stay that way for a few seconds until the
The best use of valuable SRAM memory is for the
storage of local variables.
Arduino code sees the flag, services your request, and
then resets the switch back to a dark blue color again
The problem is that the Arduino compiler stores literal
strings ("This is a literal strIng") in SRAM, which is a waste
of a scarce resource. Literal strings don't even change!
7. In a few seconds, the system state will change to
COUNTDOWN and you should soon see the countdown
time field begin updating.
When SRAM usage gets up to 80% or so, hard-to-find
program bugs can really ruin your day!
8. When the countdown reaches zero, plotting will
begin. After a few more seconds, you should see a black
line begin to work its way across the plot grid. (You can
test this even without a solar cell connected. An
unconnected Arduino analog input will float at around 1.5
volts and you can use that as your test input.)
The F-Macro causes literal strings to instead be stored
in cheap relatively plentiful Flash/program memory. All
you have to do to use the F-Macro is to insert #include
<avr/pgmspace.h> at the top of your program, and instead
of writing something like the following:
9. When the plot reaches the right margin, plotting
Write this instead:
10. Click the green “Open Folder” button. You should
be able to see a screen capture snapshot of your recently
made plot there.
11. Click the now green CONNECT switch again to
turn it red and disconnect MakerPlot from the
microcontroller; thus relinquishing the link back to the
Watch the compilation report text on the Arduino IDE
after a successful compile, and download to see how you
are doing with these critical resources. Program memory
and SRAM usage are both reported there.
12. To repeat, wait about 10 sec, click the now red
CONNECT switch turning it green. This will also have the
same effect on the microcontroller as pressing the reset
switch. The Arduino program will restart and run the
setup() code again. If desired, enter a new plot start day
and time, then click one of the two blue buttons and walk
away. You’re done!
When I first started developing the solar intensity
monitoring software, I was not using the F-Macro, and
SRAM usage got up as high as 73%. However, at this
point, the project was only about halfway done with the
To relieve this situation, I edited in the F-Macro
wherever I could, and SRAM usage dropped to 25%. Now
with the development work mostly complete, SRAM usage
is only at about 30%.
13. To abort at any point, click the green CONNECT
switch, turning it red and disconnecting MakerPlot from
Arduino/MakerPlot coding technique, but you will see it in
the example code that will follow shortly. The need for the
F-Macro is related to how the Arduino compiler handles
memory assignment for literal data. See the F-Macro
sidebar for more information.
Source comments were freely applied throughout the
Machine State: At any point in time when it is
running, the solar intensity monitor is in one of four states:
Arduino code listings. If your intent is a more thorough
understanding of this implementation or to go on and
generate your own tailored version, spending time looking
through the source code would be rewarding. A few key
aspects thought to merit additional emphasis are
IDLE, COUNTDOWN, PLOTTING, or STOPPED. The
current state determines what variables are monitored for
enabling progression to the next state. (For example, user
entry of a plot start time triggers progression to the
Most of the comments offered here are directed
toward the reader intending to modify and enhance our
sunlight intensity monitoring project, targeting his or her
own new but similar application.
F-Macro: The F-Macro has nothing to do with
Command Termination: Arduinos and MakerPlot
communicate with short ASCII messages (command
strings) which must be formatted as a single text string and
terminated with a carriage return. In building a lengthy
command string with several substrings and print
statements, this means that only the last one should be
August 2017 45