Help with PID variables

Like most, I am self-teaching Arduino programing.

Everything I have done so far has been on one application for brewing beer.
My sketch has just been growing as I learn and add new features. The latest is PID for temperature control of the HLT. I already have a lot of it working and am just trying to add the PID for heater element control.

I have tried to look at examples from those that have already made some E-brewing sketches but they are so far beyond me that I can’t understand everything they have done to incorporate it in mine.

That said, when I Verify, I get a whole bunch of errors that all relate back to the PID function.
I can and will post the whole error but it is like 17 lines long and I have a sneaky feeling it is coming from one line of my code.

PID myPID(&hlttmp, &hltout, &HLTSetpoint, Kp, Ki, Kd, DIRECT);

My question is; can I use my own variables in the line above or does it have to be “Input, Output, Setpoint”? I could simply change it to see but I would have to change several other references to these variables in the sketch and I expect to be adding another PID control for a different vessel which would have its own Input, Output, and Setpoint.

Attached is my whole sketch so far, hopefully you can find the parts that actually matter. I suppose we can talk later about how many improvements can be made to streamline and/or make the code easier to read, smaller, faster etc.
Had to put it in an attachment because it said I exceeded my 9000 character maximum.

Thanks in advance to anyone that can help.

Mikes_HERMS_v4.ino (10.6 KB)

I have been struggling with this problem also and I think I have made some progress. Have a look at this Thread and the Threads that it links to.


You need to say which exact version of the PID library you are using.

The .h file says v1 and the folder as downloaded is named;
Hopefully that helps. The actual error message is below.

Arduino: 1.6.7 (Windows 8.1), Board: "Arduino/Genuino Uno"

Mikes_HERMS_v4:52: error: no matching function for call to 'PID::PID(double*, double*, int*, double&, double&, double&, int)'

PID myPID(&hlttmp, &hltout, &HLTSetpoint, Kp, Ki, Kd, DIRECT);


D:\Mikes_HERMS_v4\Mikes_HERMS_v4.ino:52:61: note: candidates are:

In file included from D:\Mikes_HERMS_v4\Mikes_HERMS_v4.ino:1:0:

D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:18:5: note: PID::PID(double*, double*, double*, double, double, double, int)

PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and


D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:18:5: note: no known conversion for argument 3 from 'int*' to 'double*'

D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:5:7: note: constexpr PID::PID(const PID&)

class PID


D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:5:7: note: candidate expects 1 argument, 7 provided

D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:5:7: note: constexpr PID::PID(PID&&)

D:\Arduino\arduino-1.6.7\libraries\br3ttb-Arduino-PID-Library-fb095d8/PID_v1.h:5:7: note: candidate expects 1 argument, 7 provided

exit status 1
no matching function for call to 'PID::PID(double*, double*, int*, double&, double&, double&, int)'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

The error message tells you exactly what, and where, your problem is: You are passing a pointer to an int as the third argument to the constructor, and the function expects a pointer to a double.

Ray L.

That's crazy, that long message for one little thing? I saw that in there but swore I had everything declared as double. I changed the one that was int (HLTSetpoint) to a double and it compiled.

The error message was so long I thought for sure I really had some major stuff screwed up. Maybe I am not cut out for this programming stuff.
Now I just need to upload it when I get home and see if it actually works.

Thanks for your help.

Error messages are kinda useless if you don't actually read them.... Start with the first one, and fix whatever it complains about, then do another build. The numbers near the beginning tell you exactly WHERE the problem is, as a line number and character position, and the message itself tells you exactly WHAT the problem is. The error is also pointed to by by "^" on the line UNDER the line quoted from the source file.

Ray L.

That's very interesting.
I never knew some of that. My first problem was that I was only seeing the last line of the error messages which wasn't helping much. Then when I saw the whole thing I was a little overwhelmed and couldn't figure out what "no matching function call" meant.

The line number and character position is new to me.
In the first one, it looks like the line number is 52. Am I reading that right?
When I scroll through the sketch, 52 is a comment line. How do I find the real line 52?

It's amazing how much easier it can be when you know these tricks. Sorry for being such a noob but this is good stuff. Thank you for your help.

Mikes_HERMS_v4:52: error: no matching function for call to 'PID::PID(double*, double*, int*, double&, double&, double&, int)'

PID myPID(&hlttmp, &hltout, &HLTSetpoint, Kp, Ki, Kd, DIRECT);


The line number is 4, the character position on that line is 52. If you look at the ^ in the last line above it is point to exactly where the problem is. An error message will ALWAYS have "error:" following the line number and character position of the error. Other messages, like warnings, will not. When a build fails, scroll back until you find the FIRST error message, deal with that, and ignore the others. The first error will often cause many others, which go away when the first one is fixed.

Ray L.

Ray, thanks for all your help. Still a little confused and struggling to get my head around the line number in the error message.

How do you count the lines? Does each line count including comments and blank lines , or just code lines?

The '4' in the error message is part of the file name, Mikes_HERMS_v4.ino
If I count every line including , it does correspond to the PID myPID line.

The line I actually corrected is "int HLTSetpoint = 170;" changed int to double. I guess I just have to find this line based on info in the error message.

As I type, I guess I am figuring it out. Am I understanding this correctly?