Leveraging Python:
#!/usr/bin/env python
import datetime
import bme680
from kafka import KafkaProducer
from json import dumps
sensor = bme680.BME680()
json_body = [
{
"millis": str(datetime.datetime.now()),
"temperature": sensor.data.temperature,
"pressure": sensor.data.pressure,
"humidity": sensor.data.humidity
}
]
producer = KafkaProducer(bootstrap_servers=['your.kafka.server:6667'], value_s
erializer=lambda x: dumps(x).encode('utf-8'))
future = producer.send('bme680', json_body)
try:
record_metadata = future.get(timeout=10)
except KafkaError:
log.exception()
pass
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |