I'm trying to connect a hall effect sensor to a arduino feather BLE - though using my old Bluefruit Micro as test bed as it has all the pins soldered and is sitting in breadboard.

The board of the sensor has the following diagram

halleffect.png (40.93 KiB) Viewed 452 times

I get that the SCK,MOSI and MISO pins should connect to the relevant pins of the bluefruit/feather. From what I researched the SDA/CSn - SS/ line is the chip select line. I read in another forum post that I can use any GPIO pin for that. The documentation for the sensor says "chip select-active low". So am I right in assuming that if I set whichever GPIO to LOW it will get data from that, and if I set it to HIGH it will not ?

The pinouts page of the bluefruit says"You can also use the SCK/MOSI/MISO pins with an SPI device as long as it is on a Chip Select line and you disable it when you talk to the BLE module."

Both the feather and bluefruit use Pin 8 as bluefruit CS pin. So my methodology should be, when I need to get data from the sensor I set Pin 8 HIGH, whichever GPIO pin is connected to the SDA Low and when I want to use the bluetooth module I set pin 8 low and whichever GPIO pin is connected to the SDA of sensor low ?

I'm only using the sensor for stepper motor stop detection so I wont be constantly switching between the two, just at initial calibration phase.

To trim out one source of confusion, the pinout in your diagram shows a chip that can use two different signal protocols: SPI and I2C.

When you use SPI to communicate with the chip, the pin names will be (reading left to right) CS, SCK, MOSI, and MISO. When you use I2C, the pin names will be SDA, SCL, A1, and A2.

Since you've already established that you're using SPI, you can ignore the I2C names. The pin you're asking about is just 'CS'.

A microcontroller speaking SPI uses the CS signal to select the device it wants to talk to. Each external device connected to MOSI, MISO, and SCK has its own CS pin, and each of those is connected to a different GPIO pin on the microcontroller. SCK is the clock signal that tells the devices when to read and write data. MOSI is Master-Out/Slave-In, and its voltage is controlled by the microcontroller. All the external devices just listen to SCK and MOSI. MISO is Master-In/Slave-Out, and is how the external devices send information back to the microcontroller.

When an SPI device's CS pin is high, the device ignores any signals on SCK and MOSI, and if it's well-behaved, it also puts its MISO pin in a high-impedance state so other devices can send that signal high and low. If it isn't well-behaved, it tries to hold MISO either high or low when CS is high, and plays electronic tug-of-war with any other device that wants to talk to the microcontroller.

When an SPI device's CS pin is low, it listens to signals on SCK and MOSI, and assumes that it has complete control over the MISO line so it can send data back to the microcontroller.

Just to clarify, to switch the MOSI pins etc to select the sensor(for sake of this example lets say the SS(or is it called CS) of sensor is connected to pin 12) I set pin 12 to LOW and the same time I set pin 8(the ble CS pin) to HIGH ? Or do I have to wire pin 8 to a separate GPIO pin and set that pin to high ?

further reading has shown me that the version I have is indeed i2c version. The data sheet says

"Either populated with an AS5048A with SPI or AS5048B with I2C interface."

I know I have the B version so it's i2c. Unfortunately the data sheet only shows connections for SPI(the image I linked in first post) so that's where my confusion arose.(maybe i2c connections are obvious). So I now have to ignore that diagram.

If you have an I2C version, ignore the SPI names and connect SDA/SCL to the corresponding pins on the Feather.

You might also want to check the breakout's documentation to see if the A1 and A2 pins have pull-up or pull-down resistors.

Each I2C device has a 7-bit address, and the microcontroller uses that to tell the I2C bus what device should pay attention to the following commands. Many chips have pins you can connect to VCC or GND that will change the address (so you can connect more than one chip to the same microcontroller). Breakouts usually connect those pins high or low using resistors so the chip always starts with some default address, but you can still change the address by connecting the pin to the opposite voltage.

Our breakouts use pull-down resistors, for instance, so all the optional bits in the address will default to 0. You can set any of those bits to 1 by connecting a pin to VCC though.

Frigby wrote: Do the SDA and SCL pins of the bluefruit le have to be pulled up via some kind of resistor ?

I2C in general requires pull-ups on SDA and SCL (these are open drain or open collector configured). There are no pull-up resistors on the adafruit board, you must add them on your hardware if they aren't there already.

Now, I2C is available in 4 different speeds: standard (100 kHz), full (400 kHz), fast (1 MHz) and high speed (up to 4 MHz). The "best" pull-up value depends on the I2C speed, Vcc and bus capacitance. As a good rule of thumb, use 10 kOhm resistors for standard speed, 4.7 kOhm for full and 2.2 kOhm for the higher speeds (assuming there's only 1 I2C device on the bus and the bus itself is of reasonable design).