An open API service indexing awesome lists of open source software.

https://github.com/justin900429/tea-tok-clock

Project for the Discrete Mathematics course in NYCU 2021 Fall
https://github.com/justin900429/tea-tok-clock

clock python raspberry-pi

Last synced: 2 months ago
JSON representation

Project for the Discrete Mathematics course in NYCU 2021 Fall

Awesome Lists containing this project

README

          

# README

## Introduction

In this project, we're going to measure time using some physics phenomenon. We choose to
use [Newton's law of cooling](https://en.wikipedia.org/wiki/Newton%27s_law_of_cooling) as the basics to figure out the
time.

## Set up the environment

```shell script
$ pip install -r requirements.txt
```

1. Push `tools` and `sensor.py` to RPI
2. The circuit should be set up:


circuit

## Experiments

To find k, we test it different ways:

* Finding the mean of k
* Using linear regression in log-scale





## Configuration

```python
K: float = 0.02 # Constant for the Newton Law of cooling
T_s: float = 23.0 # Surrounding temperature
T_initial: float = 100.0 # Initial temperature

HOST: str = "

"
PORT: str = ""
```

## Training

The training file is located in `train` folder. The default value is listed below.

```shell
$ python train/train.py \
--file_name exp/colling.csv \
--weight exp/model.pt
```

> For more training arguments, please see `train/train.py`

The training process will be like:

```
Epoch 1: 100%|██████████████████████████████████████████████| 465/465 [00:00<00:00, 1301.83it/s, Loss: 1.394]
Epoch 2: 100%|██████████████████████████████████████████████| 465/465 [00:00<00:00, 1259.02it/s, Loss: 0.867]
...
```



## Running code

To successfully activate the code, both `clock.py` and `server.py` should be started:
> Note: `sensor.py` or `sensor_sim.py` should be run first

```shell
# For simulation
$ python sensor_sim.py
$ python clock.py
```

```shell
# For cooling
$ python sensor.py
$ python clock.py --mode
```

```shell
# For heating
$ python sensor.py
$ python clock.py --mode model --heating --weight exp/heating.pt
```

The result would be like