Running Average Coded

My project is to find the average temperature of industrial ovens through a J-Type thermocouple and the Adafruit Universal Thermocouple Amplifier MAX31856 Breakout... I went to Arduino Playground - RunningAverage to learn how and it all made sense, so I made the .h and .ccp folder and the code can read it but it keeps giving me this error code...

Arduino: 1.8.3 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\McCarthyJ\Documents\Arduino\Final_Code\Final_Code.ino:2:0:

C:\Users\McCarthyJ\Documents\Arduino\libraries\RunningAverage/RunningAverage.h:2:2: error: expected unqualified-id before ':' token

(:source lang=c:)

^

C:\Users\McCarthyJ\Documents\Arduino\libraries\RunningAverage/RunningAverage.h:2:2: error: expected ')' before ':' token

exit status 1
Error compiling for board Arduino/Genuino Uno.

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

I doubt the code arduino made is wrong so what should I do to fix this?

Thanks for any help!

Post the code, using code tags ("</>" button).

#include <Adafruit_MAX31856.h>
#include <RunningAverage.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 max = Adafruit_MAX31856(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 max = Adafruit_MAX31856(10);

RunningAverage myRA(10);
int samples = 10;

long count = 0;

void setup() {
  Serial.begin(115200);
  Serial.println("MAX31856 thermocouple test");
  pinMode(5, OUTPUT);
  myRA.clear(); // explicitly start clean
  
  max.begin();

  max.setThermocoupleType(MAX31856_TCTYPE_J);

  Serial.print("Thermocouple type: ");
  switch ( max.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
    case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
    case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
    case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
    case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
    case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
    case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
    case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
    case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
    case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
    default: Serial.println("Unknown"); break;
  }


}

void loop()

{
  {
  Serial.print("Cold Junction Temp: "); Serial.println(max.readCJTemperature());

  Serial.print("Thermocouple Temp: "); Serial.println(max.readThermocoupleTemperature());
  // Check and print any faults
  uint8_t fault = max.readFault();
  if (fault) {
    if (fault & MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
    if (fault & MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
    if (fault & MAX31856_FAULT_CJHIGH)  Serial.println("Cold Junction High Fault");
    if (fault & MAX31856_FAULT_CJLOW)   Serial.println("Cold Junction Low Fault");
    if (fault & MAX31856_FAULT_TCHIGH)  Serial.println("Thermocouple High Fault");
    if (fault & MAX31856_FAULT_TCLOW)   Serial.println("Thermocouple Low Fault");
    if (fault & MAX31856_FAULT_OVUV)    Serial.println("Over/Under Voltage Fault");
    if (fault & MAX31856_FAULT_OPEN)    Serial.println("Thermocouple Open Fault");
  }
  delay(1000);
{
  myRA.addValue(rn * 0.001);
  samples++;
  Serial.print("Running Average: ");
  Serial.println(myRA.getAverage(), 3);

  if (samples == 60)
  {
    samples = 0;
    myRA.clear();
  }
  delay(100);
}
  }
  {
    if (max.readThermocoupleTemperature() > 30)
    {
      digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1500);                       // wait for a second
      digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW
      delay(500);                       // wait for a second
    }
    else
    {
      digitalWrite(5, LOW);
    }
  }
}

This code is a combination of the thermocouple Amplifier, the running average and the code at the bottom just sets a light off at a certain temp that I can change

Someone needs to learn C.

"int samples = 10,11,12,13;"

This is technically correct, but belongs in an obfuscation contest.

What do you want samples to be? It can only be one number.

I know this is my first time coding so I'm slowing learning... I put that there because I wasn't sure which one I wanted to do and I just forgot to change it, it's supposed to be 10

I doubt the code arduino made is wrong so what should I do to fix this?

Unfortunately, you will find many things wrong within the Arduino Playground. I think the offending line is a uncommented comment. Just add the comment lines.

//(:source lang=c:)
RunningAverage.h

 (:source lang=c:)
#ifndef RunningAverage_h
#define RunningAverage_h
//
//    FILE: RunningAverage.h
//  AUTHOR: Rob dot Tillaart at gmail dot com
// PURPOSE: RunningAverage library for Arduino
//     URL: http://arduino.cc/playground/Main/RunningAverage
// HISTORY: See RunningAverage.cpp
//
// Released to the public domain
//

// backwards compatibility
// clr() clear()
// add(x) addValue(x)
// avg() getAverage()

#define RUNNINGAVERAGE_LIB_VERSION "0.2.04"

#include "Arduino.h"

class RunningAverage
{
public:
    RunningAverage(void);
    RunningAverage(int);
    ~RunningAverage();

    void clear();
    void addValue(float);
    void fillValue(float, int);

    float getAverage();

    float getElement(uint8_t idx);
    uint8_t getSize() { return _size; }
    uint8_t getCount() { return _cnt; }

protected:
    uint8_t _size;
    uint8_t _cnt;
    uint8_t _idx;
    float   _sum;
    float * _ar;
};

#endif
// END OF FILE

Okay I tried that and it didn't work it still gives me the same error code..

Post YOUR code.

I did it was the second thing I posted...

But you've corrected it since then, right?

Not really, I just changed it a bit and i edited the one I posted so it's correct

i edited the one I posted so it's correct

Obviously, it is not correct.

Post the code again, in a new post, together with the error message.

This is my code…

#include <Adafruit_MAX31856.h>
#include <RunningAverage.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 max = Adafruit_MAX31856(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 max = Adafruit_MAX31856(10);

RunningAverage myRA(10);
int samples = 10;

long count = 0;

void setup() {
  Serial.begin(115200);
  Serial.println("MAX31856 thermocouple test");
  pinMode(5, OUTPUT);
  myRA.clear(); // explicitly start clean

  max.begin();

  max.setThermocoupleType(MAX31856_TCTYPE_J);

  Serial.print("Thermocouple type: ");
  switch ( max.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
    case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
    case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
    case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
    case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
    case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
    case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
    case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
    case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
    case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
    default: Serial.println("Unknown"); break;
  }


}

void loop()

{
  {
    Serial.print("Cold Junction Temp: "); Serial.println(max.readCJTemperature());

    Serial.print("Thermocouple Temp: "); Serial.println(max.readThermocoupleTemperature());
    // Check and print any faults
    uint8_t fault = max.readFault();
    if (fault) {
      if (fault & MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
      if (fault & MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
      if (fault & MAX31856_FAULT_CJHIGH)  Serial.println("Cold Junction High Fault");
      if (fault & MAX31856_FAULT_CJLOW)   Serial.println("Cold Junction Low Fault");
      if (fault & MAX31856_FAULT_TCHIGH)  Serial.println("Thermocouple High Fault");
      if (fault & MAX31856_FAULT_TCLOW)   Serial.println("Thermocouple Low Fault");
      if (fault & MAX31856_FAULT_OVUV)    Serial.println("Over/Under Voltage Fault");
      if (fault & MAX31856_FAULT_OPEN)    Serial.println("Thermocouple Open Fault");
    }
    delay(1000);
    {
      myRA.addValue(rn * 0.001);
      samples++;
      Serial.print("Running Average: ");
      Serial.println(myRA.getAverage(), 3);

      if (samples == 60)
      {
        samples = 0;
        myRA.clear();
      }
      delay(100);
    }
  }
  {
    if (max.readThermocoupleTemperature() > 30)
    {
      digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1500);                       // wait for a second
      digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW
      delay(500);                       // wait for a second
    }
    else
    {
      digitalWrite(5, LOW);
    }
  }
}

This is the error code I keep getting…

Arduino: 1.8.3 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\McCarthyJ\Documents\Arduino\Final_Code\Final_Code.ino:2:0:

C:\Users\McCarthyJ\Documents\Arduino\libraries\RunningAverage/RunningAverage.h:2:2: error: expected unqualified-id before ':' token

 (:source lang=c:)

  ^

C:\Users\McCarthyJ\Documents\Arduino\libraries\RunningAverage/RunningAverage.h:2:2: error: expected ')' before ':' token

exit status 1
Error compiling for board Arduino/Genuino Uno.
Invalid library found in C:\Users\McCarthyJ\Documents\Arduino\libraries\Adafruit_Circuit_Playground: C:\Users\McCarthyJ\Documents\Arduino\libraries\Adafruit_Circuit_Playground
Invalid library found in C:\Users\McCarthyJ\Documents\Arduino\libraries\analog_sensors: C:\Users\McCarthyJ\Documents\Arduino\libraries\analog_sensors

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

The error message says the error is in a header file you didn't post.

//(:source lang=c:)

Okay I tried that and it didn't work it still gives me the same error code..

Proof please.

The error is in the code you didn't post, as clearly stated in the error message. Fix that by commenting out the offending line, as suggested earlier.

C:\Users\McCarthyJ\Documents\Arduino\libraries\RunningAverage/RunningAverage.h:2:2: error: expected unqualified-id before ':' token

(:source lang=c:)

//(:source lang=c:)
#ifndef RunningAverage_h
#define RunningAverage_h
//
//    FILE: RunningAverage.h
//  AUTHOR: Rob dot Tillaart at gmail dot com
// PURPOSE: RunningAverage library for Arduino
//     URL: http://arduino.cc/playground/Main/RunningAverage
// HISTORY: See RunningAverage.cpp
//
// Released to the public domain
//

// backwards compatibility
// clr() clear()
// add(x) addValue(x)
// avg() getAverage()

#define RUNNINGAVERAGE_LIB_VERSION "0.2.04"

#include "Arduino.h"

class RunningAverage
{
public:
    RunningAverage(void);
    RunningAverage(int);
    ~RunningAverage();

    void clear();
    void addValue(float);
    void fillValue(float, int);

    float getAverage();

    float getElement(uint8_t idx);
    uint8_t getSize() { return _size; }
    uint8_t getCount() { return _cnt; }

protected:
    uint8_t _size;
    uint8_t _cnt;
    uint8_t _idx;
    float   _sum;
    float * _ar;
};

#endif
// END OF FILE

That code your posted is probably not in "C:\Users\McCarthyJ\Documents\Arduino\libraries" which is where the code containing the error resides.

it is in there I double checked

The compiler does not lie.