Casa Digital is a real-time IoT data monitoring system designed for smart home purposes. It seamlessly connects MQTT sensors, streams data to Kafka, and queues into TimescaleDB for analysis. The system is implemented using Node.js for integration.
MQTT
: Message Queuing Telemetry Transport for sensor data communication.Kafka
: Distributed streaming platform for real-time data processing and queuing to timescaleDB.TimescaleDB
: Time-series database for efficient storage and retrieval of sensor data.Node.js
: Runtime environment for executing JavaScript code on the server-side.
- Clone the Repository:
git clone https://github.com/karthik2603-theBrogrammer/casa-digital.git
- Modify the
config.json
file in the root, as per your needs.
{
"topics": [
"gas_sensor_data", // Enter your desired topics here.
"temperature_data",
],
"kafka": {
"bootstrap_servers": "localhost:9092" // Local host and port of kafka.
},
"mqttBroker": {
"bootstrap_servers": "mqtt://broker.hivemq.com" // Default Broker, configured in docker-compose file.
},
"docker": {
"timescale_config": {
"user": "postgres",
"password": "password", // IMP: password here has to match docker-compose file !
"host": "localhost",
"port": "5432",
"database": "postgres"
}
}
}
- Run the
docker-compose
File.
- Maintain the same password for timescale !
docker-compose up -d
- Configure Your IOT devices to their respective ports.
NOTE: For more device connectivity use serial communication between 2 microcontrollers. (Ex: Arduino and ESP8266)
- Once the device codes have been loaded with the same topics proceed.
- Run the Kafka Consumer.
cd sink
node index.js
- Run the MQTT-Kafka pair.
- MQTT will listen to the network of IOT devices and sensors.
- Then kafka will feed the data into the brokers in its respective topics.
cd mqtt-kafka
node index.js
- Watch the streaming of data into
timescaleDB
with an interactive CLI.
cd cli
pip3 install -r requirements.txt
python3 index.py
- To interact with timescale directly,
docker exec -it timescaledb psql -U postgres
- I have learnt a lot developing this project of mine, it may not be the best but i gave it my all nevertheless :)
- Feel free to contribute to this project. Fork the repository, make your changes, and submit a pull request.