Library Crashes

Hi, im new to arduino. Can anyone help me to solve this problem? I think it is crashing problem between 2 libraries. Thank you.

Error Code:
RTC1307\RTClib.cpp.o:(.bss.i+0x0): multiple definition of `i'
processing_interrupt.cpp.o:(.bss.i+0x0): first defined here

#include <avr/io.h>
#include <avr/interrupt.h>
#include <RTClib.h>

That's your entire sketch?

How to use this forum

This is my sketch:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <Wire.h>
#include <RTClib.h>
#include <VirtualWire.h>

#define LEDPIN 13
#undef int
#undef abs
#undef double
#undef float
#undef round

RTC_Millis RTC; 
int seconds = 0;
int i = 0 , j = 0;
int storage [100] ;

int tempvoltage;
int k = 0; 
char verify[2];
int precision1;
int precision2;
int precision3;
int mult;
float charf1;
 
void setup()
{
    
     Serial.begin(9600);	  // Debugging only
    vw_set_ptt_inverted(true);    // Required for RX Link Module
    vw_setup(2000);                   // Bits per sec
    vw_set_rx_pin(11);           // We will be receiving on pin 23 (Mega) ie the RX pin from the module connects to this pin. 
    vw_rx_start();                      // Start the receiver 
    vw_set_tx_pin(3);     
  
  
 
    pinMode(LEDPIN, OUTPUT);
 
    // initialize Timer1
    cli();          // disable global interrupts
    TCCR0A = 0;     // set entire TCCR1A register to 0
    TCCR0B = 0;     // same for TCCR1B
 
    // set compare match register to desired timer count:
    OCR0A = 256;
    // turn on CTC mode:
    TCCR0B |= (1 << WGM12);
    // Set CS10 and CS12 bits for 1024 prescaler:
    TCCR0B |= (1 << CS10);
    TCCR0B |= (1 << CS12);
    // enable timer compare interrupt:
    TIMSK0 |= (1 << OCIE1A);
    // enable global interrupts:
    sei();
    
    
}
 

 
ISR(TIMER0_COMPA_vect)
{
        seconds++;
    if (seconds == 300)
    {
        seconds = 0;
        readMySensor();
    }
}


void loop()
{
     uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
        
        digitalWrite(13, true); 
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	  verify[1] = buf[i]  ;
         
          Serial.println(verify[1]);
	}
       
       if (verify[1] == 'k')
       {
         vw_rx_stop();
          for (j = 0; j < k; j++)
          {
                tempvoltage = storage [j];
               serialPrintFloat(tempvoltage);
         
          }
          vw_rx_start();  
       }
	
        digitalWrite(13, false);
    }
     

 

}

void readMySensor()
{
      digitalWrite(13, true);
      int sensorValue = analogRead(A0);
      float voltage = sensorValue * (5.0 / 1023.0);
        Serial.print("sensor:");
      Serial.println( voltage );
      precision1 = voltage * 1000;
      precision2 = voltage * 100;
      precision2 = precision2 * 10;
      precision1 = precision1 - precision2 ;
      if (precision1 >= 5)
      {
        precision2 = (voltage * 100) + 1;
         storage[k] = precision2 ;
       }
      else 
    {
      storage[k] = voltage * 100 ;
    }
      digitalWrite(13, false);
      k++ ;
     if (k==100)
     {
      k = 0;
     }
}


void serialPrintFloat( int f ){
int charnum1 = (int)f/100;
int charnum2 = ((int)f/100)*100;
charnum2 = f - charnum2 ;
char msg[24];
sprintf(msg, "%i.%i", charnum1,charnum2);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
}

HERE ARE MY ERRORS:

RTC1307\RTClib.cpp.o:(.bss.i+0x0): multiple definition of `i'
processing_interrupt.cpp.o:(.bss.i+0x0): first defined here

ANY ADVISE PLEASE? :slight_smile:

ANY ADVISE PLEASE?

Yes. Stop screaming. We may be a bunch of grumpy old men, but we aren't deaf.

Where did you get the RTClib library that you are using?

What is your sketch called?

Why are you (trying to) do(ing) Serial output in your ISR? Serial output requires interrupts to work. Interrupts are disabled while your ISR is executing.

serialPrintFloat() doesn't. That name sucks. Fix it.

Why do YOU have a global variable called i and a local (to loop()) variable called i?

Why is verify global? Why are you only ever using the second element of the array?

Yes. Stop screaming. We may be a bunch of grumpy old men, but we aren't deaf.

I did not mean to scream. I forgotten to turn off Caps Locks button. I hereby apologize for leading to misunderstanding. Sorry.
By the way, thank you for the advises and suggestions. I had remove the global variable "i" and it's able to be compiled.
Although it's still have some bug, again, thanks for the fast reply and advises. :slight_smile:

Without seeing all the other libraries, I have to guess that someone has, rather bizarrely, declared:

extern int i;

It looks like it is possibly in processing_interrupt.cpp, however I'm not sure what library that belongs to.

I would guess that two people have inexplicably chosen to name a global variable i. Poor choice by both of them. One of them was the person who wrote the sketch that limzhengtong posted. I suspect the other was the person who coded the RTC1307 library.

Lol. Next they'll be doing:

extern int temp;

PeterH:
I would guess that two people have inexplicably chosen to name a global variable i.

Just the one, because when limzhengtong removed his own "int i" it compiled.