I can't use 2 codes for my thermo couple " redefinition of 'void loop() " "redefinition of Nanoshield_Termopar"

Hi I have two codes, both control 2 NanoShield MAX 31856, but when I've integrated them in 2 different tabs I had a problem, i cant use 2 Loops or two equal librarys. This is the error: " redefinition of 'void loop() " or "redefinition of Nanoshield_Termopar".

this is the codes:

#include "Nanoshield_Termopar.h"
#include <SPI.h>


Nanoshield_Termopar termopar2(2, TC_TYPE_K, TC_AVG_OFF );


void loop()
{
  
 termopar2.read();


Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
 Serial.println("Temperatura interna °C  2 ");  
Serial.println(termopar2.getInternal());
Serial.println("                       ");
Serial.println("Temperatura externa °C  2 ");
Serial.println(termopar2.getExternal());
delay (2200);                  
Serial.println("     Carregando...         ");
delay (700);
}

And

#include "Nanoshield_Termopar.h"
#include <SPI.h>


Nanoshield_Termopar termopar2(2, TC_TYPE_K, TC_AVG_OFF );

void setup() {
  Serial.begin(9600);
termopar2.begin();
} 

void erros(){
if (termopar2.isOpen()){
 Serial.println ("circuito aberto");
} else if (termopar2.isOverUnderVoltage()) {
    Serial.print("Overvoltage/Undervoltage");
  } else if (termopar2.isInternalOutOfRange()) {
    Serial.print("Internal temperature (cold junction) out of range)");
  } else if (termopar2.isExternalOutOfRange()) {
    Serial.print("External temperature (hot junction) out of range");
}
}  

void loop()
{
  
 termopar2.read();


Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
Serial.println("                       ");
 Serial.println("Temperatura interna °C  2 ");  
Serial.println(termopar2.getInternal());
Serial.println("                       ");
Serial.println("Temperatura externa °C  2 ");
Serial.println(termopar2.getExternal());
delay (2200);                  
Serial.println("     Carregando...         ");
delay (700);
}

Thanks.

Two sketches in two tabs must not conflict. Your two sketches both have conflicting "loop()" and "setup()" and many variables.

1 Like

yes but you know how can I use this two codes at the same time without having this conflict

Here's a couple of starting points gleaned from a simple forum search:

3 Likes

See post #2.

1 Like

Thanks bro :smiley:

:slight_smile: thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.