Combining 'Build' examples in to one Arduino

  • I'm looking to use the examples from 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:

    And maybe even when a function is called periodically with a "sleep time" between reads, such as:

    However, it's not clear to me if this can be done with sensors/actuators that are constantly 'working' for instance:

    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

  • Mod

    @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 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.


Log in to reply

Suggested Topics

  • 87
  • 2
  • 8
  • 3
  • 10
  • 7