Arduino
Using the S-35710 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_S-35710 library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout VIN.
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
Library Installation
You can install the Adafruit_S-35710 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_S-35710, and select the Adafruit S-35710 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
#include "Adafruit_S35710.h"
#include <Wire.h>
// Optional reset pin connected to the S35710
const uint8_t RESET_PIN = -1;
// Create the S35710 with the reset pin
Adafruit_S35710 s35710 = Adafruit_S35710(RESET_PIN);
void setup() {
// Start the serial communication
Serial.begin(115200);
while (!Serial)
; // Wait for serial port to connect
Serial.println("Adafruit S-35710 Test!");
if (!s35710.begin(&Wire, S35710_I2C_ADDRESS)) {
Serial.println("Failed to initialize S-35710!");
while (1)
;
}
Serial.println("S35710 initialized!");
uint32_t wakeupTimeValue = 3; // 3 seconds
Serial.print("Setting wake-up time to ");
Serial.print(wakeupTimeValue);
Serial.println(" seconds");
if (!s35710.setWakeUpTimeRegister(wakeupTimeValue)) {
Serial.println("Failed to set wake-up time register!");
while (1)
;
}
// Test getting the wake-up time register
int32_t readWakeupTimeValue = s35710.getWakeUpTimeRegister();
if (readWakeupTimeValue == -1) {
Serial.println("Failed to read wake-up time register!");
while (1)
;
}
Serial.print("Wake-up time set to ");
Serial.print(readWakeupTimeValue);
Serial.println(" seconds");
Serial.println();
}
void loop() {
int32_t readTimeValue = s35710.getTimeRegister();
int32_t readWakeupTimeValue = s35710.getWakeUpTimeRegister();
if (readTimeValue == -1 || readWakeupTimeValue == -1) {
// Hmm failed to read? wait & retry
delay(1000);
return;
}
Serial.print("Internal timer: ");
Serial.print(readTimeValue);
Serial.print(" s, alarm set: ");
Serial.print(readWakeupTimeValue);
Serial.println(" s");
delay(1000);
}
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the S-35710 recognized over I2C. Then, an alarm is set for 3 seconds. In the loop, the internal timer is printed out every second along with the alarm. Once the internal timer reaches 3 seconds, the alarm expires.
Page last edited January 22, 2025
Text editor powered by tinymce.