Combining 'Build' examples in to one Arduino
-
I'm looking to use the examples from https://www.mysensors.org/build and combine them together in one arduino sketch so that one node can communicate a number of pieces of information back to the controller via a MAX485 module and network
I understand this is quite simple and possible with multiple, one time actions. Simply double up on the items in the code
For instance an arduino Mega:-
Reading 10 button states https://www.mysensors.org/build/binary
-
Controlling 4 relay outputs https://www.mysensors.org/build/binary
And maybe even when a function is called periodically with a "sleep time" between reads, such as:
- Reading and updating temperature sensor https://www.mysensors.org/build/temp
However, it's not clear to me if this can be done with sensors/actuators that are constantly 'working' for instance:
-
Controlling the brightness (via PWM) of a LED https://www.mysensors.org/build/dimmer
-
Controlling ws2812 LED data signal similar to https://www.domoticz.com/forum/viewtopic.php?f=42&t=8039&sid=71a5c0904f9a1662ff5447d264e6bb78
Can I amalgamate these .ino files? Am I only limited by the PWM / SPI outputs? Do I need to understand interrupts? Can a button press here go to the controller, run through an automation rule (I use Openhab) and then action a relay on the same node?
I'm drawing up some Gerber files for bespoke PCBs - the answer to the above will determine whether each function requires its own Arduino pro mini or whether I can simply have the functions ancilliary devices (relay, mosfet, 12v supply) on the pcb. I'll be sure to include the PCB somewhere for anyone else who would benefit from it.
Many thanks in advance, Adam
-
-
@adds666 with enough skill, time and knowledge, it is probably possible to do all of it in one node. The MySensors library does not (at least not to my knowledge) prevent you from doing everything in one node.
If you haven't already, see https://forum.mysensors.org/topic/2597/combining-mysensors-examples/ for an instruction on how to combine two sketches.
With that said, doing everything in one node will increase complexity. Mistakes / nuances that otherwise would not be a problem might make strange things happen. And troubleshooting a complex node is at least 10x harder than troubleshooting a node with only one task.
-
@mfalkvidd many thanks for coming back. I think I'll keep more complex things seperate, however will explore multiple binary sensors and relays on the same node.
Thanks