Swich a pin on the slave, from low to high, by a command on the master?

Is it possible to swich a pin on the slave, from low to high, by a command on the master?

More precisely? Coil?

for example, the master should for example switch pin 12 on the slave from high to low

Yes, I understand. But how it's implemented in the protocol? Is it Modbus? Do you have some protocol documentation?

It can be as simple as requesting slave X to turn coil x high or low.
Or completely something else....

i have , like above the max485 modules
i want to try to contro 7 slaves by 1 master

I suspect that @Hedalen uses (or wants to use) a simple serial data transfer (e.g. something like Gammon Forum : Electronics : Microprocessors : RS485 communications), no modbus.

Master and slave code written by himself.

Ahh, sorry for confusion. I expected communication with "some" slave device.
I should read the thread first... :roll_eyes:

@Hedalen ,

Topic split from another topic. Please do not add your own questions to the end of other people's topics.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

so one transmitter and many receivers. presumably no issue with transmitting in both directions

i have a model RR signaling system that has multiple nodes that need to share information. It uses Wifi. It sends broadcast UDP messages.

a typical msg indicates the status of a block, for example that block 101 is occupied

blk 101 1

the message is received by all nodes (slaves in your case) and they either use or ignore the information

you can do similar, sending a message to control a relay, by ID and the receiver will either process the request if it handles a relay with that ID

You have to be much more specific and tell us:

what exact type of microcontroller are you using?

Do you want to switch only a single IO-pin per slave or more?

If more than one IO-pin per slave: how many IO-pins per slave?

What are the distances between your master and the slaves?

And last but not least write down a pretty detailed description of your complete project.

It might well be that it is not required to have 8 microcontrollers all connected by a max485-bus to get your project running.

on the master 8 push buttons for every slave one
i use 3 mega, one as master, 2 as slave and 5 uno as slave
on the slave just one single output pin to switch
the largest distance from the master to the slave is 20 meters

As you did not post a detailed description of your project more questions:

What are the 8 slaves doing with this single IO-pin?

  • switching a single relay and that's all? => use direct wiring without a microcontroller
  • each slave is running a complex program that does a lot more things locally on the slave which is influenced by this single-bit-signal of the master
  • each slave is running a complex program that does a lot more things locally on the slave which is NOT influenced by this single-bit-signal of the master just switch on/off this single io-pin by the master

shall these 8 push-button on the master make the slaves-IO-pin just mirroring the pushbutton state?
master-push-button is pressed down => slave-IO-pin is HIGH
master-push-button is released=> slave-IO-pin is LOW

or

shall a push on a master-button toggle the related slave-IO-pin?

master-push-button pressed down and released slave-IO-pin HIGH
master-push-button pressed down and released slave-IO-pin LOW
master-push-button pressed down and released slave-IO-pin HIGH
master-push-button pressed down and released slave-IO-pin LOW
master-push-button pressed down and released slave-IO-pin HIGH
....

As you can see from all these questions. It makes sense to post a pretty detailed description of what you want to do all in all in the end

seems straight forward

yes , the master pushbuttons shall toggle the port on the slaves, only to swith a relay on and of

What is so hard about answering ALL questions?

What is so hard about describing your complete project ?

  • Does your keyboard wear out?
  • does your datavolume exhaust?

sorry for that

1 Like

It should be easy with RS485. Follow Gammon Forum indications as suggested by @sterretje post #6.

You should find Serial<->RS485 modules for cheap in China (or anywhere else) such as these.

Send short text commands such as "M6P12L1<CRC>CR" for Module 6, Pin 12, Level 1 (= HIGH) followed by any CRC (a checksum to "make sure" the message hasn't been altered) and Carriage Return to end the message.

Peripheral module should acknowledge with something like "M6P12L1OK<CRC>CR".

If you're a beginner, you don't really need to think ahead (too much), solve the problems as they appear...

i am a very very beginner, with very less knowledge about program language to Arduino

Start with easy tutorials such as Led Blink and Push Button or any others and build on that...
Using Wokwi, or any other Arduino simulator, you don't even have to wait for the hardware to arrive. Not to mention short circuit avoidance...

1 Like

Two days ago you got a link to an site explaining serial communication.
Have you read it? If something wasn't clear - what do you still need to know?