Set output pin High before message initialising
Is there a way to set an output pin high before sending the init message to the gateway?
// Initialize messages
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.
rejoe2 last edited by
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).
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.
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
See also https://github.com/mysensors/MySensors/issues/927 for an attempt to clarify which order the different functions are called.
OK, the before() works!
0 MCO:BGN:INIT NODE,CP=RSNNA--,VER=2.1.1
running before() function
2012 TSM:INIT:TSP OK
2855 TSF:MSG:FPAR OK,ID=0,D=1
thanks for the cooperation mfalkvidd & rejoe2