# Testing Instructions for C1001 mmWave Sensor with ESPHome

This document provides step-by-step instructions for testing your C1001 mmWave sensor integration with ESPHome and Home Assistant.

## Prerequisites

Before testing, ensure you have:
- Completed the hardware connections as specified in the integration guide
- Successfully flashed the ESPHome firmware to your ESP32-S3-DevKitC-1
- Added the device to your Home Assistant instance

## Testing the Hardware Connection

1. **Power Test**
   - Connect the ESP32-S3-DevKitC-1 to power via USB
   - Verify that both the ESP32 board and the C1001 sensor have power LEDs illuminated
   - The RGB LED on the ESP32-S3 should initially turn red and pulse, then turn green after initialization

2. **Physical Connection Test**
   - Inspect all wire connections to ensure they are secure
   - Check for any loose connections or bent pins
   - Verify that the C1001 sensor is properly seated if using a breadboard

## Testing UART Communication

1. **ESPHome Logs**
   - In the ESPHome dashboard, click on your device
   - Click on **LOGS** to view the real-time logs
   - Look for initialization messages like:
     ```
     [C1001] Setting work mode to 2
     [C1001] Setting LED 4 to ON
     [C1001] Resetting sensor
     ```
   - If you don't see these messages, there may be an issue with the UART connection

2. **Debug Mode**
   - If needed, you can temporarily increase the log level in your configuration:
     ```yaml
     logger:
       level: DEBUG
     ```
   - This will show more detailed information about the UART communication

## Testing Sensor Functionality

1. **Human Presence Detection**
   - Stand in front of the sensor (within its detection range)
   - Check Home Assistant to see if the "Human Presence" entity changes state
   - Move away from the sensor and verify that the state changes back after the delay
   - Test both the GPIO-based sensor and the UART-based sensor

2. **Fall Detection**
   - Testing fall detection safely requires careful simulation
   - You can test the GPIO signal by temporarily connecting the IO1 pin to GND
   - This should trigger the "Fall Detection" entity in Home Assistant

3. **Sleep Detection**
   - Place the sensor near a bed or resting area
   - Lie down and remain still for a few minutes
   - Check Home Assistant to see if the "Sleep State" entity changes
   - The "Respiration Rate" and "Heart Rate" sensors should also show readings

## Testing Home Assistant Integration

1. **Entity Availability**
   - In Home Assistant, go to **Settings** > **Devices & Services**
   - Find your ESPHome device and click on it
   - Verify that all expected entities are available:
     - Binary sensors (Human Presence, Fall Detection, etc.)
     - Sensors (Respiration Rate, Heart Rate, etc.)
     - Text sensors (Sleep State)
     - Light (Status LED)

2. **Dashboard Integration**
   - Add the entities to your Home Assistant dashboard
   - Create a dedicated view for your C1001 sensor
   - Arrange the entities in a logical manner for easy monitoring

3. **Automation Testing**
   - Create a simple test automation, such as:
     ```yaml
     trigger:
       platform: state
       entity_id: binary_sensor.human_presence
       to: 'on'
     action:
       service: light.turn_on
       target:
         entity_id: light.status_led
       data:
         brightness: 255
         rgb_color: [0, 0, 255]
     ```
   - Test the automation by triggering the sensor

## Troubleshooting Common Issues

1. **No Sensor Data**
   - Check power connections
   - Verify UART pin connections (TX/RX might need to be swapped)
   - Restart the ESP32 board
   - Check ESPHome logs for communication errors

2. **Intermittent Detection**
   - Adjust the sensor position
   - Check for interference sources
   - Ensure the sensor has a clear line of sight to the detection area

3. **False Detections**
   - Adjust the delayed_off filter in the configuration
   - Position the sensor away from moving objects like fans or curtains
   - Consider adding additional filtering in Home Assistant automations

## Performance Optimization

1. **Sensor Placement**
   - For optimal performance, mount the sensor:
     - At a height of 2-2.5 meters for ceiling installation
     - At a height of 1-1.5 meters for wall installation
     - With a clear line of sight to the detection area

2. **Update Interval**
   - The default configuration polls the sensor continuously
   - If you experience WiFi or performance issues, consider adding an update interval

3. **Power Considerations**
   - The C1001 sensor consumes approximately 0.5W of power
   - For battery-powered applications, consider implementing deep sleep modes for the ESP32

## Next Steps

After successful testing:
1. Finalize the mounting of your sensor in its intended location
2. Create meaningful automations based on the sensor data
3. Consider integrating with other Home Assistant entities for a comprehensive smart home solution
