Optocoupler linking two Arduinos .... or not

I have a project i'm working on where by when a digital pin on the Arduino MQTT client goes high, i want to send that information to an Arduino UNO which will send a P2P message to operate a motorised valve.

Can I connect two digital pins together, one on the MQTT directly to the other on the UNO? or
do I need to use an optocoupler?

Thank you.

As long as their grounds are common, and the signalling voltage is appropriate for both ends.
You could pt a small current limiting resistor (e.g. 2K2) in the signal line - in case something unexpected happens.

Yes, as long as both are working at the same voltage, and both boards need a common GND. The Uno works at 5V. which Arduino are you using for the MQTT client and why can't it be used to control the valve directly without a further Arduino

There is no type of Arduino called "MQTT" that I can find. MQTT is a software communications protocol. Similarly, "P2P" simply means "point to point" so does not clearly describe what you are doing. Please clarify your explanation.

What I can say is that using 2 Arduino is usually a mistake. Only an expert would know when it would be appropriate, when beginners ask about using multiple Arduinos as a solution, they are almost always wrong.

Opto-isolators are normally used to protect one circuit from damage by another, usually because of high voltages, or when two circuits cannot share the same ground for some reason. Is this the case for your circuit?

The MQTT client is an Arduino Mega. It gets information from the gateway about moisture levels under trees. Dependent on the value, an instruction is sent via a P2P LoRa link to turn the watering on via a motorised valve located near the trees.


Any reason you can't have the Mega work directly with the Lora unit send instructions to the other Lora at the trees.

Can you post a block diagram of how you see your project layed out?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Thank you for all your responses. I appreciate all the advice.

Here are the line-diagrams of what I'm trying to do.

There are two plantations which are labelled top left corner "Lorraine's abortorium" and "Larry's abortorium". They are about 500m apart.

At Larry's end there is Tank2 (33,000L) which feeds stock and waters the trees.

You will see on Larry's that there is some RAK WisBlock modules that tracks the level of water in Tank2 and sends that data back to the RAK7294 Gateway in the barn. This informs the management of water delivery to Tank2.

There is a motorised valve which is controlled via the 433MHz P2P LoRa radio, simply open or closed, but instructed from the barn and timed from the barn.

There is a probe under one tree. That moisture information is also sent back to the gateway which advises the Arduino Mega MQTT Client which activates the LoRa link back to the motorized valve at the tree site.

Lorraine's end is pretty much the same but no water level measuring.

The diagram of the gateway in the barn shows the interconnection of the Arduino Mega MQTT client with the two P2P LoRa modules.

Would be interested in your views, but I'm confident now that I can connect the three Arduinos directly together and it will work and I dont need to isolate that connection with an optocoupler.

At the barn site (gateway) there are already 4-motorised valves controlling the water deliver to the three tanks (4 valves vs 3 tanks? its complex because of prioritisation). That is driven by another Arduino Mega MQTT client. It is informed by the gateway which gets its info from 3 RAK WisBlocks associated with each tank as in the Larry diagram. In the finished version, pretty sure the one Arduino Mega MQTT client will drive the whole thing. At the moment the bit that's working prioritises the water deliver to the tree 33,000 litre tanks: human, animal, trees.


Slide 12 error: 433MHz should read 868MHz.

No opto-isolators needed. But you can add them if you want, for example 3 opto isolators in series between the Mega and each of the Unos, because you clearly like to have 3 where 1 will do: 3 Arduinos, 3 LoRa frequency bands...

Are you being cynical or constructive? I just happen to have modules lying around at those frequencies which will give me two P2P channels. In fact everything in my line diagrams, I happen to have including the RAK gear.

Having said that, if you can show me a diagram that does it in a simpler manner without any conflicts, Iā€™d welcome it.

I have had conflicts between two Arduino before, hence my thinking to get around that issue with an optocoupler, however, pretty sure as others have pointed out, the answer is a common earth and same VCC level.


Apologies, I was being cynical.

I like to do more with less. It's not fashionable these days.

1 Like

I'm fine with that. I will do some work around that concept. I guess I am driven by the experience of using the gateway in one direction, ie a node in the field to the gateway to IoT. In this case, to the MQTT and I have replied to that message via the two separate P2P channels. So I'm guessing you're advocating make some logistic decisions in the gateway/MQTT and send the motorised-valve actuation message back via the gateway to the node in the field?

Yes, that kind of idea. Keep the hardware simple and minimal, and compensate by making the software cleverer.