# install notes
add a unprivilleged system user and copy the progam files to it's home directory
```
sudo useradd --create-home --shell /bin/false --system radon
sudo chown radon rd200.py
sudo chown radon ../backend
sudo ln -sf /home/jb6113/radon-ble-rd200/backend/rd200.py /home/radon/.
```

run on boot
```
# second is       'S'      C2:58:00:9A:26:29
# first purchased 'R'      CF:CD:27:79:55:6B

# rd200.py takes a command line argument, the bluetooth address of the sensor
systemctl enable radon-eye@CF:CD:27:79:55:6B
```

systemd status info
```
sudo systemctl status radon-eye@CF:CD:27:79:55:6B
```

systemd status stop
```
sudo systemctl stop radon-eye@C2:58:00:9A:26:29
```

## pitfall and troubleshooting
in case you are having problems, check these common pitfalls:
1.  pyrhon3 sqlite3 wrapper requires that user owns directory as well for no reason

install a systemd service
```
#systemd-analyze verify radon-eye.service
sudo cp radon-eye.service /etc/systemd/system/.
sudo chmod +x /etc/systemd/system/radon-eye.service
sudo systemctl enable radon-eye.service
```

# extras
raspberry pi has some problems, but edit `/etc/watchdog.conf` set timeout to `10` and interval to `2` and things should work out, I needed to install watchdog apt package first even though watchdog module and hardware were ready

# prerequisites
apt packages - python3, bluetooth, bluez

python3 modules - BLE_GATT

# locations
the rd200 sensor is expensive and we purchased a single unit with the intent to move the sensor around for samples that are spread accross a larger area

store the changes of location in a database
```
-- initialize database
sqlite3 locations.db "CREATE TABLE locations (description TEXT, room INTEGER DEFAULT 0, time INTEGER NOT NULL DEFAULT (strftime('%s', 'now')))"

-- example location update
sqlite3 locations.db "INSERT INTO locations (description) VALUES ('pink room, on a branch of the bonsai tree')"

-- if you need to add a location at a different time other than now
sqlite3 locations.db "INSERT INTO locations (description, room, time) VALUES ('main level livingroom, halfway up shared kitchen wall', 0, strftime('%s', 'now', '-7 days'))"
```
