Skip to content

Trouble Connecting to SPI on AVR-IOT Cellular Mini - Need 2x STHS34PF80 Running  #5

@PaulKyros

Description

@PaulKyros

I can't connect my AVR-IOT Cellular Mini via SPI to the STHS34PF80

here is how I've connected it.

spi_connections.pdf

image

An alternative solution would be to change the addressing, preferably not using a MUX because of the additional space required for the enclosure. This is a battery operated application.

Therefore, I've opted to run the 2nd using SPI, but am not having any luck.

//////
#include "SparkFun_STHS34PF80_Arduino_Library.h"
#include <SPI.h>
#include "sths34pf80_class.h" // Include the correct class header file

STHS34PF80_SPI sths34pf80_presence_front;

// Variables to store sensor values
int16_t presenceVal = 0;
int16_t motionVal = 0;
float temperatureVal = 0;

// Define the chip select pin
//#define PD7 PIN_PD7 // A5
//#define PB5 PIN_PB5 // D10 - PIN_PB5
//const int chipSelect = 29;
uint8_t chipSelect = 10;

void setup() {
Serial3.begin(115200);
Serial3.println("STHS34PF80 SPI Sensor Readings");

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

//pinMode(PIN_PB5, OUTPUT);
//digitalWrite(PIN_PB5, HIGH);

SPI.setDataMode(SPI_MODE3);
SPI.begin();

while (!Serial3)
  delay(50);


if(sths34pf80_presence_front.begin(chipSelect) != 0) {
//if(sths34pf80_presence_front.begin(PIN_PB5) != 0) {
  Serial3.println("Error setting up device - please check wiring.");
  while(1);
}

delay(500);

}

void loop() {
sths34pf80_tmos_drdy_status_t dataReady;
sths34pf80_presence_front.getDataReady(&dataReady);

if(dataReady.drdy == 1) {
sths34pf80_tmos_func_status_t status;
sths34pf80_presence_front.getStatus(&status);

// Process presence data
if(status.pres_flag == 1) {
  sths34pf80_presence_front.getPresenceValue(&presenceVal);
  Serial3.print("Presence: ");
  Serial3.print(presenceVal);
  Serial3.println(" cm^-1");
} else {
  Serial3.println("No presence detected.");
}

// Process motion data
if(status.mot_flag == 1) {
  sths34pf80_presence_front.getMotionValue(&motionVal);
  Serial3.print("Motion: ");
  Serial3.println(motionVal);
} else {
  Serial3.println("No motion detected.");
}

// Process temperature data
if(status.tamb_shock_flag == 1) {
  sths34pf80_presence_front.getTemperatureData(&temperatureVal);
  Serial3.print("Temperature: ");
  Serial3.print(temperatureVal);
  Serial3.println(" °C");
} else {
  Serial3.println("No temperature change detected.");
}

} else {
Serial3.println("Waiting for data...");
}
delay(500);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions