Two Microcontrollers Talking, All It Needs Is An LED

There are some projects that seem at first sight to be easy, but anyone who tries them finds a whole heap of unexpected problems and turns to the off-the-shelf device. PCB antennas for example, or data links using LEDs, whether IR or visible. The latter doesn’t faze [Luca Soltoggio] though, because he has two ESP32s talking to each other using visible light. Best of all, both use a single LED as both transmitter and receiver.

The software is called SecurePair, and is an Arduino library for exchanging keys and communicating with encryption. The LEDs are the cool hardware hack but it’s designed to work with ESPNow or LoRa too, indeed a typical use case would see light for pairing and wireless for the exchange of encrypted data.. In case you were wondering, it relies on the property of an LED that it’s also a photodiode of sorts. Best of all, while the examples have two ESP32s, it’s not limited to that number and many more can join the conversation if needed.

Check out the video below to see it in action — if you’re curious about LEDs as sensors, we’ve been there too.

10 thoughts on “Two Microcontrollers Talking, All It Needs Is An LED”

  1. I am reminded of the touch display that someone once made from an 8X8 array of LED’s that basically worked via careful PWM and pin-switching between outputs and inputs. At any given very short period of time, some portion of the LEDs would be in receive mode looking for patches of brighter light modulated in the same way as their neighboring sections. Overall the display gave up some brightness, but it you could wave a fingertip over it (possibly just if you were white) and it would recognize where on the grid you were pointing.

  2. This is very cool. I’m feeling old … back in 2003 there was a well written paper talking about this:

    https://www.merl.com/publications/TR2003-35
    Dietz, P.H., Yerazunis, W.S., Leigh, D.L., “Very Low-Cost Sensing and Communication Using Bidirectional LEDs”, ACM International Conference on Ubiquitous Computing (UbiComp), October 2003.

    1. That paper is exactly where this starts, and you are not that old: it still reads very well. It is credited in the PacketLED README, together with the other work on LEDs as sensors.

      What PacketLED adds on top of the idea is the boring part that makes it usable as a link: a packet format with CRC, acknowledgements and retransmissions, 256 to 1024 bit/s, tested up to about 2.5 m with clear narrow-beam LEDs. SecurePair then uses that link to exchange keys.

  3. The original 802.11 specification was developed for infra-red communication between laptops. It got adopted by wireless and the original peer to peer protocol was supplanted — and largely replaced — by the much common access point centered mechanisms that are widely used today.

  4. Author here. Thanks to Jenny for the write-up, and to everybody for the kind words.

    A small clarification, since there are two repos: PacketLED is the LED link itself (one LED as emitter and sensor, with framing, CRC, acknowledgements and retransmissions), and SecurePair sits on top of it and does the pairing and the encryption. SecurePair also runs over ESP-NOW or LoRa, so the LED can be used just for the pairing and a radio for the data.

    It is a beta, and the part I would most like feedback on is the protocol. It is written down in full, failure cases included, in docs/PROTOCOL.md, and no cryptographer has reviewed it yet. If you feel like trying to break it, please do: https://github.com/toggio/SecurePair

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.