Help - complete duffs

I have a Photon, I have some code that I found, that allegedly works on a Spark Core. Trying to get it to run on the Photon.

The code is here: https://captain-slow.dk/2015/01/31/temperature-controlled-fan/

I have a server rack in my office and it uses two fans permanently on to reduce temps but controllable PWM fans would be much better from a noise perspective. The code looks ideal for what I want. The wiring indicated is a doddle to sort and I know the pin outs for the PWM.

All I get is:
call of overloaded ‘map(float, int, int, int, int)’ is ambiguous

I have no idea what this means or what to do about it. Yes I should be able to code, yes I agree I am out of depth. Yes this is a big step up from the one project I got running which was just reading several TMP36 from the Photon to record what the server rack temps.

Please send help - I’m lost.
Dave

map() needs to have all of it’s inputs be either float or int.

So you could do

map(float 1, float 2, float 3, float 4, float 5)

or

map(int 1, int 2, int 3, int 4, int 5)

but not mix and match.

It looks like the map function needs to have all ints or all floats, not a mixture of the two. If you redefine your variables to be floats, it should get rid of that error,

#define tempMin                 25.0      // Temperature where PWM will be equal to pwmMin
#define tempMax                 40.0      // Temperature where PWM will be equal to pwmMax
#define pwmMin                  5.0       // Minimum PWM duty cycle (min 0)
#define pwmMax                  255.0     // Maximum PWM duty cycle (max 255)
#define pwmCalcDelay            100     // Time in milliseconds between calculating and setting PWM
#define pwmMultiplier           100.0     // Multiplying values to increase resolution on the map function
1 Like

Awesome, that got the code complied and loaded. Thank you. I knew it would be simple if I knew what.

Started playing with hardware and got rubbish readings. Eventually realised I don’t have a TMP36 but a DS18b20. Now will either have to get a TMP36 or amend code to use DS18b20. As the postman isn’t instant I’ll give code changes a go.

Thank you.