Hi,
I am programming some Arduino sensors and other things and I want to make them work together, some activated with an IR sensor. If I use ONLY the code with that library, everything works. In the code you will find at the end of the post, I always get the same error:
Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "IRremote.h"
Used: C:\Users\matt\Documents\Arduino\libraries\IRremote
Not used: C:\Program Files (x86)\Arduino\libraries\IRremote
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 can't post the verbose output because it has more than 18000 characters.
The code about the IR sensor in the below code is a test, to see if the library worked. As you can understand from the subject, the test failed. I tried removing the IR library, and everything worked. Here the code:
#include <IRremote.h>
#include <LiquidCrystal.h>
#include <Servo.h>
#include <SPI.h>
//#include <MFRC522.h>
#include <RFID.h>
#include <Stepper.h>
#include <SimpleDHT.h>
int temperatureInterval = 1000;
int IRinterval = 50;
int alarmInterval = 500;
int ActualAlarmInterval = 1500;
int RFIDinterval = 100;
int stepperTendaInterval = 2457.6;
int IRreceiverInterval = 100;
int ventolaInterval = 10000;
int DHT11Interval = 10000;
int SDA_DIO = 53;
int RESET_DIO = 9;
int delayRead = 1000;
const String codiceGiusto = "70EFBE1938";
const int stepsPerRevolution = 4096;
RFID RC522(SDA_DIO, RESET_DIO);
Stepper tenda(stepsPerRevolution, 24, 25, 26, 27);
Stepper door(stepsPerRevolution, 30, 31, 32, 33);
int i = 0;
//const int tempPin = A0; // analog pin for the temp sensor
float celsius = 0; //all for the termometer
float millivolts; //all for the termometer
int tempSensor; //all for the termometer
int KitchenLed = 2;
int entranceLed = 3;
int thirdRoomLed = 4;
int fourthRoomLed = 5;
int IRreceiver = 9;
int alarmLed = 11;
int alarmBuzzer = 10;
int triggerPort = 28;
int echoPort = 29;
int receiver = 22;
int pompa = 39;
int ventola = 53;
int DHT11 = A2;//???????????????????
SimpleDHT11 dht11;
long temperaturePreviousMillis = 0;
long IRreceiverPreviousMillis = 0;
long alarmPreviousMillis = 0;
long ActualAlarmPreviousMillis = 0;
long RFIDpreviousMillis = 0;
long ventolaPreviousMillis = 0;
long DHT11PreviousMillis = 0;
bool isAlarmOn = true;
bool isAlarmTriggered = false;
Servo washingMachine;
IRrecv irrecv(receiver);
decode_results results;
void setup() {
Serial.begin(9600); // start serial communication
pinMode( triggerPort, OUTPUT );
pinMode( echoPort, INPUT );
washingMachine.attach(22);
Serial.println("Premere sul telecomando:");
Serial.println("1 = accendi luce della cucina");
//Serial.println("2 = turn on second light");
//Serial.println("3 = turn on third light");
//Serial.println("4 = turn on fourth light");
//Serial.println("5 = turn on fifth light");
Serial.println("6 = turn on the dishwasher");
//Serial.println("7 = show clock on LCD screens");
//Serial.println("6 = turn on servo");
//lcd.begin(16, 2);
//lcd.clear();
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
RC522.init(); // Init MFRC522 card
pinMode(KitchenLed, OUTPUT);
irrecv.enableIRIn();
}
void loop() {
// if (millis() - temperaturePreviousMillis > temperatureInterval ){ //temperature
// temperaturePreviousMillis = millis();
// int aRead = 0;
// aRead = analogRead(pin);
// Serial.print("Analog = ");
// Serial.print(aRead);
// float tempC = aRead * 0.48875; // convert in centigrades
// Serial.print(" Temp = ");
// Serial.println(tempC);
// lcd.print("Temp = ");
// lcd.print(tempC);
// lcd.print("º C");
//}
if (millis() - alarmPreviousMillis > alarmInterval ){
alarmPreviousMillis = millis();
if (isAlarmOn == true) {
//porta bassa l'uscita del trigger
digitalWrite(triggerPort, LOW );
//invia un impulso di 10microsec su trigger
digitalWrite(triggerPort, HIGH );
delayMicroseconds( 10 );
digitalWrite(triggerPort, LOW );
long duration = pulseIn(echoPort, HIGH);
long r = 0.034 * duration / 2;
if( duration > 38000 ) {
Serial.println( "fuori portata");
}
else {
Serial.print( r ); Serial.println( "cm" );
}
if (duration < 912) {
isAlarmTriggered = true;
}
}
}
if (millis() - ActualAlarmPreviousMillis > ActualAlarmInterval ){
ActualAlarmPreviousMillis = millis();
if (isAlarmTriggered == true) {
digitalWrite(alarmLed, HIGH);
delay(750);
digitalWrite(alarmLed, LOW);
delay(750);
}
}
if (millis() - ActualAlarmPreviousMillis > ActualAlarmInterval ){
ActualAlarmPreviousMillis = millis();
if (isAlarmTriggered == true) {
tone(19, 330, 375);
delay(375);
tone(19, 262, 375);
delay(375);
tone(19, 330, 375);
delay(375);
tone(19, 262, 375);
delay(375);
}
}
if (millis() - RFIDpreviousMillis > RFIDinterval ) {
RFIDpreviousMillis = millis();
byte i;
// Se viene letta una tessera
if (RC522.isCard())
{
// Viene letto il suo codice
RC522.readCardSerial();
String codiceLetto ="";
Serial.print("Codice letto: ");
for(i = 0; i <= 4; i++) //Lettura del codice della scheda e composizione della stringa
{
codiceLetto+= String(RC522.serNum[i],HEX);
codiceLetto.toUpperCase();
}
Serial.print(codiceLetto); //Viene stampato il codice letto
if(codiceLetto.equals(codiceGiusto))
{
Serial.println(" --> CODICE VALIDO"); //Se il codice letto è uguale a quello atteso verrà stampato "CODICE VALIDO", altrimenti verrà stampato "CODICE ERRATO"
for (i = 0; i<1350; i++) {
door.step(-15); //Un passo in senso orario.
delay(10);
i = (i+1);
}
for (i = 1350; i>0; i--) {
door.step(15); //Un passo in senso orario.
delay(10);
i = (i-1);
}
}
else
{
Serial.println(" --> CODICE ERRATO");
}
delay(1000);
}
}
if (millis() - IRreceiverPreviousMillis > IRreceiverInterval ){
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX);
irrecv.resume(); // receive the next value
delay(10);
}
}
if (millis() - ventolaPreviousMillis > ventolaInterval ){
ventolaPreviousMillis = millis();
if ((temperature) >= (25)) {
digitalWrite(ventola, HIGH)
} else {
digitalWrite(ventola, LOW)
}
}
if (millis() - DHT11PreviousMillis > DHT11Interval ){
DHT11PreviousMillis = millis();
byte temperature = 0;
byte humidity = 0;
byte data[40] = {0};
if (dht11.read(DHT11, &temperature, &humidity, data)) {
return;
}
Serial.print("Sample RAW Bits: ");
for (int i = 0; i < 40; i++) {
Serial.print((int)data[i]);
if (i > 0 && ((i + 1) % 4) == 0) {
Serial.print(' ');
}
}
Serial.println("");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" %");
//lcd.clear();
//lcd.setCursor(0, 0);
//lcd.print((int)temperature); lcd.print(" *C, ");
//lcd.setCursor(0, 1);
//lcd.print((int)humidity); lcd.println(" %");
// DHT11 sampling rate is 1HZ.
delay(1000);
}
}