Instructions PDF
Instructions PDF
Instructions PDF
rev 1.0
by Roberto Valgolio
Introduction
Arduino Excel (former Arduino Excel Commander) is a powerful interface
between Arduino and MS Excel that supports data exchanging in both directions.
Excel can represent real time data and charts or it can be used as an extern
database to overcome Arduino memory limitations. The main purposes are:
• sensors data harvesting and consolidation
• email alerts sending
• support for advanced applications (eg: 3D printers, CNC tools, robotic
arms)
The tool is typically used in prototypes but even in some professional applications
for scientific experiments or industrial data harvesting accomplished with cheap
hardware.
The logic is built in the Arduino sketch with simple instructions like:
// write the x variable value to worksheet 'Example' range 'B5' with two
digits as decimals
myExcel.write("Example", "B5", x, 2);
or
// get the value from worksheet 'Test' range 'A3' and put it in y variable
ret = myExcel.get("Test", "A3", y);
Find more documentation in the sketch supplied as example.
History: the project started in 2015, at beginning 2020 about 5000 users have
worked with it especially in education but even in scientific or industrial
environments. Top user countries are USA, Brazil, UE.
Coming soon: a new pro version with TCP an MQTT protocols is under study as
an interface to SQL databases, stay in touch.
ArduinoExcel roberto.valgolio@gmail.com
Installing
First step
• download the setup procedure from
http://www.robertovalgolio.com/sistemi-programmi/arduino-excel
• rename Arduino_Excel_Setup.eee to Arduino_Excel_Setup.exe
• IMPORTANT: launch Arduino_Excel_Setup.exe as Admnistrator (click the
exe with the right mouse button and choose 'Run as Administrator')
ArduinoExcel roberto.valgolio@gmail.com
Getting started
• connect an Arduino board to a USB port of your PC (up to four Arduino
can be connected at the same time)
• open Arduino_Excel_30.xls
• press the keys CTRL and ‘a’, you should see the launch form (1)
See the sketch for examples an modify them for your purposes. You can use a
modified copy of Arduino_Excel_30.xls but note that it isn't a generic Excel file
because contains the code (macro) to interact with Arduino.
(1)
if CTRL ‘a’ key pressing doesn’t work open menu Show, click on Macro icon, Show macro,
select CommanderRunA and press Run button, press Options button to define a launch key as
you like
ArduinoExcel roberto.valgolio@gmail.com
Software Architecture
The standard interaction between systems is based on Excel acting as server
and Arduino as client. Note that for Excel we mean a workbook with special code
(macro) running.
Excel workbook
Arduino sketch
(with code)
The rExcel library defines the API for data interchange, ArduinoExcel.dll instead
is to manage COMs and message queues since Excel VBA hasn’t specific
instructions for them.
ArduinoExcel roberto.valgolio@gmail.com
Arduino Excel API
In order to make easy and clean the Arduino programming an API was
implemented in rExcel library. See the following reference and the sketch
supplied as example for practical uses.
ArduinoExcel roberto.valgolio@gmail.com
myExcel.writeIndexed("Example", 11, 4, a0, 2); // write the content of
a0 to worksheet 'Example' row '11' column '4' with two digits as decimals
ArduinoExcel roberto.valgolio@gmail.com
log write info in the configured log file (see Parameters worksheet)
syntax bool log(char* info);
parameters info string with arguments semicolon (;) separated
return true if successful
example // write on log the values of idx and rnd
char floatValue[8];
char info[16];
dtostrf(rnd, 3, 2, floatValue); // trick because in Arduino sprintf() doesn't
represent floats
sprintf(info,"%d;%s", idx, floatValue); // info must separated by
semicolon, be careful on info lenght
myExcel.log(info);
note date and time are automatically added for each writing
ArduinoExcel roberto.valgolio@gmail.com
Protocol
When an API function is called, the rExcel library builds a specific message and
send it to Excel that process the message and respond with acknowledgement
or not. If not acknowledgement the function does some retries before to give
up.
The data exchange is based on readable CSV strings terminated with NewLine
char.
For details about the message management see rExcel library and the code in
Arduino_Excel_30.xls (open the file and press ALT F11 to get the programming
environment).
ArduinoExcel roberto.valgolio@gmail.com
Programming tips
The above values are tested for most applications, change them only for special
requirements.
VBA hasn’t two important features for this app: COMs management and timed
events.
In order to overcome the first lack, a specific DLL was developed for COMs
management within a separate process plus a message queue to store incoming
messages. This software is protocol independent except for message ending that
must be NewLine.
Without timed events a continuous loop looks for queued messages, check and
performs all requests. This is the heart of the app, for more details get access
to the programming environment and see the ReadingLoop() function in
Module1.
The loop ends when all connections are closed.
ArduinoExcel roberto.valgolio@gmail.com
Appendix A – macro enabling
Click on File, Options
click 'Enable all Macros' and check 'Trust access to the VBA project object
model'
ArduinoExcel roberto.valgolio@gmail.com
Appendix B
May happen that your Excel VBA (Visual Basic Application) hasn’t configured
some component called “reference” so check as follows:
• press ALT F11
• click on Run menu and then Restore (this reset the error status)
• click on Tool menu and then on Reference, should appear this form
ArduinoExcel roberto.valgolio@gmail.com