Hi,
i tried to use the PID library together with the MLX temperature sensor (SDA/SCL)
program compiles and uploads but nothing happens.
cant figure it out. does the PID lib only work with Analog input?
please review someone thanks!
#include <PID_v1.h>
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
#define RELAY_PIN 12
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
double Kp=2, Ki=5, Kd=1;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
int WindowSize = 5000;
int temp = mlx.readObjectTempC();
unsigned long windowStartTime;
void setup()
{
Â
Serial.begin(9600);
Serial.println("Adafruit MLX90614 test");Â
mlx.begin();Â
 windowStartTime = millis();
 //initialize the variables we're linked to
 Setpoint = 100;
 //tell the PID to range between 0 and the full window size
 myPID.SetOutputLimits(0, WindowSize);
 //turn the PID on
 myPID.SetMode(AUTOMATIC);
}
void loop()
{
Â
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
Â
Serial.println();
delay(50);
Â
 Input = temp;
 myPID.Compute();
 /************************************************
 * turn the output pin on/off based on pid output
 ************************************************/
 if (millis() - windowStartTime > WindowSize)
 { //time to shift the Relay Window
  windowStartTime += WindowSize;
 }
 if (Output < millis() - windowStartTime) digitalWrite(RELAY_PIN, HIGH);
 else digitalWrite(RELAY_PIN, LOW);
}