https://github.com/kairen/rpi-collector
Collect sensor data using Raspberry Pi, and publish data to MQTT, Kafka server
https://github.com/kairen/rpi-collector
Last synced: 6 months ago
JSON representation
Collect sensor data using Raspberry Pi, and publish data to MQTT, Kafka server
- Host: GitHub
- URL: https://github.com/kairen/rpi-collector
- Owner: kairen
- Created: 2016-03-10T03:52:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-09T05:52:16.000Z (over 8 years ago)
- Last Synced: 2025-02-10T12:32:37.312Z (8 months ago)
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Collect Sensor Data Using Raspberry Pi
透過 Raspberry Pi 與簡單幾個感測器來實作資料的收集,並推送到 OpenStack 上的 MQTT Broker、Apache Kafka伺服器。也可以透過 Spark Streaming 來接收 MQTT 與 Kafka 的訊息,目前實作以下感測器的接收:
* DS18S20
* DS1822
* DS18B20
* DS28EA00
* DS1825/MAX31850K
* DHT11
* DHT22
* AM2302訊息佇列系統的推送目前實作```MQTT```與```Apache Kafka```,未來也會持續增加。
# 安裝與執行
首先安裝 python 與 python-pip 套件:
```sh
$ sudo apt-get install -y git python-pip python-setuptools build-essential python-dev
```從 Git Server 將 Repositiory 下載至要執行的 Raspberry Pi 上:
```sh
$ git clone https://github.com/imac-cloud/rpi-collector.git
$ cd rpi-collector
```建立 conf 目錄,並複製 conf 檔案到 etc 底下:
```sh
$ SERVICE="rpi-collector"
$ sudo mkdir -p /etc/${SERVICE}
$ sudo chown -R ${SERVICE}:${SERVICE} /etc/${SERVICE}
$ sudo cp -r etc/rpi-collector/rpi-collector.conf /etc/${SERVICE}/
```安裝```rpi-collecter```服務套件:
```sh
$ sudo pip install .
```
> 也可以透過以下方式安裝:
```sh
$ sudo python setup.py install
```編輯```/etc/rpi-collector/rpi-collector.conf```檔案,並修改一下:
```conf
[default]
debug = Truew1therm_sensors_id = 200000758e2c2
w1therm_sensors_type = DS18S20adafruit_sensors_gpio = 11
adafruit_sensors_type = DHT11time_interval = 0.5
multi_message_queue = true
[message_queue]
type = kafka
address = 10.26.1.159
port = 9092
topic_name = rpi-1
qos_level = 2
```
> ```P.S``` 目前 message_queue type 有```mqtt```、```kafka```。若沒設定則不會推送。完成後,即可透過以下指令執行(目前還沒完成 Service 方式執行):
```sh
$ rpi-collector
[collect.temperature][INFO] 2016-03-10 17:14:37.535571, 23.75
[collect.temperature][INFO] 2016-03-10 17:14:38.565419, 23.75
[collect.temperature][INFO] 2016-03-10 17:14:39.583886, 23.75
[collect.temperature][INFO] 2016-03-10 17:14:40.611681, 23.75
```