Hello,
I’m new user of PlatformIO (comming from Notepadd++ and Arduino IDE). On one of my project, I’m trying to split my code into 2 cpp files: I’m trying to moove the functions dedicated to deal with my MAX31865 ADC into a dedicated cpp file.
When I try to build the code, I’ve the following errors:
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\feather32u4\firmware.elf] Error 1
I’ve read some topic on the forum about this error, in particular:
But I wasn’t able to find where is the error in my code.
Here is how my files are organized:
The max31865.h code:
#ifndef max31865_h
#define max35865_h
#include <Arduino.h>
#include <SPI.h>
/************************** MAX31865 Parameter ***********************************/
#define REGISTER_CONFIG 0x0 // MAX31865 Configuration register adress
#define REGISTER_RTD 0x01 // MAX31865 RTD MSBs register adress
#define REGISTER_FAULT 0x07 // MAX31865 fault register adress
#define RTD_A 3.9083e-3 // Callendar-Van Dusen coefficient values used in equation to convert resistance value into temperature
#define RTD_B -5.775e-7 // Callendar-Van Dusen coefficient values used in equation to convert resistance value into temperature
/*MAX31865 global variables*/
int max31865CS = 0; // CS Pin for MAX31865
byte configInit = 0b0; // The config byte that will be send to MAX31865 at init. The config bit is determined in max31865Init() function depending on RTD wires number and filter frequency
byte configVbias = 0b0; // Config byte that will be send to MAX31865 to enable Vbias. The config byte is determined in max31865Init() function, based on configInit byte
byte config1Shot = 0b0; // Config byte that will be send to MAX31865 to enable 1-shot. The config byte is determined in max31865Init() function, based on configInit & configVbias bytes
byte configFaultClear = 0b0; // Config byte that will clear fault register. The config byte is determined in max31865Init() function, based on configInit byte
float refResistor = 0; // Reference resistor value for calculation of current RTD resistance value
float RTDnominal = 0; // Nominal 0-degrees-C resistance of the RTD for convertion of RTD resistance value into temperature
/*MAX31865 function prototype*/
bool max31865Init(int cs = 23, int wire = 3, int freq = 50, float ref = 4300, float rtd = 1000);
void max31865ReadRTD(word *rtd, bool *fault);
void max31865Calc(float data, float *rt, float *temp, float *R);
void max31865Write(byte adress, byte *data);
void max31865Read8(byte adress, byte *data);
void max31865Read16(byte adress, word *data);
#endif
The include section of max31865.cpp:
#include <Arduino.h>
#include "max31865.h"
The include section of main.cpp:
#include <Arduino.h>
#include <SPI.h>
#include <TinyLoRa.h>
#include "max31865.h"
The “TinyLoRa” librairie is only used in the main.cpp code. And it required SPI library (Lora module of the board is also on SPI bus).
The platformio.ini file:
[env:feather32u4]
platform = atmelavr
board = feather32u4
framework = arduino
lib_deps =
# RECOMMENDED
# Accept new functionality in a backwards compatible manner and patches
adafruit/TinyLoRa @ ^1.4.0
monitor_speed=9600
The code was working good when everythings was in the main.cpp file. I face this build error since I splid the code into two cpp files.
Have you an idea where can be the error ?
Thank for your help !
Math