Server application for a university IoT project "Smart Home"
- Mosquitto MQTT broker
- MySQL RDBMS
- Spring Framework & Spring Boot
- Docker
This is the back-end server application for the "Smart Home" university project for "Distributed Embedded Systems" discipline.
- Room lights and temperature monitoring
- Temperature control via commands based on the temperature sensor readings
- commands issued to relays controlling a fan and a heater
- Lights control via commands based on the lights sensor readings
- commands issued to relays the room lights
- 2x NodeMCU (ESP8266) modules
- 4x AC relays (10A/250V)
- 1x DHT11 temperature and humidity sensor
- 1x photoresistor as a light sensor
- Download and install Docker -> link
- Execute
docker-compose up
in the root directory of the project - Run the Spring Boot appliaction -
./mvnw spring-boot:run
GET http://localhost:8090/smarthome/measurements/light/latest?num=5
GET http://localhost:8090/smarthome/measurements/temperature/latest?num=5
GET http://localhost:8090/smarthome/measurements/light
GET http://localhost:8090/smarthome/measurements/temperature
POST http://localhost:8090/smarthome/device/command
with the following JSON request body:
{
"command": "LIGHTS_ON"
}
Supported commands: LIGHTS_ON, LIGHTS_OFF, HEAT_ON, HEAT_OFF, COOL_ON, COOL_OFF
GET http://localhost:8090/smarthome/device/command/history?num=50
- query parameter
num
- number of records to fetch, default if missing parameter is 100 records
Response objects are returned ordered by timestamp, descending:
[
{
"timestamp": "2020-06-17T23:58:14.064376",
"commandType": "HEAT_ON"
},
{
"timestamp": "2020-06-17T23:58:14.014381",
"commandType": "LIGHTS_OFF"
}
]
GET http://localhost:8090/smarthome/device/state
Sample response:
{
"light": "OFF",
"heater": "ON",
"cooler": "UNKNOWN"
}