how to communicate with salve device through SPI bus

I know how to use the SPI library to communicate, but the problem is that the data bits is not 8 bits multiple, how to adjust it?

Just pad with 0 to get complete bytes b101 is the same as b00000101

if u are using "SPI.transfer" to receive the data from slave and I am assuming that it is the RECEIVED data that you a saying is not is 8 bit multiples then you have a couple of options:

SPI.transfer will clock for 8 bits meaning that your received data will be put a byte.

you can then do some bit manipulation if need be to get by your data; that is assuming that you are getting one set of data per SPI transfer. using JML example if you receive only 3 bits(b101), SPI.transfer could return anything between 0b00000101 to 0b10100000.

however if you are receiving a stream of bits then it gets a bit more complicated but still possible! :slight_smile: