add-sensor

Use when user wants to add a new sensor to the Enviro+ monitoring system, or asks to monitor a new data point. Guides through importing libraries, initialization, reading sensor values, publishing to Adafruit IO and Home Assistant, updating documentation, testing, and rate limit verification.

181 stars

Best use case

add-sensor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when user wants to add a new sensor to the Enviro+ monitoring system, or asks to monitor a new data point. Guides through importing libraries, initialization, reading sensor values, publishing to Adafruit IO and Home Assistant, updating documentation, testing, and rate limit verification.

Teams using add-sensor should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/add-sensor/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/add-sensor/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/add-sensor/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How add-sensor Compares

Feature / Agentadd-sensorStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when user wants to add a new sensor to the Enviro+ monitoring system, or asks to monitor a new data point. Guides through importing libraries, initialization, reading sensor values, publishing to Adafruit IO and Home Assistant, updating documentation, testing, and rate limit verification.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Add New Sensor to Enviro+ Logger

This skill guides you through the complete process of adding a new sensor to the project.

## Prerequisites

Before adding a sensor:
- Sensor library must be installed in the virtual environment
- Sensor must be hardware-compatible with Raspberry Pi
- Consider Pi Zero 2W's limited resources

## Step-by-Step Process

### 1. Import Sensor Library
Add the sensor library import at the top of `publish_to_adafruit.py`

```python
from your_sensor_library import SensorClass
```

### 2. Initialize Sensor
Add initialization in the `read_sensors()` function

```python
def read_sensors():
    sensors = {}

    try:
        # ... existing code ...

        # Initialize new sensor
        new_sensor = SensorClass()

        # ... rest of function ...
```

### 3. Read Sensor Value
Get the sensor value and add to `sensors` dict with a clear key name

**Important**: If the sensor uses analog/ADC readings, it may return stale data on first read (like BME280 and MICS6814). Test this and discard first reading if needed:

```python
# If sensor needs first reading discard:
_ = new_sensor.read()
time.sleep(0.1)

# Get actual reading
value = new_sensor.read()
sensors['new_sensor_name'] = round(value, 2)
```

### 4. Publish to Adafruit IO
Add feed mapping in `publish_to_adafruit()` function's `feed_mapping` dict:

```python
feed_mapping = {
    'temperature': 'enviro-temperature',
    'pressure': 'enviro-pressure',
    # ... existing feeds ...
    'new_sensor_name': 'enviro-new-sensor',  # Add this
}
```

### 5. Publish to Home Assistant
Add sensor configuration in `publish_to_homeassistant()` function's `sensor_configs` dict:

```python
sensor_configs = {
    'temperature': {
        'name': 'Enviro+ Temperature',
        'unit': '°C',
        'device_class': 'temperature',
        'icon': 'mdi:thermometer'
    },
    # ... existing sensors ...
    'new_sensor_name': {
        'name': 'Enviro+ New Sensor',
        'unit': 'UNIT',  # e.g., 'Pa', '%', 'lx'
        'device_class': 'CLASS',  # e.g., 'pressure', 'humidity', 'illuminance'
        'icon': 'mdi:ICON_NAME'
    }
}
```

**Home Assistant device_class reference:**
- Temperature: `device_class: 'temperature'`, unit: `'°C'`
- Pressure: `device_class: 'atmospheric_pressure'`, unit: `'hPa'`
- Humidity: `device_class: 'humidity'`, unit: `'%'`
- Light: `device_class: 'illuminance'`, unit: `'lx'` (NOT 'lux'!)
- Custom: Omit device_class, use descriptive icon

**Icon reference**: Browse [Material Design Icons](https://pictogrammers.com/library/mdi/)

### 6. Update Documentation

**README.md**:
- Add sensor to the feeds list
- Explain what it measures and typical values
- Update sensor description section

**CLAUDE.md** (or SKILLS.md if not merged):
- Add sensor details to hardware section
- Document any special considerations (calibration, warm-up, etc.)

### 7. Test Manually
Run at least 3 times to verify stability:

```bash
source ~/.virtualenvs/pimoroni/bin/activate
python3 /home/kleinmatic/Code/enviroplus-logger/publish_to_adafruit.py
```

### 8. Verify in Home Assistant
If Home Assistant publishing is enabled:
1. Check sensor appears in **Settings → Devices & Services → MQTT → Enviro+ Sensor**
2. Verify in **Developer Tools → States** (filter for "enviro")
3. Check unit of measurement displays correctly
4. Verify icon appears as expected

### 9. Rate Limit Check
**Critical**: Ensure total publishing time doesn't exceed Adafruit IO limits

- Free tier: 30 data points/minute maximum
- Each sensor takes 0.5 seconds to publish
- Formula: `(number_of_sensors × 0.5 seconds) < 30 seconds`

Currently: 8 sensors × 0.5s = 4 seconds ✓

With your new sensor: 9 sensors × 0.5s = 4.5 seconds ✓

If you exceed 30 seconds total, you'll get 429 rate limit errors.

### 10. Update Dependencies
If you installed a new library:

```bash
source ~/.virtualenvs/pimoroni/bin/activate
pip freeze > requirements.txt
```

## Important Reminders

### Don't Add Excessive Logging
- microSD card longevity concerns on Pi Zero
- Current logging is acceptable but don't expand it
- Remove temporary debug print statements before committing

### Test First Reading Behavior
Many analog sensors return stale data on first read. Always test:

```bash
source ~/.virtualenvs/pimoroni/bin/activate
python3 -c "
from your_sensor import Sensor
import time

sensor = Sensor()
print('First reading:', sensor.read())
time.sleep(0.1)
print('Second reading:', sensor.read())
time.sleep(10)
print('After 10s idle:', sensor.read())
time.sleep(0.1)
print('Second after idle:', sensor.read())
"
```

If first readings are different, discard them like BME280 and MICS6814.

### Security Check
Before committing:
- Verify `.env` is still in `.gitignore`
- No credentials in code
- Test with `read_sensors.py` first

## Common Issues

**Sensor not appearing in Home Assistant:**
- Check Home Assistant logs: **Settings → System → Logs**
- Look for MQTT discovery errors
- Verify MQTT broker is running
- Check device_class/unit compatibility

**Rate limit 429 errors:**
- Too many sensors or publishing too frequently
- Reduce cron frequency or number of sensors

**Stale readings:**
- Add first reading discard pattern
- Test over 10+ minute period for gas sensors (warm-up time)

## After Adding Sensor

Run the publishing script manually a few times, then monitor the cron job logs:

```bash
tail -f /home/kleinmatic/Code/enviroplus-logger/sensor_log.txt
```

Verify data appears correctly in both Adafruit IO and Home Assistant (if enabled).

Related Skills

tech-blog

159
from majiayu000/claude-skill-registry

Generates comprehensive technical blog posts, offering detailed explanations of system internals, architecture, and implementation, either through source code analysis or document-driven research.

Content & DocumentationClaude

modal-deployment

159
from majiayu000/claude-skill-registry

Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.

DevOps & Infrastructure

chrome-debug

159
from majiayu000/claude-skill-registry

This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.

Coding & DevelopmentClaude

grail-miner

159
from majiayu000/claude-skill-registry

This skill assists in setting up, managing, and optimizing Grail miners on Bittensor Subnet 81, handling tasks like environment configuration, R2 storage, model checkpoint management, and performance tuning.

DevOps & Infrastructure

ontopo

159
from majiayu000/claude-skill-registry

An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.

General Utilities

astro

159
from majiayu000/claude-skill-registry

This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.

Coding & Development

whisper-transcribe

159
from majiayu000/claude-skill-registry

Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.

Media Processing

ux

159
from majiayu000/claude-skill-registry

This AI agent skill provides comprehensive guidance for creating professional and insightful User Experience (UX) designs, covering user research, information architecture, interaction design, visual guidance, and usability evaluation. It aims to produce actionable, user-centered solutions that avoid generic AI aesthetics.

UX Design & StrategyClaude

vly-money

159
from majiayu000/claude-skill-registry

Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.

Fintech & CryptoClaude

lets-go-rss

159
from majiayu000/claude-skill-registry

A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.

Content & Documentation

thor-skills

159
from majiayu000/claude-skill-registry

An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.

SecurityClaude

advanced-skill-creator

181
from majiayu000/claude-skill-registry

Meta-skill that generates domain-specific skills using advanced reasoning techniques. PROACTIVELY activate for: (1) Create/build/make skills, (2) Generate expert panels for any domain, (3) Design evaluation frameworks, (4) Create research workflows, (5) Structure complex multi-step processes, (6) Instantiate templates with parameters. Triggers: "create a skill for", "build evaluation for", "design workflow for", "generate expert panel for", "how should I approach [complex task]", "create skill", "new skill for", "skill template", "generate skill"