Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Anyone tried compiler optimisations?

Anyone tried compiler optimisations?

Scheduled Pinned Locked Moved Development
5 Posts 3 Posters 1.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martin Tellblom
    wrote on last edited by
    #1

    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?

    MySensors MQTT Client Gateway, Openhab, Dashing, Razberry, 1-wire

    mfalkviddM N 2 Replies Last reply
    0
    • M Martin Tellblom

      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?

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      @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.

      1 Reply Last reply
      0
      • M Martin Tellblom

        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?

        N Offline
        N Offline
        Nca78
        Hardware Contributor
        wrote on last edited by
        #3

        @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.

        M 1 Reply Last reply
        1
        • M Offline
          M Offline
          Martin Tellblom
          wrote on last edited by
          #4

          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.

          MySensors MQTT Client Gateway, Openhab, Dashing, Razberry, 1-wire

          1 Reply Last reply
          0
          • N Nca78

            @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.

            M Offline
            M Offline
            Martin Tellblom
            wrote on last edited by
            #5

            @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

            MySensors MQTT Client Gateway, Openhab, Dashing, Razberry, 1-wire

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            18

            Online

            12.0k

            Users

            11.2k

            Topics

            113.4k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular