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. General Discussion
  3. Setting parameters before system load

Setting parameters before system load

Scheduled Pinned Locked Moved General Discussion
6 Posts 4 Posters 62 Views 4 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
    mariusl
    wrote on last edited by
    #1

    Hi
    I want to set some of my parameters prior to the mySensors code loading. I want to set the NodeId on my sensors and things like the WiFi credentials on the gateway. The gateway can be ESP8266 or ESP32.
    I noticed that was a preHwInit() function available. Will this allow me to set things like that before the code loads and if so where will I store or effect those parameters?

    1 Reply Last reply
    0
    • mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      NodeID is set by defining MY_NODE_ID. The assignment can be a variable if you want to set it dynamically yourself.

      In the same manner you can probably set MY_WIFI_SSID and MY_WIFI_PASSWORD. I am not aware if anyone has tried setting them dynamically before, so you'll probably have to experiment a bit.

      https://www.mysensors.org/download/sensor_api_20#node-boot-sequence describes when things are canned in the boot sequence.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mariusl
        wrote on last edited by
        #3

        Thanks for the reply. If use defined variables then I am sure it should be possible to do.
        As far as the dynamic setting is concerned, I want to connect the sensor serial port to a terminal and then set the variables that I need through text messages. There is an Arduino library called sCmd that has a very basic protocol that allows this kind of thing. There will be a button to put it into setup loop before hardware init and then I need to write the variables to the Eeprom. They will be retrieved at the next boot. Hence my need to know where the system puts it's config variables so that I don't go mess that up.

        mfalkviddM 1 Reply Last reply
        0
        • M mariusl

          Thanks for the reply. If use defined variables then I am sure it should be possible to do.
          As far as the dynamic setting is concerned, I want to connect the sensor serial port to a terminal and then set the variables that I need through text messages. There is an Arduino library called sCmd that has a very basic protocol that allows this kind of thing. There will be a button to put it into setup loop before hardware init and then I need to write the variables to the Eeprom. They will be retrieved at the next boot. Hence my need to know where the system puts it's config variables so that I don't go mess that up.

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

          @mariusl Cool use case, thanks for explaining.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Arvie_Mamayson
            wrote last edited by
            #5

            That’s a really clever way to handle provisioning! To make sure you don't stomp on the MySensors internal data, check out the MyEEPROM.h file in the library source. MySensors usually starts its storage from the very beginning of the EEPROM (index 0), but you can usually find a safe 'offset' higher up (like above 256 or 512) to store your custom sCmd strings. Just make sure your preHwInit() reads from that same offset before the MySensors engine takes over!

            1 Reply Last reply
            0
            • OldSurferDudeO Offline
              OldSurferDudeO Offline
              OldSurferDude
              wrote last edited by
              #6

              This is very cool. In order to provision my devices, I had two programs. I loaded the first that was used to set MY_NODE_ID in location 0 of the MyEEPROM (this is where MySensors puts it). Then I would load the MySensors program.

              The sCmd library is much better, though it would take up program space.

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


              21

              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