> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperwisor.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lesson 5 — Store Data & Automate

> Log readings to the database, then add an if-this-then-that rule.

**Goal:** make your product remember and react — persist readings, then automate a
response.

## 1. Create a table

In your product's Studio, open **Monitor → Database** and create a schema with a
`readings` table (e.g. a `temperature` column). See [Database](/studio/database).

## 2. Store a reading

**Real hardware** — insert from firmware:

```cpp theme={null}
device.insertDatainDatabase(productId, deviceId, "readings", [](JsonObject &row) {
  row["temperature"] = readTemperature();
});
```

Read it back with `getDatabaseData(productId, "readings", 20)`, or show it on the
dashboard with a **Table** or **Chart** widget bound to the table.

<Note>
  No hardware? The [Database API](/api/database) and the dashboard **Database Form**
  widget can write records too.
</Note>

## 3. Add a rule

Now automate a reaction. As a user of the product, open the app's
[Rules](/app/rules) tab and build an **if / then**:

```
IF   temperature > 30
THEN send Operate → ON      (turn on the fan/pump/etc.)
ELSE send Operate → OFF
```

That's conditional automation with no code — the same `Operate` command you've used
since Lesson 1, now fired automatically.

<Check>
  Readings landing in the `readings` table, and a rule that acts on them.
</Check>

<Card title="Next: publish & onboard" icon="arrow-right" href="/learn/lessons/06-publish-onboard">
  Ship it to users.
</Card>
