[Solved]MCP3424 function call, not sure what type of variable is needed.

Hello,

I am very new to Arduino programming and programming in general. I am having trouble discerning what variables need to be declared in order to make my code compile. The error occurs at the following line:

#include <MCP3424.h>
MCP3424 adc(PIN_LOW, PIN_FLOAT);

The error I get is as follows:

“‘PIN_LOW’ was not declared in this scope”

I examined the MCP3424.h file in order to try to figure out what variables are needed for the call, and found the following:

typedef enum { PIN_LOW, PIN_HIGH, PIN_FLOAT } PinType;

later in the code, I saw this:

MCP3424 (PinType, PinType);

Here is the link to the MCP3424.h code

If anyone can let me know how I can fix this error or how I should be declaring a variable to resolve this issue, please let me know.

I am helping a friend out by with a project that another programmer coded for them, so I did not create the code this comes from.

Did you also get an error for PIN_FLOAT ?
If not, it looks like you may have a library mismatch. Did you look in the library folder within the sketches folder to verify that the correct version of the MCP3424 library is installed ?

The other thing you can try is copy the library (.h and .cpp files) into the same folder as the current .ino file and change #include <MCP3424.h> to #include “MCP3424.h” (in both the .ino and the .cpp file) so the local copy of the library is used.

6v6gt:
Did you also get an error for PIN_FLOAT ?
If not, it looks like you may have a library mismatch. Did you look in the library folder within the sketches folder to verify that the correct version of the MCP3424 library is installed ?

The other thing you can try is copy the library (.h and .cpp files) into the same folder as the current .ino file and change #include <MCP3424.h> to #include “MCP3424.h” (in both the .ino and the .cpp file) so the local copy of the library is used.

I appreciate the response.

If I define PIN_LOW as something arbitrary, then yes I get the same error for PIN_FLOAT.

I am using the most recent version of the library. It may be possible that the version the person who wrote this program and my version are different. I am unsure how to verify this at the current time, so I’ll have to reach out to the original programmer.

I tried your suggestion and received the same error, unfortunately. Would it be helpful to attach the full code?

Ok. Attach the whole code. But maybe first try to compile one of the simple example sketches that come with the library and see if that fails as well. If so then the problem maybe with your environment and not with the sketch you are developing. State also what version of the Arduino IDE you are using.

6v6gt:
Ok. Attach the whole code.
But maybe first try to compile one of the simple example sketches that come with the library and see if that fails as well. If so then the problem maybe with your environment and not with the sketch you are developing. State also what version of the Arduino IDE you are using.

I was able to compile the examples included with the MCP library.

I am using 1.8.7.

final_code_adc_rtc_oled_cloud_v2_sleep_sd_ver2.ino (20.3 KB)

I use Sloeber/Eclipse for arduino projects and I did succeed in getting it to compile.
Ultimately, what I did was this:

  1. Made a local copy of the MCP3424 library
  2. Changed the sketch:
    2a. removed the first reference to #include “MCP3424.h” (there are 2)
    2b. removed the static keyword from static const unsigned char PROGMEM logo16_glcd_bmp = . . .

At one time, I had to change
MCP3424 adc(PIN_LOW, PIN_FLOAT) ;
to
MCP3424 adc((PinType)1, (PinType) 1 ) ;
just to get further, but after a complete clean up, this was no longer required. I initially compiled a simple example MCP3424 sketch for the avr architecture which left a mess and error messages referring to an incorrect architecture after I tried your sketch which I compiled for the Node MCU 1.0.

Maybe create a fresh sketch and copy your code into it, make changes 2a. and 2b. above and see if you get any further.

The bits are attached in case it helps

BareMinimum.ino (20.3 KB)

MCP3424.cpp (2.47 KB)

MCP3424.h (2.21 KB)

6v6gt:
I use Sloeber/Eclipse for arduino projects and I did succeed in getting it to compile.
Ultimately, what I did was this:

  1. Made a local copy of the MCP3424 library
  2. Changed the sketch:
    2a. removed the first reference to #include “MCP3424.h” (there are 2)
    2b. removed the static keyword from static const unsigned char PROGMEM logo16_glcd_bmp = . . .

At one time, I had to change
MCP3424 adc(PIN_LOW, PIN_FLOAT) ;
to
MCP3424 adc((PinType)1, (PinType) 1 ) ;
just to get further, but after a complete clean up, this was no longer required. I initially compiled a simple example MCP3424 sketch for the avr architecture which left a mess and error messages referring to an incorrect architecture after I tried your sketch which I compiled for the Node MCU 1.0.

Maybe create a fresh sketch and copy your code into it, make changes 2a. and 2b. above and see if you get any further.

The bits are attached in case it helps

I tried to run your code and received the same PIN_LOW error :/, as well as when I tried making the changes you recommended. I will try downloading Sloeber to see if it will compile there. I am also using the generic ESP8266 board. I am uncertain if that is the correct board I should be using, but it allowed my code to compile further than if it was left as the default.

Attached is my full error codes.

error.txt (10.3 KB)

6v6gt: I use Sloeber/Eclipse for arduino projects and I did succeed in getting it to compile. Ultimately, what I did was this: 1. Made a local copy of the MCP3424 library 2. Changed the sketch: 2a. removed the first reference to #include "MCP3424.h" (there are 2) 2b. removed the static keyword from static const unsigned char PROGMEM logo16_glcd_bmp[] = . . .

At one time, I had to change MCP3424 adc(PIN_LOW, PIN_FLOAT) ; to MCP3424 adc((PinType)1, (PinType) 1 ) ; just to get further, but after a complete clean up, this was no longer required. I initially compiled a simple example MCP3424 sketch for the avr architecture which left a mess and error messages referring to an incorrect architecture after I tried your sketch which I compiled for the Node MCU 1.0.

Maybe create a fresh sketch and copy your code into it, make changes 2a. and 2b. above and see if you get any further.

The bits are attached in case it helps

I managed to get past the PIN_LOW error. I am now receiving a new error, however, that I posted separately here:

https://forum.arduino.cc/index.php?topic=581744.0

Thank you so much for your help.