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. Feature Requests
  3. Set output pin High before message initialising

Set output pin High before message initialising

Scheduled Pinned Locked Moved Feature Requests
5 Posts 3 Posters 1.1k 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.
  • A Offline
    A Offline
    ArduiSens
    wrote on last edited by
    #1

    Is there a way to set an output pin high before sending the init message to the gateway?
    so before
    // Initialize messages
    MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP);
    MyMessage sleepMsg(CHILD_ID_SLEEP, V_TEXT);

    I want to save energy (300µA) so I want to power the MAX485 only when sending messages.
    This is manageable in the sketch (set output pin high after returning from sleep mode, low before sleep) but at first start it isn't. I walked through the libraries but I didn't find the code where the DE pin is managed in order to send data to the MAX chip whch will send the data to the gateway. If I could find this I can make a similar set-up. Thanks in advance.

    MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

    1 Reply Last reply
    0
    • rejoe2R Offline
      rejoe2R Offline
      rejoe2
      wrote on last edited by
      #2

      Not sure, if I got your ideas right. Imo, (de-) powering the AMX485 may just be fine within the loop(). Some remarks wrt this (afaik):

      • the MyMessage-definitions are just definitions to prepare sending command structures, but there's no direct send command issued. So there's no need to (de-)power any transceiver at this point in time
      • the DE-PIN is not related to powering the transceiver - it just indicates the direction of communication (high, when receiving, low while sending, maybe pulled to low from transceiver side when receiving starts (RE) to trigger an interrupt at PIN2)
      • when switching transceiver on manually in loop(), you may need a short wait() to make sure, transceiver is correctly initialised (didn't test anything like that bevore).

      Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

      1 Reply Last reply
      1
      • A Offline
        A Offline
        ArduiSens
        wrote on last edited by
        #3

        hello rejoe2, you have to power the MAX chip before you come into the loop() because the first time you have to send the node configuration to the gw.
        Putting the

        pinMode(SENSOR_POWER_PIN, OUTPUT);
        digitalWrite(SENSOR_POWER_PIN, HIGH);

        code in the setup() is also too late.
        If the MAX isn't powered before, you get error messages because the node can't connect to the gw.

        btw the DE-PIN is not related to powering the transceiver --> right, it's a similar management, it was an example to find a solution

        MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

        mfalkviddM 1 Reply Last reply
        0
        • A ArduiSens

          hello rejoe2, you have to power the MAX chip before you come into the loop() because the first time you have to send the node configuration to the gw.
          Putting the

          pinMode(SENSOR_POWER_PIN, OUTPUT);
          digitalWrite(SENSOR_POWER_PIN, HIGH);

          code in the setup() is also too late.
          If the MAX isn't powered before, you get error messages because the node can't connect to the gw.

          btw the DE-PIN is not related to powering the transceiver --> right, it's a similar management, it was an example to find a solution

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

          @arduisens I am not at all familiar with RS485, but maybe the before() function or preHwInit() is what you're looking for?

          See also https://github.com/mysensors/MySensors/issues/927 for an attempt to clarify which order the different functions are called.

          1 Reply Last reply
          1
          • A Offline
            A Offline
            ArduiSens
            wrote on last edited by
            #5

            @mfalkvidd
            OK, the before() works!

            0 MCO:BGN:INIT NODE,CP=RSNNA--,VER=2.1.1
            3 MCO:BGN:BFR
            running before() function
            2006 TSM:INIT
            2011 TSF:WUR:MS=0
            2012 TSM:INIT:TSP OK
            2014 TSM:INIT:STATID=25
            2016 TSF:SID:OK,ID=25
            2018 TSM:FPAR
            2036 TSF:MSG:SEND,25-25-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
            2850 TSF:MSG:READ,0-0-25,s=255,c=3,t=8,pt=1,l=1,sg=0:0
            2855 TSF:MSG:FPAR OK,ID=0,D=1
            4043 TSM:FPAR:OK

            thanks for the cooperation mfalkvidd & rejoe2

            MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

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


            19

            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