Multiple Relays Spanned Across Nodes
-
Hello All -
I ran in to an interesting issue over the weekend that I'm hoping I can get some help with.I have two identical nodes/sensors. Each Arduino has a water pulse meter and a relay (to control an actuator/valve).
I used the same forloop logic found in the relay example at: http://www.mysensors.org/build/relay
However, the relay was not discovered/added by Vera on the second node. The only way I could get it to include was if I started the forloop with sensor=2. This will give the first relay on the second node an ID of "2". This seemed like an odd necessity to me as it was coming from a different sensor/node.
Is this expected behavior?
for (int sensor=2, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
}All is well and both nodes are up and functioning. It just seemed like an ugly way to handle this situation and could cause trouble down the road as I add relays/sensors.
-
Are you sure you hadn't previously deleted a device with the same id/child id?
Vera sometimes keeps deleted devices in some hidden cache which is not cleared until you hard-reboot the box. If you try to add a new device with the same id it won't succeed until this cache is cleared.
-
@hek I've rebooted several times over the past few days while working on other sensors. However, your idea sounds valid.
So you're saying that I should be able to have multiple sensors running the example relay sketch on my network without issue, correct?
This should be fine because each individual node/arduino gets it's own ID so the relays on each Arduino should not conflict with its neighbors.
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