PC with master Arduino and slave ATTINY816

Hi everyone,

Is it possible to have a connection between 3 modules like this:
PC -----usb ------ Master Arduino -----RS485----- ATTINY816

From PC, I want to send commands to Master Arduino via USB connection. then based on the command, Master Arduino could send a command to the ATTINY816 to get some data via RS485.

I don't have much experience in Arduino so I don't know how to differentiate the signal in master Arduino which one is from PC and which one is from ATTINY816 in case both PC and ATTINY816 send data at the same time. Also how to send data to the correct communication channel in the master Arduino.

Thank you.

That is doable.
The master Arduino uses Serial.read to read the Pc. Use software serial and an RS485 adapter to communicate with the slave.

What is "Master Arduino"?

I know that you know that there are boards with free UARTs that are not used for communication with the PC.

@haisonvh So it depends on which Arduino you use as a "master". 328P based boards only have one UART and it's used for communication with the PC so you need SoftwareSerial; most other boards have at least one free UART that you can use.

It's a choise, staying with the controller suggested by the OP, ot suggest a major change. The Mega offers a lot but costs more and is rather bulky.

I have figured out the way
To communicate with PC, I still use the USB connection and use Serial class for coding.
To communicate with ATITINY microcontroller, I use SPI with MAX485 module to convert SPI signal to RS485 signal. To do that I will use the SPI class
With this setup, I can differentiate the signal of PC and ATITINY in my "master Arduino"

Thanks

Are you referencing someone else's implementation here, or imagineering? SPI has bidirectional data chip selection, AND a clock signal to contend with. I don't believe I've seen that done on an RS485 bus structure.

@camsysca , for the converter from SPI to RS485, I reference in this post
https://www.circuitbasics.com/how-to-set-up-spi-communication-for-arduino/

Because the ATITINY works as a slaver so I will enable SS pin (set to HIGH) in Arduino when I want to get data from the ATITINY. In addition, it uses a different class (SPI) to transmit data so I guess the Arduino could differentiate this signal from the serial signal sent from PC.

Read that article from end to end, no mention of RS485. Just plain, simple, SPI implementation. Since you don't appear to know the difference, I'll step away now. Have fun!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.