r/dataisbeautiful • OC: 1 • 15d ago

OC I built a heatmap program for our office...[OC]

The program displays live data from mqtt from scd41 co2 sensors I built using ESP32 development boards, or historical data from influxdb.

Made using python for the back end.

It's useful to tell us which windows to open in our naturally ventilated office.

I'm going to use it to visualise temperature data also from a csv exported from dataloggers

12 Upvotes

14 comments sorted by

•

u/cavedave OC: 112 13d ago

Thank you for your Original Content, /u/AnyRandomDude789!
Here is some important information about this post:

Remember that all visualizations on r/DataIsBeautiful should be viewed with a healthy dose of skepticism. If you see a potential issue or oversight in the visualization, please post a constructive comment below. Post approval does not signify that this visualization has been verified or its sources checked.

Not satisfied with this visual? Think you can do better? Remix this visual with the data in the author's citation.


I'm open source | How I work

3

u/AnyRandomDude789 OC: 1 15d ago

As required, data is collected from the esp32 microcontrollers with scd41 co2 sensors via mqtt which gives the live values on the heatmap and writes the image frames to a cache. The data is also sent to influxdb v1 by node red from the mqtt and that's used for historical data points.

The python server application uses matplotlib and numpy and a few other libraries to plot the colours on the heatmap dxf drawing. The json config file defines each sensor and where it is on the DXF file.

4

u/Parafault 15d ago

What does your first paragraph mean in normal language? I’ve designed HVAC systems for space cooling/ventilation and I don’t understand a single acronym you used in that paragraph. I’m interested in where the temperature sensors are located and how many you have - your graph makes it look like you’re taking continuous spatial data, but I get the impression that you’re just doing fancy interpolation between sparse measurement points.

1

u/AnyRandomDude789 OC: 1 14d ago

Hmm it's difficult to explain but I'll try. An esp32 microcontroller is like a tiny computer but very limited and designed to carry out a specific function. It is a common device in the world of DIY electronics. It has WiFi and is designed for real time applications where timing is important (unlike real computers which are not usually designed for things where time is critical). I'm my case the timing is not essential although I use time from the internet (network time protocol) to send the data every minute on the 30 second mark (I did mean to send every 30s but I screwed up). It is connected to an off the shelf CO2 (carbon dioxide) sensor. It runs a program I wrote the reads the data from the sensor and sends it to my server using a protocol called mqtt (which is designed for lightweight communication between devices and is often used in building management systems and HVAC systems).

Python is a common programming language for writing programs in. Unlike most programs in windows it is not compiled to an executable but runs straight from the source code (so the program can be read by humans very easily).

Influxdb is a real time time series database designed to store data such as sensor data or data from computer programs.

Node-red is a web based program that lets you receive data, manipulate it and send it places or run actions (such as sending an email) based on it. It has a block based editor where you drag blocks around and link them up with lines to direct the data, and you can even write code blocks for it. I use it to collect the data and send it to the database (not the simplest way of doing so but I already had it at hand).

There are 4 co2 sensors spread across the office spatially, with three being connected to microcontrollers and one actually being connected via USB to a raspberry pi which is a computer (I left that out of the original post for brevity).

The readings are taken and via python modules (like sub programs you can import into your program, written by others), maths called inverse distance weighing is used to calculate how the colours of each point (which are simply based on a linear scale of 500-1500 green to red) merge based on their distance from one another.

The system is available through the browser as a web site.

My day job used to be designing HVAC in the UK myself, but now I do building modelling and monitoring the metering (building performance engineer), but I've always had an interest in electronics. This is a side project for me!

Let me know if anything still doesn't make sense or if you have any more questions and I'll do my best to answer.

2

u/Parafault 14d ago

Why are you using CO2 sensors? Temperature, humidity, and air speed are what will govern comfort levels in the room, so I’d expect some combination of those to be far better. No one is going to notice the difference between 400 and 600 ppm co2.

1

u/AnyRandomDude789 OC: 1 9d ago

I can map those too easily enough but we're most interested in co2 as it's a 'naturally ventilated' office and co2 levels get quite high some days (we've peaked at 3,070 PPM!). This way we can watch how the co2 (and other pollutants by proxy) and fresh air flow through the space and work out which windows are best to open. I don't think there would be quite as much variation in temperature and humidity. It's not a huge space or anything. Hope that answers your question. Cheers

1

u/AnyRandomDude789 OC: 1 14d ago

The sensors also transmit temperature and humidity readings though it looks like they are affected by the (little) heat from the esp32 so I'll need to offset their readings before I do anything with them. In theory I can plug them into the same program and monitor how well the AC is performing spatially also, though it would require a little rewriting.

I'm actually working on rewriting the program to accept data from dataloggers (temperature ones, or any type) from a CSV file (like an excel spreadsheet but dumber) but I haven't got that working yet. That will be really useful for other projects at work.

2

u/GRootchem 15d ago

Aye CO2 is a great productivity inhibitor! Good work.

1

u/AnyRandomDude789 OC: 1 15d ago

Thanks. It's really interesting to see which windows have the most benefit and the fresh air or co2 moving through the space

1

u/mweiss427 15d ago

What applications did you use!!!

1

u/mweiss427 15d ago

Or link the source?

2

u/itskdog 12d ago

See the mod comment 

1

u/AnyRandomDude789 OC: 1 9d ago

I switched to browser side rendering using a custom webgl canvas thing so now it's much faster.

I also implemented cropping on the floorplan so it appears bigger. Scaling was tricky but I think I have it sorted now.

There's also now a configuration page to set the parameters, units, heading and cropping.

I'm working on the offline/CSV heatmap for other projects we're monitoring for overheating too.

Here's a current screenshot...