- Table of Contents
- Building Management System
- Dashboard
- Hardware setup
- Installation
- Usage
- Contributing
- License
This project seeks to demonstrate the use of MQTT protocol and MERN stack for building an IoT Building Management System for commercial usage, where parameters such as building occupancy, energy demand, andenergy consumption are measured and displayed on an online database and dashboard.
A more detailed description of the project can be found here.
You can access the dashboard after you sign up here
Circuit design
Installing in an ESP8266-01 and NodeMCU involves pushing the python files into the device whether it's via a usb to ttl or just a usb cable. This can be done using the command
sudo ampy --port /dev/ttyUSB0 --baud 115200 put main.py
sudo ampy --port /dev/ttyUSB0 --baud 115200 put config.py
sudo ampy --port /dev/ttyUSB0 --baud 115200 put connectWifi.py
You need to create a config.py file with the following information for each and every esp folder (current-sensor, dht-sensor, motion-sensor, relay-bulb, relay-fan)
MQTT_CONFIG = {
'SENSOR_ID': '',
'MQTT_HOST': '',
'PORT': '',
'PUB_TOPIC': ''
}
WIFI_CONFIG = {
'WIFI_ESSID': '',
'WIFI_PASSWORD': ''
}
To install npm packages used for the Raspberry Pi, you run.
npm install axios mongoose mqtt
You also need to create a config folder and have two files that contain config/broker.js
module.exports = {
brokerUrl: ""
};
and config/server.js
module.exports = {
serverUrl: ""
};
To install npm packages used for the server, you run.
npm install axios bcryptjs body-parser concurrently cors express gravatar jsonwebtoken mongoose mqtt passport passport-jwt recharts validator
You also need to have a config/keys_dev.js with the configuration above. The mongoUri and secretOrKey are obtained when you create a mongodb on https://mlab.com the database I used.
module.exports = {
mongoUri: "",
secretOrKey: ""
};
To install npm packages used for the client, you run.
npm install jwt-decode axios react-redux redux recharts redux-thunk semantic-ui-css semantic-ui-react
To run the code for Raspberry Pi just cd into the folder and run
node app.js
To ensure that the Raspberry Pi runs the code whenever it boots, edit the rc.local file
sudo nano /etc/rc.local
and add
node app.js &
To run a local development of the website, all you need to do is to do the installation setup then once that is done
cd site && npm run dev
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.