SPI Devices with Different Pinout Labels

All:

I am trying to use two SPI devices together that have different pin labels. One is the SparkFun AS3935 Lightning Detector and the other is an SSD1306 OLED 128x64.
The AS3935 has these seven pins: VCC, GND, INT, CS, SCK, MISO, MOSI
The OLED has these seven pins: VCC, GND, D0, D1, RES, DC, CS

I know the VCC, GND, and CS pins are a match, even though each device needs its own CS pin for identification purposes. However, I cannot figure out how to match up the other four pins on an SPI bus. If the pins/devices were labelled the same, it would be no big deal.

I am using Arduino Uno and Nano boards, so I don't have enough digital pins to make all of these pins have unique assignments plus have the peripheral indicator LEDs, Buzzer, and (future) HC06 Bluetooth modules.
Also, if I try to run the OLED as I2C and the AS3935 as SPI, I get all kind of strange conflicts when read/writing to those two individual devices. Note, both SPI devices work fine when I test them one at a time.

Can anyone help me place these Detector and OLED devices on a single SPI bus?

Thank you!

Maybe this link and diagram will help you sort it out.

1 Like

It is not a SPI device, it can't share pins with SPI

Thank you for your quick answer! Interfacing this display on its own is no problem whether in SPI or I2C modes. However, the AS3935 Lightning Sensor is an SPI-only device, so between the OLED and the AS3935 I don't have enough digital pins left for my other peripherals.

I did read several of the links from the page you cited, since most of them had this screen plus other devices. Unfortunately, those setups all use I2C and the AS3935 does not want to play nice with I2C devices in combination.

My goal is to set up an SPI bus so I have enough pins to run everything. I don't know what pins on this screen match up to the SPI standard. I may just have to experiment with pretending "D0" and "D1" on the OLED are MOSI and MISO and see if that works.

This is what I am actually worried about. The seller insists it is both SPI and I2C, so could it be that the manufacturer mis-labelled it?

In an ideal setup, I would use an I2C bus but the AS3935 Lightning Detector is SPI-only. If it comes down to it, I may break out my soldering station and try to alter the AS3935 to run I2C. That will be my last resort since I'll most likely destroy it LOL

No you did not read that page I posted properly. It has examples of an SPI interface for you. It is just that the labeling is different to the pinout you describe but the pins are in the same order. So you can see what they are really called. All pins on both SPI devices can be common except as you say the chip select lines. Set these to all high to start with.

You hold the chip select down low the do the SPI operation, when it is finished you put it back high.

Could that be "DI" and DO" (eye, oh) rather than D1/D0 (one, zero)?
That would make a lot of sense for SPI (DI (Data In) would be MOSI, DO (Data Out) MISO, DC would be Data Clock.) (RES for RESET, just in case.)

The previous standard terms MISO and MOSI have been deemed politically incorrect, and of course they may not fit so well on tiny little OLED boards.

1 Like

The example you have referred has different (but similar) OLED signal signatures.

OP's OLED has:   GND, VCC, DO,  DI,  RES, DC, CS
Your link has:   GND, VDD, SCK, SDA, RES, DC, CS

Specifically, OP wants to operate i OLED using SPI Port.

Your Light Detector has unambiguous SPI Port pins. So, operate it using SPI Port.

Now, try to operate OLED using I2C Bus. Try the followimg connections;

UNO        OLED
5V         VCC
GND        GND
SCL (A5)   DO
SDA (A4)   DI
DPin-8     RESET------- 10k --------VCC (HIGH - LOW- 10 us delay - HIGH)

Set I2C address 0x3C 

Run an example program from Library that you will include with your sketch.

1 Like

If I mix SPI and I2C, the AS3935 Lightning Detector register variables change with every reboot, and are rarely what my code declares them to be in my Void Setup. The rig needs to be SPI only.

It is hard to accept your experimental results. I would suggest:
1. Opertae Light Detector alone using SPI Port. Please, post the connection diagram.

2. Disconnect Light Detector from Arduino. Operate OLED using I2C Bus. Please, post the connection diagram.

It is my intetion to chcek if there is any wiring conflict when you connect both devices together.

Which Arduino are you using?

RESOLVED: It was a power problem. Once I moved the OLED and buzzer to 5 volt and their own ground pin, leaving the AS3935 and LED on 3v3 with a different ground pin, everything started working. Completely isolating the grounds to their own pins was also an important part.
The OLED is fully functional on I2C (A4/DI and A5/DO), and the AS3935 is on SPI (pins D9 thru D13).
Thanks for everyone's help!

nonsense... All GND pins on Uno are connected together.

When I shared the 5 volt and 3 volt circuit grounds, it was randomly screwing up the interrupt values on the AS3935. Once I isolated the grounds from each other, my interrupt values stayed clean and the conflict between the devices was gone.

Fig-1 and Fig-2 are electrically equivalent; but, they are functionlly different. Fig-2 might cause problem for the normal functioning of OLED due to sharing of GND path of Light Detector.

As others have pointed out this is a nonsense. I think your use of the word isolated to describe the arrangement of the grounds is not the same as the normally understood use of the word.

Post #15 shows a physical arrangement of grounds, note none of these two physical configurations can be, in any way, described as isolated. It is just that the ground current flow is different.

In Figure 1 the ground current is flowing equally to each device. Where as in Figure 2 the ground current is flowing from the ground of the OLED then through the of the light detector, causing what is known as a ground lift. This is where the current from one device affects the voltage on another, causing the ground voltage to change for the second device, thus causing problems.

What Figure 1 is illustrating is what is called a star ground where all the grounds are connected to the same point. This is perhaps a clearer example of star wiring.

Note any point can be the focus of the star, it doesn't have to be the Arduino. That is why the diagram is shown like it is, but often the Arduino is the Star point.

1 Like

Is it same as the ground loop -- I have forgotten the definition?

Not quite the same.

A ground loop is where the disturbance in the ground is a self generated. This is often seen in audio setups where the mains can cause a constant noise or hum on the signal. At the end of the day it is all caused by the ground lift effect. But ground lift is often used to describe the random variations of one component to another. So the same sort of thing but not self perpetuating.

1 Like