0 Replies Latest reply on Dec 6, 2018 1:57 PM by pflanigX

    Using Arduino Uno in MATLAB


      I just joined Intel Labs as a contingent worker with the task of testing and developing an environmental sensor. The device is put on a printed circuit board that is connected to an Arduino Uno; the board also has a BME 280 commercial environmental sensor (https://www.adafruit.com/product/2652 ) to measure the ambient pressure, temperature, and relative humidity. The project worker before me got the system to work through the Arduino IDE, but I thought it would be a good idea to use it in MATLAB as well. I have no problem extracting and saving data from our sensor, but I don't know how to let MATLAB look at the BME 280 data and save it.


      The C++ code that controls the BME sensor on the Arduino was obtained from https://github.com/adafruit/Adafruit_BME280_Library . It also requires you to download https://github.com/adafruit/Adafruit_Sensor .


      The process for setting up the MATLAB-Arduino connection is here: Create Custom Arduino Add-On Device, Library, or Code- MATLAB & Simulink . The first step (add-on package folder) is easy enough. The second step (MATLAB add-on class) pretty confusing. The last step (C++ header file) I can't understand at all. I'll go in order to keep things simple, so first I'll ask questions about the MATLAB add-on class file (https://www.mathworks.com/help/supportpkg/arduinoio/ug/matlab-add-on-class.html ):


      * What are the "dependent libraries"? Are those the lines at the beginning of the .h file (there's "Arduino.h", "WProgram.h", <Adafruit_Sensor.h> and <Wire.h>). Am I supposed to list those in the DependentLibaries line? Where are these files in the first place, i.e. does MATLAB need to know where to look for <Wire.h> somehow? If I was forced to guess, I'd leave this part blank, but I wanted to be sure.


      * I think "ArduinoLibraryHeaderFiles" is where you list <Adafruit_Sensor.h>, but how does MATLAB know where to look for this other .h file? Do I create another add-on package folder, even if I don't use it directly? Also, <Adafruit_Sensor.h> calls its own .h file (namely, <stdint.h> and "Print.h"). What should I do about those?


      * Are the whole "ResourceOwner" and destructor things optional?


      * The adafruit BME 280 link includes a .cpp file and a .h file. The .h file goes in the add-on package folder, but what do I do with the .cpp file? Am I supposed to transfer all of its processes and calculations to the .h file?


      Any help would be greatly appreciated.