### AFE::init() Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Initializes the AFE4404 chip with default configurations for pulse oximetry, including timing, LED sequences, and ADC settings. ```APIDOC ## AFE::init() ### Description Initializes the AFE4404 chip by setting up I2C communication, configuring the internal timing engine, LED timing sequences, ADC sampling windows, TIA gains, and LED current levels. This function must be called before reading any sensor values. ### Response - **void** - Initializes the hardware state. ``` -------------------------------- ### Initialize AFE4404 Sensor Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Configures the chip with default timing, LED current, and TIA gain settings. Must be called before any sensor data reading. ```cpp #include #include AFE sensor; void setup() { Serial.begin(115200); Serial.println("Initializing AFE4404..."); // Initialize the AFE4404 with default configuration // - Internal 4MHz oscillator enabled // - LED current range 0-100mA // - Dynamic power-down mode for ADC and TIA // - LED1=15, LED2=3, LED3=3 current settings // - TIA gains configured for optimal signal detection // - ADC averaging set to 3 samples sensor.init(); Serial.println("AFE4404 initialized successfully!"); } void loop() { // Sensor is ready for reading } ``` -------------------------------- ### Read LED3 Channel Value Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Retrieves the 22-bit ADC value from the LED3 channel, useful for ambient light compensation or additional wavelengths. ```cpp #include #include AFE sensor; void setup() { Serial.begin(115200); sensor.init(); } void loop() { // Read LED3 / Ambient 2 sensor value uint32_t led3_value = sensor.get_led3_val(); Serial.print("LED3/Ambient Value: "); Serial.println(led3_value); // Can be used for: // - Third wavelength measurements (e.g., green LED for HRM) // - Ambient light compensation delay(100); } ``` -------------------------------- ### AFE::get_led3_val() Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Reads the 22-bit ADC value from the LED3 channel, used for ambient light or third wavelength measurements. ```APIDOC ## AFE::get_led3_val() ### Description Reads and returns the 22-bit ADC value from LED3 channel (also known as Ambient 2). The value is returned as a signed 32-bit integer in two's complement format. ### Response - **uint32_t** - The 22-bit signed ADC value from LED3. ``` -------------------------------- ### Read Pulse Oximetry Data with AFE4404 Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Implements a 20Hz sampling loop to read IR, Red, and Ambient LED channels from the AFE4404 sensor. ```cpp /* * AFE4404 Complete Pulse Oximetry Example * * Hardware Connections (Arduino Uno): * AFE4404 Pin | Arduino Uno Pin * -------------|------------------ * I2C_DAT | A4 (SDA) * I2C_CLK | A5 (SCL) * VDD | 3.3V * GND | GND * * AFE4404 I2C Address: 0x58 (88 decimal) */ #include #include AFE pulseOx; // Variables for signal processing uint32_t ir_value, red_value, ambient_value; unsigned long lastSampleTime = 0; const int SAMPLE_RATE_MS = 50; // 20 Hz sampling void setup() { Serial.begin(115200); while (!Serial) { ; // Wait for serial port to connect } Serial.println("================================="); Serial.println("AFE4404 Pulse Oximetry Monitor"); Serial.println("=================================\n"); // Initialize AFE4404 with default configuration pulseOx.init(); Serial.println("AFE4404 initialized!"); Serial.println("Reading sensor values...\n"); Serial.println("IR\t\tRed\t\tAmbient"); Serial.println("----------------------------------------"); } void loop() { // Sample at fixed rate if (millis() - lastSampleTime >= SAMPLE_RATE_MS) { lastSampleTime = millis(); // Read all three LED channels ir_value = pulseOx.get_led1_val(); // LED1: Infrared red_value = pulseOx.get_led2_val(); // LED2: Red ambient_value = pulseOx.get_led3_val(); // LED3: Ambient/Green // Output tab-separated values for easy plotting Serial.print(ir_value); Serial.print("\t\t"); Serial.print(red_value); Serial.print("\t\t"); Serial.println(ambient_value); // Values can be sent to Serial Plotter for visualization // or processed for SpO2 and heart rate calculation } } ``` -------------------------------- ### AFE::get_led1_val() Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Reads the 22-bit ADC value from the LED1 channel, typically used for infrared (IR) measurements. ```APIDOC ## AFE::get_led1_val() ### Description Reads and returns the 22-bit ADC value from LED1 channel. The value is returned as a signed 32-bit integer in two's complement format. ### Response - **uint32_t** - The 22-bit signed ADC value from LED1. ``` -------------------------------- ### Read LED1 Channel Value Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Retrieves the 22-bit ADC value from the LED1 channel, typically used for infrared (IR) measurements. ```cpp #include #include AFE sensor; void setup() { Serial.begin(115200); sensor.init(); } void loop() { // Read LED1 (typically IR LED) sensor value uint32_t led1_value = sensor.get_led1_val(); Serial.print("LED1 (IR) Value: "); Serial.println(led1_value); // LED1 values are 22-bit signed values // Typical range: -2097152 to +2097151 // Higher values indicate more light detected (less absorption) delay(100); } ``` -------------------------------- ### Read LED2 Channel Value Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Retrieves the 22-bit ADC value from the LED2 channel, typically used for red LED measurements in SpO2 calculations. ```cpp #include #include AFE sensor; void setup() { Serial.begin(115200); sensor.init(); } void loop() { // Read LED2 (typically Red LED) sensor value uint32_t led2_value = sensor.get_led2_val(); Serial.print("LED2 (Red) Value: "); Serial.println(led2_value); // Used in conjunction with LED1 for SpO2 calculation // SpO2 = f(Red/IR ratio) based on calibration curves delay(100); } ``` -------------------------------- ### AFE::get_led2_val() Source: https://context7.com/rakshithbk/afe4404-library/llms.txt Reads the 22-bit ADC value from the LED2 channel, typically used for red LED measurements. ```APIDOC ## AFE::get_led2_val() ### Description Reads and returns the 22-bit ADC value from LED2 channel. The value is returned as a signed 32-bit integer in two's complement format. ### Response - **uint32_t** - The 22-bit signed ADC value from LED2. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.