Compilation error when using LowPower.h library with MySensors



  • Hi all,
    I would like to put my node on deepsleep (328p + rfm69hcw + battery):

    LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF);
    
    • I succeeded with going down to 17µA BUT ONLY with the lowpowerlab libraries

    • if I include LowPower.h in my MySensors sketch :

    //===== RFM config =====
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW //with H(CW)
    #define MY_RFM69_NEW_DRIVER
    #define MY_RFM69_FREQUENCY  RFM69_868MHZ
    #define MY_SIGNAL_REPORT_ENABLED
    
    #define MY_RFM69_IRQ_PIN 2
    #define MY_RFM69_CS_PIN 10
    
    //===== LOWPOWERLAB =====
    #include <LowPower.h> //get library from: https://github.com/lowpowerlab/lowpower
    //writeup here: http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/
    
    #include <MySensors.h>
    
    //========== TRANSMISSION ID ==========
    #define CHILD_ID_RX_RSSI        (4)
    
    //pr1: ===== vcc =====
    #include <Vcc.h>                      //https://github.com/Yveaux/Arduino_Vcc
    const float VccMin   = 0.0;           // Minimum expected Vcc level, in Volts.
    const float VccMax   = 3.3;           // Maximum expected Vcc level, in Volts.
    const float VccCorrection = 3.32 / 3.29; // Measured Vcc by multimeter 4.97 divided by reported Vcc 4.88
    Vcc vcc(VccCorrection);
    #define CHILD_ID_VCC        (10)
    
    //pr2: ===== sleep =====
    unsigned long SLEEP_TIME = 60000;           // Sleep time between reads (in milliseconds) 60000=1minute
    
    //========== Initialize general MESSAGE ==========
    MyMessage msgRxRSSI(CHILD_ID_RX_RSSI, V_CUSTOM);
    MyMessage msgVcc(CHILD_ID_VCC, V_VOLTAGE);
    
    //===================================
    //=              BEFORE              =
    //===================================
    void before()
    {
    
    } //FIN de before
    
    //===================================
    //=              SETUP              =
    //===================================
    void setup() {//no need Serial.begin(115200)
    
    }//FIN du SETUP
    //==========================================
    //=              PRESENTATION              =
    //==========================================
    void presentation()
    {
      // Send the sketch version information to the gateway and controller
      sendSketchInfo("ATC_report & Vcc", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_RX_RSSI, S_CUSTOM, "RX RSSI");
      present(CHILD_ID_VCC, S_MULTIMETER, "Vcc");
    
    } // FIN de PRESENTATION
    //===================================
    //=              LOOP               =
    //===================================
    void loop()
    {
      // send messages to GW
      // retrieve RSSI / SNR reports from incoming ACK
      send(msgRxRSSI.set(transportGetSignalReport(SR_RX_RSSI)));
    
      Serial.print("Receive RSSI: ");
      Serial.println(  RFM69_getReceivingRSSI ());
    
      //pr1:========== send vcc ==========
      float v = vcc.Read_Volts();
      Serial.print("VCC = ");
      Serial.print(v);
      Serial.println(" Volts");
    
      float p = vcc.Read_Perc(VccMin, VccMax);
      Serial.print("VCC = ");
      Serial.print(p);
      Serial.println(" %");
      send(msgVcc.set(v, 1));
    
      Serial.println("Enter in sleep time ...");
      //pr1:===== sleep =====
      LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); //COMPILATION ERROR  : libraries\LowPower-master\LowPower.cpp.o: In function `__vector_6':
    
      //sleep(SLEEP_TIME);                         //WORK BUT :  go from 25mA to 3.7mA (not µA)
      //gw.sleep(8000);             // MysensorsV1 :  3.7mA
    
    }// FIN de LOOP
    

    I have this error:

    Arduino: 1.8.13 (Windows 10), Card: "ATmega328, Yes (UART0), EEPROM retained, 328P / 328PA, BOD 2.7V, LTO disabled, External 16 MHz "
    libraries \ LowPower-master \ LowPower.cpp.o: In function `__vector_6 ':
    D: \ Documents \ Arduino \ SKETCH \ libraries \ LowPower-master / LowPower.cpp: 1190: multiple definition of `__vector_6 '
    sketch \ moteino_MySensors_vcc_sleep_pr3.ino.cpp.o: D: \ Documents \ Arduino \ SKETCH \ libraries \ MySensors / hal / architecture / AVR / MyHwAVR.cpp: 79: first defined here
    collect2.exe: error: ld returned 1 exit status
    exit status 1
    Compilation error for the ATmega328 card
    

    Someone to help me ?



  • In MySensors/hal/architecture/AVR/MyHwAVR.cpp
    find:

    ISR (WDT_vect)
    {
    }
    

    // Make it weak to allow local sketch implementation by changing it to

    ISR(WDT_vect, __attribute__((weak)))
    {
    }
    

    Make WDT_vect weak #717

    Or you can do it like this Compile problem: multiple definition of `__vector_6'
    Go to LowPower.cpp, find this lines

    ISR (WDT_vect)
    {
    	// WDIE & WDIF is cleared in hardware upon entering this ISR
    	wdt_disable();
    }
    

    and comment it

    This last solution worked for me to compile with lowpower lib, but I wanted to use Timer2 on and that is incompatible with Mysensors for now.



  • great thank you for your answer! 👍


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 24
  • 2
  • 2
  • 3

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts