Using bulti-in Silan SC7A20 accelerometer on Arduino Stella

Hi, I'm new to Arduino and I'm trying to set up a peer-to-peer connection using a UWB module with the Arduino Portenta X8 (Stella). I noticed that the board includes a built-in Silan SC7A20 accelerometer, but I’m not sure how to use it. The serial output shows "no I2C devices found"—does this mean the accelerometer isn't accessible by default? Do I need to connect an external IMU instead? Thanks!

This is my first post and There doesn't seem to be a Stella UWB forum category yet, so I thought to post it here first,

Post a link to this, I find several radically different items using that description.

What protocol are you planning on using?

Welcome the the Arduino forum. You seem to have two completely different questions/subjects in this posting. A peer-to-peer connections means the UWB module has a processor controlling it that is equivalent to the Arduino Portenta. What is this UWB module and what is it's controller?

From the Arduino Stella website, they say it uses DCU040 from TrueSense and Silan SC7A20 accelerometer. This is their tech specs. I have also seen posts saying that the Arduino Stella board's built-in SC7A20 accelerometer is connected internally and may not be accessible on this external bus, as it could use a separate I2C instance or dedicated pins not exposed via QWIIC.

So Stella has their own UWB library, and I might just use theirs.

I am not sure I am understanding correctly, but I basically use two arduino stella boards and set one as master or initiator and the other one as slave or responder. I can get the distance between the two devices, but not the direction. I looked up and I think I need and IMU to figure out the direction. There is a built-in Silan SC7A20 accelerometer, but I can't find it using code through I2C. I don't know if this helps.

Peer-to-peer means equal to equal not master/slave.

hi @wgb0742 please see:

Best Regards

Pier

Hi, I’ve also tried to access the built-in SC7A20 accelerometer on Arduino Stella via I2C (using the example code from the Grove-3-axis-digital-accelerometer-2g-to-16g-LIS3DHTR library and scanning for 0x18, 0x19, 0x1C) and failed to obtain any values.

After that, I attempted to initialize SPI directly through Stella pins, and it bricked the board completely, probably because some of the pins became messed up. Now, Windows detects a USB device for a second, but immediately shows that it malfunctioned. The Arduino IDE no longer detects the board at all. Pressing RESET or KEY on Stella also does nothing.

I cannot find any documentation about how the IMU is actually connected inside the Stella, and I also cannot find any bootloader files for Stella in the ArduinoCore-renesas repository, so I’m unable to restore the board using an external programmer. Please don't repeat my mistakes :slight_smile:

Here is the code I uploaded last that led to the malfunction:

#include <SPI.h>

// SC7A20 chip select pin
#define SC7A20_CS p41

// Registers
#define CTRL_REG1 0x20
#define CTRL_REG4 0x23
#define OUT_X_L   0x28

SPISettings scSettings(1000000, MSBFIRST, SPI_MODE3);

// SPI: write 1 byte
void sc7a20_write(uint8_t reg, uint8_t value) {
  digitalWrite(SC7A20_CS, LOW);
  SPI.beginTransaction(scSettings);
  SPI.transfer(reg);
  SPI.transfer(value);
  SPI.endTransaction();
  digitalWrite(SC7A20_CS, HIGH);
}

// SPI: read 1 byte
uint8_t sc7a20_read(uint8_t reg) {
  digitalWrite(SC7A20_CS, LOW);
  SPI.beginTransaction(scSettings);
  SPI.transfer(0x80 | reg);  // read
  uint8_t v = SPI.transfer(0x00);
  SPI.endTransaction();
  digitalWrite(SC7A20_CS, HIGH);
  return v;
}

// SPI: read 6 consecutive bytes
void sc7a20_readBytes(uint8_t reg, uint8_t* buf, uint8_t len) {
  digitalWrite(SC7A20_CS, LOW);
  SPI.beginTransaction(scSettings);
  SPI.transfer(0xC0 | reg);  // 0x80 = read, 0x40 = autoincrement
  for (int i = 0; i < len; i++)
    buf[i] = SPI.transfer(0x00);
  SPI.endTransaction();
  digitalWrite(SC7A20_CS, HIGH);
}

void setup() {
  Serial.begin(115200);
  delay(300);

  pinMode(SC7A20_CS, OUTPUT);
  digitalWrite(SC7A20_CS, HIGH);

  SPI.begin();

  Serial.println("Initializing SC7A20...");

  // Enable X/Y/Z + 100 Hz
  sc7a20_write(CTRL_REG1, 0b00110111); // SC7A20: 100Hz, LowPower ON, XYZ enable

  // High resolution, ±2g
  sc7a20_write(CTRL_REG4, 0b00001000);  // High resolution disabled in SC7A20 (works better)
  delay(100);

  Serial.println("SC7A20 ready!");
}

void loop() {
  uint8_t raw[6];
  sc7a20_readBytes(OUT_X_L, raw, 6);

  int16_t x = (int16_t)(raw[1] << 8 | raw[0]);
  int16_t y = (int16_t)(raw[3] << 8 | raw[2]);
  int16_t z = (int16_t)(raw[5] << 8 | raw[4]);

  // 1 mg/LSB in high-res mode
  float xf = x / 1000.0;
  float yf = y / 1000.0;
  float zf = z / 1000.0;

  Serial.print("X: ");
  Serial.print(xf, 3);
  Serial.print(" g   Y: ");
  Serial.print(yf, 3);
  Serial.print(" g   Z: ");
  Serial.print(zf, 3);
  Serial.println(" g");

  delay(100);
}

Any help would be greatly appreciated, thanks!

hi @hesea

you can get details of how the IMU is connected to the MCU from the schematic available on the Arduino Docs page related to Stella (https://docs.arduino.cc/hardware/stella/)

You will see that it uses the I2C bus (as per my previous post mentioned in this thread) while in your code you are using SPI, which is likely causing your board to get stuck.

Before declaring your board bricked, have you tried pushing the reset button twice at boot? That should put the bootloader in programming mode and allow you to flash a correct firmware on board.

Best Regards

Pier

Hi @pierpaolo_lento, thank you for the quick response and your help! I was able to reset my Stella and flash a new program. I also tried out your code for the I2C bus from the LIS3DHTR library, which initially didn’t work for me for some reason (all acceleration values were zero, that’s why I was using SPI instead). But now, after some calibration, it works just fine.