Is it possible?: Two wire communication bus with ESP32 as a slave? #16642
Replies: 5 comments 6 replies
-
I Don't know if your controller is also a esp32. If so, can you not use websockets? |
Beta Was this translation helpful? Give feedback.
-
This is a recurring question. I'm no expert in it. With googling I found this (in German, I attach a translation with deepl.com). This is no full satisfactory solution, of course. Apart from this there are inofficial solutions for the RP2 Pico, which should work well, given that you might employ the PIO machinery. There was an implementation for the ESP32 by Loboris, for an earlier version of the firmware. Someone with ESP32 expertise might extract the code and see if it is compatible with recent firmware. Also the question appears if SoftI2C, which works quite well, cannot be extended in a minimal way to slave mode.
Using UART might be much easier. Recently there was even a callback implemented which would be fired, when there are messages received. You might be able to access the TX pin as ordinary pin in parallel to UART mode. I would at least try this. |
Beta Was this translation helpful? Give feedback.
-
I agree with that - in spades. UART communication is highly reliable. If you're using You mention turning off the TX pin. That is not necessary. When a UART is idling the pin is high. The receiver recognises this state as an idle state and produces no output until data is received. |
Beta Was this translation helpful? Give feedback.
-
If all seven of your MCUs are esp32 (one controller and six motor drivers), I have a few suggestions:
|
Beta Was this translation helpful? Give feedback.
-
Thanks yall for your ideas and help! I finally got this working using UART. The master esp32 would send commands each with an ID of the slave and the slave with the correct ID would respond. The problem was that each slave had set the TX bus to idle (high) when not transmitting preventing the other slaves from talking. By setting the TX pin to high impedance (input mode) it stopped that. I had to set it back though and reinitialize UART unfortunately every transition but it works. Here is the UART slave code I used.
|
Beta Was this translation helpful? Give feedback.
-
Question:
Does anybody know of a way to communicate to set up a two wire bus with ESP32 as a slave?
Why I want this:
I’m building a robot arm with six axises. Each axis has a custom motor driver/controller ESP32 board that I have been designing and programming months.
What I have tried:
I designed it to use I2C as the communication protocol. Little did I know that there is not a working ESP32 I2c slave library. I tried using uart as a bus but could not reliably turn off the TX pin when not in use.
What I haven’t tried:
I know 3 wire SPI works by tying the Miso and Mosi together. Would it be possible to remove the CS pin by using addressing?
What I know I could do as last resort:
I could use the SPI 3 wire and solder on a chip select pin to each esp32 motor driver.
I could also switch my entire program to Arduino instead but I have already spent months on this micropython program and am not fluent in Arduino
If anybody has any ideas for how I can connect each esp32 in a bus with two wires, I would greatly appreciate the help!
Beta Was this translation helpful? Give feedback.
All reactions