Go Down

Topic: Multiple SPI devices when one is lacking a CS pin (Read 1 time) previous topic - next topic


Any ideas on how to connect multiple SPI devices onto the bus when one of them is lacking a CS pin?

I'm trying to connect a sensor (MS5541 pressure sensor) that communicates using an SPI-like protocol.  I'm not too sure of the details, as I was able to find example code to make it work, but I'm using the MOSI MISO and SCK pins, as well as a MCK signal generated by the Arduino Mega 2560.  The sensor works beautifully.

I understand that I cannot now connect an SD card to the same bus, because there is no CS pin on the sensor. Both the sensor and SD card are integral in what I'm trying to do, and I don't want to fork out another $30 for the I2C version of the sensor.

Any help will be greatly appreciated!


This is the sensor:

I think you have bad luck. That sensor uses a 3-wire interface, and the word "SPI" is not even in the datasheet. I'm not sure if the sensor is compatible with SPI.

Use either three seperate pins of the Arduino Mega and a voltage level converter, or buy the I2C version.
That sensor is for 3.0V (or 3.3V), while the Arduino Mega is 5.0V. So you can't connect it directly to the Arduino Mega.

Using a level shifter with the I2C bus is simple. Just one level shifter and you have a 5V I2C bus and a 3.3V I2C. You can connect your sensors to the appropriate bus.

There is another option: use an extra dedicated 3.3V Arduino board to interface with the sensor. You can connect that dedicated Arduino board to the Arduino Mega with the 3.3V I2C bus.


Hah, well I was powering the sensor with 3.3v from the Mega, but didn't realize that the data and clock signals would be at 5v.  Oops.  It did work though, and I got accurate readings.  I can post the code I'm using if need be.

I've heard the sensor described as "SPI-like" (http://nrqm.ca/2012/12/interfacing-avrarduino-with-the-ms5541c-pressure-sensor/)...
He says "There's no select pin, so you can't put the sensor on an SPI bus unless you turn the sensor on and off at its power source." 

Is this a viable option, after I get it running through the level converter?


Only in a very few situations it is possible to remove something from a bus by turning off the power source.
Perhaps you could use some kind of 'enable' in the level converter.

Are you sure you don't have 3 unused pins ? That would make it so much easier. After reading that link, I think it is not even close to "SPI-like". Perhaps you can't even communicate with this sensors using MISO and MOSI after the Arduino is set for the SPI bus.

My conclusion: This sensor has nothing to do with SPI, don't try to put that together.


Use tri-state buffers, enable then with your CS signal and have pullup resistors on the three SPI signals on the device side.

As for the SPI timing, that might be a different story but most things work.

Rob Gray aka the GRAYnomad www.robgray.com


Yes, it looks like a tri-state buffer accomplishes exactly what I had in mind. Thanks!


For future reference, I used a CD74ACT541 "Octal Non-Inverting Buffer/Line Driver with 3-State Outputs."

After running the pressure sensor through a bi-directional logic level converter from sparkfun, and through the tri-state buffer, I have it successfully connected onto the SPI bus with the SD card.

I tried bit banging it during the few days the buffer was in the mail, and I have to say I was clueless.  Thank you for the buffer suggestion, Graynomad.


Rob Gray aka the GRAYnomad www.robgray.com

Go Up