1

I have 1 GPIO pin on my RPi that I'm using to monitor power status of my project, the intention is to connect this pin to a serial port on a Teensy that will be running a script to send information like battery levels/charge statuses, the RPi receives it and displays it; so usually the Pi is just receiving data. All other pins are already used for the main application.

I know I can't use the same pin to both send and receive at the same time, but would it be possible to set up a ping/pong type protocol such that each end sends a message, then once reaching the end of the line the mode changes so that the other end now sends a message. So for example, after receiving each power status message, the modes flip and the Pi responds with a simple 'ack' then the modes flip back; and the Teensy would be able to detect if the Pi has shut down if it doesn't receive that 'ack' within a certain timeout.

1
  • Ah, let me see. What you suggest is is a bit difficult. One work around is to forget UART serial port on both Rpi and Teensy. Instead you use one GPIO pin both side, and switch the GPIO pin between Input and Output mode. This is usually called "One-Wire" protocol, such as used in DS18b20 temperature sensor. One wire protocol can actually use any single GPIO pin, so is very flexible.
    – tlfong01
    Commented Mar 2, 2020 at 2:04

2 Answers 2

1

What you describe is exactly how LIN and 1-Wire protocols work. 1-Wire is especially interesting, since it is supported by Pi out of the box with dtoverlay=w1-gpio. I would check if there's a corresponding library on Teensy, so that you don't even have to program the protocol yourself.

Before you start, I suggest you give it a good thought: is saving one pin worth the trouble learning a new protocol? If you're familiar with UART, I would stick to it even if it means wasting an extra pin.

0

That is possible.

You would need to bit bang the serial link so would be limited to, say, 9600 bits per second or less.

My pigpio provides support. You would have to be a fairly experienced programmer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.