MiTemp-Server is composed of two things: 1. application (hassiweb/mitemp and hassiweb/mitemp-sender) deployment into Raspberry Pi using Ansible 2. instantiation of InfluxDB and Grafana docker containers
- Xiaomi temperature/Humidity Bluetooth Sensor
- Raspberry Pi which supports Ethernet (either wired and wireless) and Bluetooth (e.g. 3B+, Zero W, etc.)
- Linux server
All instructions are run on the Linux server.
$ git clone https://github.com/hassiweb/mitemp-server $ cd mitemp-server
$ docker-compose up -d
-
Sensor’s MAC address list
- File:
ansible/roles/mitemp/files/mac_list.txt
- Description: MAC addresses to be scanned at Raspberry Pies
- File:
-
InfluxDB connection information
- File:
ansible/roles/mitemp/files/influxdb.conf
- Description: Information to connect a database in InfluxDB
- File:
-
Time intervals to scan and send temperature and humidity data
- File:
ansible/roles/mitemp/vars/<Raspberry Pi\'s host name/IP address>.yml
- Description: Cron is used to run containers to scan data and send data. This time intervals are defined in this file.
mitemp_measurement_cron_min
defines the time interval mitemp_measurement_cron_min to run the container to scan data.mitemp_sender_cron_min
defines the time interval in minutes to run the container to send data. The format of both variables follows the crontab format.
- File:
-
Inventory for Ansible targets (i.e. Raspberry Pies)
- File:
ansible/inventory/inventory.ini
- Description: This follows Ansible definition.
- File:
$ ansible-playbook -i inventory/inventory.ini mitemp_deploy.yml
After this deployment, Raspberry Pies start scanning and sending data to the InfluxDB on the server. You can confirm the data with a commend below:
$ curl -G 'http://<Your server's host name>:8087/query?pretty=true' --data-urlencode "db=mitemp" --data-urlencode 'q=SELECT * from "<Sensor's MAC address>"'
Open Grafana on a browser and type your server’s host name and the port number of the Grafana container (default is 8087). With some configurations of Grafana, you can show a dashboard like below.
MIT
See my blog below. - Raspberry Piで温湿度モニタリングシステムの構築