Anyone tried compiler optimisations?



  • Im creating a wheatherstation based on a UNO with a lot of sensors on it and I have started to run out of memory on my UNO.

    I found a page that described how to compileroptimize regarding to executiontime and space.

    He is changing the -Os compiler flag to -O2

    Has anyone tried this?
    Is this possible with the MySensors library?


  • Mod

    @Martin-Tellblom it should work. But the result will probably be a compiled sketch that needs more flash (as the article says). Execution time is generally not a problem in mysensor sketches, so trading space (which is scarce) for time (which is already plentyful) is generally not beneficial.

    But if your code is strapped for speed and getting a faster arduino or optimizing the critical code path by hand is not an option, adjusting the compiler settings can be useful. And it can be fun experimenting with them.


  • Hardware Contributor

    @Martin-Tellblom said:

    I have started to run out of memory on my UNO.

    As the default compiler option in Arduino is the one using the less memory, I think you have no choice but to optimize your code, or switch to another board.
    Have you disabled the debug mode by commenting the #define MY_DEBUG line ? This will save a lot of flash space as the strings and serial writing instructions are not compiled.
    Else depending on the sensors you use, you can try to switch either to an Arduino Mega (plenty of inputs/outputs) or a board based on ESP8266. ESP8266 has limited I/O pin count and only one (and limited to 1V) analog input so it might not work out for your case if you are not mostly using i2c sensors.



  • The problem I saw when trying to use -O1 flag was that the size was less than the standard -Os (That should optimize according to space) , and thats strange.



  • @Nca78
    I can also combine with another MySensors Arduino mini for the rain metering.

    The problem I have is that the forcast is taking up alot of memory (and I don't know right now if I going to need that


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts