sensor-patterns

A reference guide of embedded C patterns for sensor drivers, calibration, and filtering, including SPI communication, a common chip-to-microcontroller connection method.

In plain words
What is it for?
Use it when writing SPI sensor drivers, burst reads, register access, calibration logic, or sensor-data filtering in embedded C.
Why use it?
It provides concrete register-reading and register-writing patterns for implementing sensor hardware code consistently.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hermeticormus/libreembed-claude-code/sensor-patterns
Any agent
npx skills add HermeticOrmus/LibreEmbed-Claude-Code --skill sensor-patterns
Clone the repo
git clone --depth 1 https://github.com/HermeticOrmus/LibreEmbed-Claude-Code

Made for: Claude Code, Codex.

Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,652 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01652
Opus 5 $0.00000 $0.00826
Sonnet 5 $0.00000 $0.00330
Haiku 4.5 $0.00000 $0.00165

Measured 2d ago against content hash b1778d42ecc2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sensor-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/sensor-integration/skills/sensor-patterns/SKILL.md · 193 lines

How it starts

The opening of the file, as written. The whole thing — 193 lines — stays where its author put it; the contents beside it link to each section on GitHub.

sensor-patterns

Knowledge Base

Sensor driver, calibration, and filtering patterns for embedded C.


Pattern 1: SPI Sensor Register Protocol

Most SPI sensors use: CS assert → [address byte with R/W bit] → [data bytes] → CS deassert.

/* Generic SPI sensor: 8-bit register address, bit7 = R/W (1=read) */
/* Example: ICM-42688 IMU, MPU-9250, LIS3DH */

uint8_t spi_sensor_read_reg(uint8_t reg)
{
    uint8_t tx[2] = { reg | 0x80U, 0x00U };  /* Bit7=1: read */
    uint8_t rx[2] = { 0 };

    spi_cs_assert();
    spi_transfer_bytes(tx, rx, 2);
    spi_cs_deassert();

    return rx[1];   /* Byte 0 = dummy (address phase), byte 1 = data */
}

void spi_sensor_write_reg(uint8_t reg, uint8_t val)
{
    uint8_t tx[2] = { reg & 0x7FU, val };  /* Bit7=0: write */

    spi_cs_assert();
    spi_transfer_bytes(tx, NULL, 2);
    spi_cs_deassert();
}

/* Burst read: read N registers starting at addr */
void spi_sensor_read_burst(uint8_t start_reg, uint8_t *buf, uint8_t len)
{
    uint8_t addr = start_reg | 0x80U;

    spi_cs_assert();
    spi_transfer_bytes(&addr, NULL, 1);     /* Send address */
    spi_transfer_bytes(NULL, buf, len);     /* Receive data */
    spi_cs_deassert();
}

Pattern 2: Temperature Sensor with NTC Thermistor

NTC (Negative Temperature Coefficient) resistance decreases with temperature. Steinhart-Hart equation.

#include <math.h>

#define R_SERIES   10000.0f   /* 10kΩ series resistor */
#define R_NOM      10000.0f   /* Nominal resistance at T_NOM */
#define T_NOM      298.15f    /* 25°C in Kelvin */
#define B_COEFF    3950.0f    /* Beta coefficient from datasheet */

/* Returns temperature in Celsius */
float ntc_adc_to_celsius(uint16_t adc_raw, uint16_t adc_max)
{
    /* Voltage divider: R_NTC = R_SERIES * ADC / (ADC_MAX - ADC) */
    float resistance = R_SERIES * (float)adc_raw / (float)(adc_max - adc_raw);

    /* Steinhart-Hart simplified (B-parameter equation) */
    float temp_K = 1.0f / (1.0f/T_NOM + (1.0f/B_COEFF) * logf(resistance / R_NOM));

    return temp_K - 273.15f;
}

Read the full file on GitHub · 193 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 193 lines · 0 tokens per session scan A b1778d42ecc2

Subscribe to this mod's changes

sensor-patterns is a skill published in the GitHub repository HermeticOrmus/LibreEmbed-Claude-Code (44 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,652 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

platform-port

Guide porting FastLED to new MCU platforms, including int.h types, clockless drivers, SPI implementations, and platform detection. Use when adding support for a new microcontroller family or board.

FastLED/FastLED · 42 tokens

hardware-iot-bus

Low-level I2C and SPI bus peripheral control for embedded Linux boards (Orange Pi, Raspberry Pi, RISC-V).

AbdullahMalik17/malikclaw · 31 tokens

aether-iot-query

Use this skill when the user asks about a live AetherEdge runtime: channels, points, real-time values, history, alarms, rules, models, instances, routing, SHM health, service health, or system status. Use aether CLI commands to answer — do NOT inspect source code, local database files, or config YAMLs to answer…

EvanL1/AetherEdge · 82 tokens

aether-iot

Build, integrate, diagnose, or generate applications for the AetherEdge AI-native edge kernel. Use for AetherEdge onboarding, SDK compositions, device and topology clients, read-only operations UIs, MCP integration, Domain Packs, or governed IoT commands where live-state authority and physical-device safety must be…

EvanL1/AetherEdge · 68 tokens

nucleo-native-app

Scaffold and implement a NucleoOS native firmware app (C++) correctly — anti-flicker, poll handler, RAM discipline, input routing, registration. Use when creating or fixing a native app in firmware/components/nucleoapp/.

indecenti/NucleoOs · 55 tokens

avr-bare-metal-embedded

Curated Knowledge API for AI Agents — 68 MCP tools, 200+ skill packs, 46K chunks, semantic search over 670K vectors, 5-layer validation pipeline. Works with Claude Code, Cursor, Cline, Windsurf.

MidOSresearch/midos · 6 tokens