Overview of My Submission
hi, today we are going to see a project that collect your home temperature and humidity in real time!
before talking in the detail about the app is important to understand the architecture.
as we can see there are many different parts:
- Backend: write using node js and TS, handle the redis integration using redis OM, MongoDb integration, Aws Iot real time MQTT connection
and Tensorflow js model utilization. Use redis for reading the real time sensor messagges over the MQTT channel “machines” and try to find a sensor associated with it,
if found insert a datalog of the received data in both MongoDb and redis for rapid real time data into the frontend graph.
the alarm logic is associated to the datalogs, if when a datalog is created trigger an alarm rule an active alarm is created and will be closed only when an alarm below the trashold arrive, all the alarms are stored and not deleted.
Tensorflow is used to read a very simple regression model and use it for the next hour predictions.
the most cool features of the backend are:- Aws Iot integration
- Tensorflow Js integration to parse an existing ML model and use it into JS
- Redis integration to cache data and use redis JSON and redis search to get real time data
- Redis model generator that take an existing Mongoose model and parse it into a redis one with no code logic!
- the alarms rules that are stored into the database!, an example is:
{
"_id" : ObjectId("6300e639830e983ff546f7af"),
"sensorId" : ObjectId("62fce2bc830e983ff546f775"),
"rule" : {
">" : [
{
"var" : "temp"
},
25.0
]
},
"name" : "Bedroom High Temperature",
"type" : "rule"
}
as you can see the rule is a sort of logic!, in fact this is possible by the JSON logic module.
- Frontend: retrieve the data from the backend API to make a graph based on a custom range time, in the graph you can choose the sensor who data you want to see,
there is also the average temperature and humidity cards in the bottom of the dashboard that show you the Average in the selected range.
the alrams are real time and retrived with only 1 minute cache to don’t lose the new alarms, as explained before the alrams are created only when a value trigger an alarm trashold.
there is also a home map to see the sensors disposition and have an idea of the space, the “SUN” card show you the actual values and not the average.
the last card show you the prediction fo the next hour.
All the components support the multi theme feature to personalize the user experience.
frontend also have mobile support but only Horizontal not vertical!
- Sensors: send real time temperature and humidity data every 5 minutes, integrated with Aws-Iot. this sensor are made using Mongoose Os, a really cool it framework that help to increase speed using simil JS code. for the code see the Firmware repo
-
Redis: used to store the cache and the partial datalogs data to speed up the responses time and keep retrive graphic data simple.
-
MongoDb: used to store all other data like sensor and alarms
Previews
Live Preview: Site
after enter into the site select a range and enjoy it!
now that we know the base of the app is time to talk about the redis integration, it help a lot for the graph real time data, because as we say before the data are partial stored into redis to take i for graphs, before redis with only mongo the response time was 300 ms, after 120 ms what a great thing!. i also use redis cache to store the most important and slow enpoint (like the tensorflow one) and it was very helpfull, here we go too see a list of endpoints and used cache:
- datalogs/:
- /predict: predict the next hour data, using redis cache to keep it for 15 minutes
- /ambient/now: actual data
- /:sensorId/:interval: get datalogs of a sensor use redis JSON and redis Search!
- /ambient/humidity/:interval: Average humidity
- /ambient/temperature/:interval: Average temp
- alarms/:
- /active: get active alrams, use redis cache to store it for 1 minutes
- /finished: get finished alarms: use redis cache to keep it for 3 minutes
- sensors/: get the sensor list, use redis cache to keep it for 30 minutes.
so a full list of frontend feature you can try in the live demo!
- real time graph data from my house sensors on 1 or more sensor in an interval
- 2D map to take an idea of sensor position
- active alarms up to now!
- average temp and humidity in the selected range
- card with actuals info
- next hours prevision using ML!
futures feature
the only thing that i don’t have time to make was a complete ML model, in fact this simple one use a regression but a complete one is a timeseries prevision model!
Submission Category: MEAN/MERN Mavericks
video overview of the project Video
Language Used
Node js / TS for the backend
Angular for the frontend
Mongoose Os for the firmware code
Link to Code
Live Preview: Site
after enter into the site select a range and enjoy it!
BackeEnd repo:
marco-bertelli
/
iotSensorBackend
Backend with node js and TS for redis hackathon
SmartHome
this is a project that get real time temperature and humidity data from esp32 with DHT22 AM2302 temperature sensor. after this the data
is stored in both redis and MongoDb and processed from the frontend (see the other repo for more frontend info)
Overview video
Here’s a short video that explains the project and how it uses Redis:
How it works
before start is important to understand the app architecture:
as we can see there are many different parts:
-
Backend: write using node js and TS, handle the redis integration using redis OM, MongoDb integration, Aws Iot real time MQTT connection
and Tensorflow js model utilization. Use redis for reading the real time sensor messagges over the MQTT channel “machines” and try to find a sensor associated with it
if found insert a datalog of the received data in both MongoDb and redis for rapid real time data into…
FrontEnd repo:
SmartHome
this is a project that get real time temperature and humidity data from esp32 with DHT22 AM2302 temperature sensor. after this the data
is stored in both redis and MongoDb and processed from the frontend (see the other repo for more frontend info)
Overview video
Here’s a short video that explains the project and how it uses Redis:
How it works
before start is important to understand the app architecture:
as we can see there are many different parts:
-
Backend: write using node js and TS, handle the redis integration using redis OM, MongoDb integration, Aws Iot real time MQTT connection
and Tensorflow js model utilization. Use redis for reading the real time sensor messagges over the MQTT channel “machines” and try to find a sensor associated with it
if found insert a datalog of the received data in both MongoDb and redis for rapid real time data into…
Firmware repo:
SmartHome
this is a project that get real time temperature and humidity data from esp32 with DHT22 AM2302 temperature sensor. after this the data
is stored in both redis and MongoDb and processed from the frontend (see the other repo for more frontend info)
Overview video
Here’s a short video that explains the project and how it uses Redis:
How it works
before start is important to understand the app architecture:
as we can see there are many different parts:
-
Backend: write using node js and TS, handle the redis integration using redis OM, MongoDb integration, Aws Iot real time MQTT connection
and Tensorflow js model utilization. Use redis for reading the real time sensor messagges over the MQTT channel “machines” and try to find a sensor associated with it
if found insert a datalog of the received data in both MongoDb and redis for rapid real time data into…
Tensorflow Model: if you want more info of tensorflow visit the model here: colab
closure
if you like the project or have any questions leave a like and a comment!
all the shares will be appreciated!
- Check out Redis OM, client libraries for working with Redis as a multi-model database.
- Use RedisInsight to visualize your data in Redis.
- Sign up for a free Redis database.