if someone could give me a hand on what should i code to send a temp data from master to slave over UART serial communication.
also, i intend to use a "Compim" to read data via a serial monitor : how exactly can i code that ?
nb: i already did a working code of this project by SPI, my question what is the data length ( bits ) that can be transferd from RX , TX ? is the same as SPI ( 8 bits ).
i wouldn't describe this as master/slave if there are just 2 devices.
of course the TX pin of one device is connected to the RX pin of the other device. this is what null modem connector use to do.
with 2 devices, either device can send data whenever needed, no need to wait for a poll from a master.
master/slave describes many devices connected using a serial connection where the TX lines of all the slaves are connected together and connected to the RX line of the master, RS-422 allowing full duplex communication, or all TX and RX lines are connected togeter, RS-485 allowing half-duplex communication.
the RS-422 and RS-485 interface chips support disabling the TX to prevent interfering with other devices. the TX line would normally be disabled except when transmitting and Serial.flush() will return when all data are transmitted and the line disabled again
Characters of 5, 6, 7, or 8 bits, using the Arduino built-in HardwareSerial functions (default is 8). If you use a special library the hardware is capable of 9-bit characters.
What is your Transmitter (that you call Master mistakenly) Device (Arduino UNO/NANO/MEGA) and what is your Receiver (what you call Slave mistakenly) device?
SPI sends 8-bit frame; there is no START or STOP bits. UART sends (by default for UNO) 10-bit wide frame composed of START-bit (1-bit), character length (8-bit), and STOP-bit (1-bit).
SPI is a synchronous protocol requiring clock signal for shift-in/shift-out data; whereas, UART is an asynchronous protocol.