Simple communication protocol?

I’m trying to connect two ESP devices by one or two wires and allow them to communicate (one direction) with one another via a simple communication protocol such as Morse code by driving the signal/voltage on the wire connecting them high/low.

Any ideas on how to accomplish something like this? Pulse width sensor sounds interesting but examples and docs are a little slim….

What is the distance between them?

I’d suggest going with the UART component. Depending on the baud rate you select, the amount of noise in the environment and cable you use, you could get a couple for meters just from the 3.3V TTL level signal straight from the GPIOs.

Using RS232 line driver/receiver modules would extend this considerably (10s of meters, depending on the baud rate).

e.g.

Sounds like a job for a uart aka serial connection.

1 Like

Why don’t you tell us what you are trying to accomplish rather than how you want to do it? There may be better or easier methods.

Are the ESP devices known to Home Assistant, like with ESPHome?

I was editing my reply to suggest just that.

Well its nice to beat you to an answer once in a while!

2 Likes

Thank you guys for the quick replies, I appreciate it! I should have included more details…

I have three lines that circle a property and I’d like to put sensors at various locations. For several reasons including cost, weather, distance and reliability I’d like to make use of these existing wires. Since there are 3 of them I’ll use 2 for power which leaves one for a ‘communication bus’. My “requirements” are:

  1. One way communication only from one node to the others downstream. Which means all nodes will hang off the same ‘bus’ and will pickup their messages based on some sort of identifier I send as part of the datagram.
  2. Transmission speed can be slow.
  3. Wired communications only, no wireless.

The above is what led me to my original ask above. Since I have one control line I was thinking along the lines of sending messages/commands in some sort of modified Morse Code (for lack of a better description) that all nodes would receive and then only act upon if they saw their identifier. To do this I was thinking of just signaling the control line high/low but I’m stuck on how to decode this on the receiver side(s). Something along the lines of a multipress action/timings for buttons is what came to mind initially but I don’t think it is flexible enough for my needs.

Hopefully this helps clarify the ask/problem statement.

Thank you all once again!

Can all nodes transmit on the bus or is it only one single transmitter and multiple listeners ? In the latter case use serial, as the guys above suggested. If more than one node is able to transmit on the bus then things become more complex. You will need a open drain bus with Hi-Z tristate drivers. Something like 1-Wire. The transmission protocol is not trivial, because it needs to handle collisions when multiple nodes decide to transmit at the same time.

I don’t know the actual status of development but sometimes ago I read about PJON protocol (link removed, site not more available). You can use this protocol (there is a library compatible with esp32 and esp8266 I think) over single wire bus PJDL.

One transmitter with multiple receivers. I’ll look into serial more in that case. I’d assumed it needed more than one wire though but maybe I’m wrong if it’s only one transmitter?

Thanks!

PJON sounds interesting too, thank you for the suggestion. I’ll check it out as well!

Thanks!

Just one wire if the serial link is unidirectional. Connect it to the TX (out) of the transmitting node and to the RX (in) of one or more receiving nodes.

1 Like

I use PJON with mysensors since two years, very reliable, no problems at all. Would be interesting to add PJON to esphome. If ESPhome would support something like gateway and nodes, this would be a reason to go fully with ESPhome. At the moment all wired stuff is done in my (quite complex) smart home system with MySensors and PJON.

That’s a good endorsement, I’m curious, what’s the largest distance you have between any two nodes?

Thanks!

I have quite huge house with four electrical cabinets and all smart devices in star topology. The longest node to gateway distance is about 30m, but in this one network there are about 50 devices connected together, so the sum of cable lenght is about 500m. At the beginning I have test it over 100m cat 5e, the connection was very reliable. To send data I used one twisted pair - PJON + GND. I think this is not the limit, they claim PJON can go up to 2000m.

When I hit that site, it was an online gambling platform in a language I didn’t understand. Avoid, and try here instead. Home · gioblu/PJON Wiki · GitHub

Thanks @nickrout. I removed the link. The website is not available anymore.