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. Troubleshooting
  3. How to pass the #define for MySensors

How to pass the #define for MySensors

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 2 Posters 1.0k 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.
  • Ricardo JL RufinoR Offline
    Ricardo JL RufinoR Offline
    Ricardo JL Rufino
    wrote on last edited by
    #1

    I need to use the same technique in my library but is not working.
    I am using in my config.h

    #ifdef ODEV_API_KEY
    #define ODEV_API_KEY_REAL ODEV_API_KEY
    #endif
    
    #ifndef ODEV_API_KEY
    #define ODEV_API_KEY_REAL "*"
    #endif
    
    const char MQTT_TOPIC[] = ODEV_API_KEY_REAL "/in/ModuleName";
    
    

    If I put a #error at first condiftion, it really indicates is falling in this first condition, but MQTT_TOPIC is as if he had fallen in second

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      The "trick" we use in the mysensors library is to include code files (cpp) in the MySensors.h header file. A bit ugly but as the Arduino IDE has a very limited build system, it's the only way you can make defines in sketch visible in the code.

      1 Reply Last reply
      0
      • Ricardo JL RufinoR Offline
        Ricardo JL RufinoR Offline
        Ricardo JL Rufino
        wrote on last edited by Ricardo JL Rufino
        #3

        If I knew it could include cpf in a .h file I had done before ... =]
        Thanks for the tip.

        1 Reply Last reply
        0
        • Ricardo JL RufinoR Offline
          Ricardo JL RufinoR Offline
          Ricardo JL Rufino
          wrote on last edited by
          #4

          I have found some alternatives that can be used:
          https://electrohobby.ca/forum/showthread.php?tid=214&pid=1281

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          17

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          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