Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@ An advanced thermostat for micropython devices using `asyncio`.

## Installation

On a micropython device, install with `mip`:
On a micropython device, install with `mip` from the REPL:

```python
>>> import mip
>>> mip.install("github:solanus-systems/micropython-thermostat")
```

Or on a unix build of micropython via the CLI:

```bash
mip install github:solanus-systems/micropython-thermostat
micropython -m mip install github:solanus-systems/micropython-thermostat
```

## Usage

This module implements async thermostat logic but does not include any hardware-specific code.

Setup generally involves:

1. Initialize a `Thermostat` instance and set the mode and setpoint(s)
1. Write a polling loop or other function to read temperature from a sensor
1. Call `set_temp()` to update with the temperature read from the sensor
1. Check or `await` the `heating` and `cooling` flags (`asyncio.Event` objects)
1. Use the flags to control relays or other hardware as needed

### Example

```python
from thermostat import Thermostat

Expand All @@ -31,7 +50,7 @@ therm.set_temp(read_sensor_temp())
assert therm.heating.is_set()
```

See `thermostat.py` for the full API.
See `thermostat/__init__.py` for the full API.

## Developing

Expand Down Expand Up @@ -60,3 +79,18 @@ Then, you can run the tests using the micropython version of `unittest`:
```bash
micropython -m unittest
```

## Releasing

To release a new version, first cross-compile to micropython bytecode. You need `mpy-cross` in your `PATH`:

```bash
mpy-cross thermostat/__init__.py
```

Then, update the versions in `manifest.py` and `package.json`. Commit your changes and make a pull request. After merging, create a new tag and push to GitHub:

```bash
git tag vX.Y.Z
git push --tags
```
11 changes: 9 additions & 2 deletions manifest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
metadata(version="0.1.0")
module("thermostat.py")
metadata(
description="Advanced async thermostat logic for micropython",
version="0.1.1"
)

require("time")
require("logging")

package("thermostat")
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"urls": [
["thermostat/__init__.py", "github:solanus-systems/micropython-thermostat/thermostat/__init__.py"]
["thermostat/__init__.mpy", "github:solanus-systems/micropython-thermostat/thermostat/__init__.mpy"]
],
"deps": [
["time", "latest"],
["logging", "latest"]
],
"version": "0.1.0"
"version": "0.1.1"
}
Binary file added thermostat/__init__.mpy
Binary file not shown.