Temperature Sensor example on Pro Mini ATmega168 not compiling



  • The sketch in the example of the temperature sensor is not compiling for an Arduino Pro Mini ATmega168.
    On the Codebender browser pluging I get error
    There is not enough space!
    And in my Arduino IDE on my machine I get error :
    ....Arduino\libraries\MySensors\utility\LowPower.cpp:828:3: note: in expansion of macro 'lowPowerBodOn'
    lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
    ^
    Error compiling.

    I am using the latest IDE 1.6.1 and the latest MySensor Libraries. All is compiling for my Arduino Mega and I also tested it for an Arduino Pro Mini ATmega328 which also works fine in both IDE as the Codebender pluging.

    I am not sure (still learning) but I reckon the ATnega168 has not enough memory or storage to cope with this sketch.

    If anyone has a tip it would be more than welcome !

    I might be wrong but if I am not it would be nice for noobs like me to mention this somewhere in the article.

    I see that the shop's link has just been adjusted as AliExpress link to the
    Arduino Pro Mini Compatible 5V was pointing to the ATmega168 just an hour ago.
    Might have been a slip up, no biggie it only costed me a few cents but I was hoping to build my remote temperature sensor and now I have to wait again a few weeks for the ATmega328 shipment.

    [EDIT]
    Just checked most of the examples on the website here, and so for NONE of the sketches is compiling for the ATmega168.
    😞



  • @sj44k said:

    Arduino Pro Mini ATmega168

    I have Arduino1.6.1 on my systems and Arduino1.0.6. On 1.0.6 under Tools->Board I have "Arduino Pro or Pro Mini w/ ATmega168". Under Arduino1.6.1 I dont have any boards listed with ATmega168. Is the issue maybe that the ProMini w/ ATMega168 is not supported with the latest version of Arduino? Maybe you need to fall back to the 1.0.x series? Someone who understands all the boards better then me may be able to weigh in.



  • @sj44k It will compile if you disable debug in MyConfig.h , but I allso figured out that the temp sensor is the only sensor that will fit on the ATmega168.

    http://www.mysensors.org/build/debug



  • I've been buying my ATMega chips from "Banggood.com".

    AtMega328P-PU

    Costs £2.02 for one, but multi buy is even cheaper and free shipping, yes they ship from China so it takes a while but so far they have worked fine for me. Even bought the Radios from them, and they are working fine.

    They don't have the Arduino boot loader installed, but if you already have an Arduino that's easy to fix and saves.



  • @reddy11
    Forgive me my incompleteness, but I the ATmega168 is the processor on the Arduino Pro mini.
    You can find the pro Mini with the ATmega168 and ATmega328 cpu, just buy the 328 costs 10cents more but gives you double the flash / memory and eeprom capicity (check the link in my initial post)

    @pjeterinfo
    Thank you sir, makes sense, will try this tonight and revert.

    @GuyP
    Yep exact my conclusion now, I just got mislead by the "wrong" link of the Arduino Pro Mini 5v at the shop section of this website, the aliexpress link pointed to a Arduino Pro mini Atmega168, this has been corrected to the right Atmega238 version (which is only 10 cents more expensive)

    [Few Hours later]
    I disabled Debugging, and removed these lines 818 to line 830 from the file LowPower.cpp

    	if (bod == BOD_OFF)	
    	{
    		#if defined __AVR_ATmega328P__
    			lowPowerBodOff(SLEEP_MODE_EXT_STANDBY);
    		#else
    			lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
    		#endif
    	}
    	else	
    	{
    		lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
    	}
    
    

    Sketch is now compiling, but less than 1% too big.
    I will try an older version of the Mysensors library as current 1.4 is just a little bit too big.

    [And a few hours further]
    I tried a lot but I am not able to get rid of this error :

    Sketch uses 14,366 bytes (100%) of program storage space. Maximum is 14,336 bytes.
    Global variables use 507 bytes (49%) of dynamic memory, leaving 517 bytes for local variables. Maximum is 1,024 bytes.
    processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
    

    Anyone an idea ? I disabled the debug in MyConfig.h but I'm not able to get it to compile 😞

    Yeah FIXED it 🙂
    Won some space by edit line 53 and changed it to :

    // Fetch and round temperature to one decimal
    float temperature = static_cast<float>(static_cast<int> (sensors.getTempCByIndex(i) * 10.)) / 10.;
    

    I will only need the sensor to have Celsius readouts and this gave me exactly enough room to compile this beautiful sketch 🙂

    Sketch uses 14,308 bytes (99%) of program storage space. Maximum is 14,336 bytes.
    Global variables use 507 bytes (49%) of dynamic memory, leaving 517 bytes for local variables. Maximum is 1,024 bytes. 
    

    And it's official, the Temperature sketch is working I just build it successful with all components and it is communicating with my Raspberry PI 👍
    I'm quite curious how long it will run on a battery !



  • I too have fallen for the 168 trap - ordered a few of these off eBay and now realized there is not enough space for the sketch 😞

    I only plan to run 1 temp sensor on the 168 so tried the above but commenting out the code the LowPower.cpp does not fix the issue.

    Has anyone managed to successfully strip out enough code on library 1.5 to get this to compile?


  • Mod

    MySensors version 1.6 is supposedly 20% smaller than 1.5, so you might want to try your luck with the development branch.



  • Thanks a lot - that did the trick!

    Ran a few tests for comparison and its a lot smaller.

    API 1.4 - IDE 1.6.5
    Sketch uses 14,324 bytes (99%) of program storage space. Maximum is 14,336 bytes.
    
    API 1.5 IDE 1.6.5
    Sketch uses 14,504 bytes (101%) of program storage space. Maximum is 14,336 bytes.
    
    API 1.6 dev IDE 1.6.5
    Sketch uses 12,240 bytes (85%) of program storage space. Maximum is 14,336 bytes.
    

Log in to reply
 

Suggested Topics

  • 33
  • 17
  • 2
  • 5
  • 2
  • 8

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts