ADS1015 matlab simulink library issue

I’m following this tutorial

to create a simulink custom s-model

I have this error message

sfADS1015_wrapper.o: In function Adafruit_ADS1015::begin()': C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:116: undefined reference to Wire’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:116: undefined reference to Wire' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:116: undefined reference to TwoWire::begin()’
sfADS1015_wrapper.o: In function writeRegister': C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:64: undefined reference to Wire’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:64: undefined reference to Wire' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:64: undefined reference to TwoWire::beginTransmission(unsigned char)’
sfADS1015_wrapper.o: In function i2cwrite': C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:52: undefined reference to Wire’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:52: undefined reference to Wire' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:52: undefined reference to TwoWire::write(unsigned char)’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:52: undefined reference to Wire' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:52: undefined reference to Wire’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:52: undefined reference to TwoWire::write(unsigned char)' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:52: undefined reference to Wire’
C:\Ads1015Arduino\ADS1015_ert_rtw/…/Adafruit_ADS1015.cpp:52: undefined reference to Wire' C:\Ads1015Arduino\ADS1015_ert_rtw/../Adafruit_ADS1015.cpp:52: undefined reference to TwoWire::write(unsigned char)’

i attache complete error message

i don’t know how to solve this issue. Can anyone help me?

i copied wire.cpp and wire.h to the directory in C:ADS1015 folder that i created for my s-model.

i think wire can’t read some libraries but i don’t know how to corret it.

(i try to copy the entire folder and modify ads1015.cpp from adafruit to link it…but that doesn’t work)

(deleted)

Hello,

I was wondering if you were ever able to figure this issue out? Please let me know! Thank you!

Best.

Using Matlab R2019a I got exactly the same error code. So I changed the Libraries pane code in the S-Function-Builder as you can see below:

#include <math.h>
#ifndef MATLAB_MEX_FILE
#define ARDUINO 100
#include <Arduino.h>
#include <Wire.h>
#include “twi.h”
#include “twi.c”
#include “Wire.cpp”
#include “Adafruit_ADS1015.cpp”
Adafruit_ADS1015 ads;
#endif

(Reason: It seems to be important to include these libraries in the right order. Otherwise Simulink doesn’t seem to find the libraries which “Adafruit_ADS1015.cpp” refers to.)

Additionally I added Wire.h, Wire.ccp, twi.h and twi.c into my project folder. These were found in the following location:

C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\arduino\avr\libraries\Wire\src

Then I copied the folder “utilities” which also contains twi.h and twi.cpp into my project folder.
(Reason: I didn’t want to modify any library, but Wire.cpp refers to “utility/twi.h”. Therefore this structure is needed.)

After these changes all undefined references were gone and everything worked out well.

Hope I could still help anybody.