7 ms·
Show HN: I wanted to measure CO2 in my office, so I build a C++ WebServer/App
- jamisteven 8y agoNo story behind the build, just a link to the git repo? yay
- stackmad 8y agoYou can only put link + title on here. And the story is rather boring :) I wanted to measure it, I got a device from amazon, found a python script to read the data, the dependencies (pyhidapi) always sigfaulted, so I wrote my own :)
- WilliamEdward 8y agoWhy do you need a script for this? Isn't the device good enough at telling you the bare necessary information? Still a cool script nonetheless, no hate.
- stackmad 8y agoSure, but I wanted to see the data over time. And I was bored :)
- tobyhinloopen 8y agothat thermostat is working pretty well, keeping the temperature stable like that
- stackmad 8y agoYeah, I've finally managed to tweak the thermostat on the radiators and the main thermostat for the heater to where I like it :)
- Leandros 8y agoUnrelated to the project, but your CO2 levels are far to high. The maximum should be around 600ppm.
- switch007 8y agoYour comment doesn't seem to match up with https://www.kane.co.uk/knowledge-centre/what-are-safe-levels-of-co-and-co2-in-rooms https://www.kane.co.uk/knowledge-centre/what-are-safe-levels... unless you mixed up CO and CO2? Am I missing something? EDIT: ah, looking at a CO2 monitor, it says "Indoor air quality: Good (0 to 800ppm), Normal(800 to 1200ppm), Poor (>1200ppm) indication"
- stackmad 8y agoYes, I agree. I've already ordered a bunch of plants :) Sadly my building is quite old and ventilation is poor.
- thinkcontext 8y agoIn most places ventilation standards are set by building code. Point this out to your landlord, if they are not responsive notify the relevant local authority.
- Joakal 8y agoI heard that you would need about 40(?) plants per person. Best advice was to be well ventilated unless the outdoor CO2 is worse than indoors.
- antisthenes 8y agoYou literally can't have enough plants in the house to compensate for the CO2 production of its inhabitants. You would have to place water immersed algae farms on every open space in the house and keep them illuminated with artificial light 24/7, because plants will produce CO2 at night otherwise. Like you said, good ventilation is far more effective than any plant.
- ody4242 8y agoWhats wrong with this one? (it works with the same device) https://github.com/larsp/co2monitor https://github.com/larsp/co2monitor
- akuji1993 8y agoI'd improve the ticks on the x-Axis a bit. Otherwise looks fine to me.
- stackmad 8y agoYeah, that was pretty quickly hacked together :)
- maxk42 8y agoInstalled a CO2 monitor in my home two days ago. Already changed my life. It warns me when I need additional ventilation and even beeps if CO2 levels raise too high. It sounds silly but it's scary how quickly levels rise when the windows are closed.
- llampx 8y agoWhich one did you get? I'm interested in getting one as well.
- maxk42 8y agoThis one on Amazon: https://www.amazon.com/gp/product/B001PDGFR8/ref=ppx_yo_dt_b_asin_title_o01__o00_s01?ie=UTF8&psc=1 https://www.amazon.com/gp/product/B001PDGFR8/ref=ppx_yo_dt_b... Looks like they're out of stock now, but it has a big label on the front that says co2meter.com, so you might want to check there. I am not affiliated with that company.
- coldtea 8y ago>It sounds silly but it's scary how quickly levels rise when the windows are closed. It might be scary, but is it actually dangerous? It could just be that the levels shown, even if raised, are inconsequential. Basically wondering about the "Already changed my life" line. Are we all without one risk certain CO2 death every day, or is the parent overly worried over nothing (and opens windows without really a need for it).
- z3t4 8y agoIt could be dangerous if the room is completely sealed, as the oxygen would eventually run out.
- rimliu 8y agoFun fact: humans do not have oxygen levels detection, but do have CO2 levels detection. Your body would ring all kinds of the alarm bells if CO2 levels rise above the norm, even if there is enough oxygen.
- jakobegger 8y agoWhy are there steps in the CO2 levels?
- johndough 8y agoSince this is based on a reverse-engineered binary protocol and since the step sizes are reasonably close to 64 and 128, I'd guess it's a bug.
- stackmad 8y agoThe device on its onscreen display shows the same steps, so I think its due to how the sensor works.
- CamperBob2 8y agoIt looks like there's no need to reverse-engineer the protocol: https://www.co2meter.com/products/co2mini-co2-indoor-air-quality-monitor https://www.co2meter.com/products/co2mini-co2-indoor-air-qua...
- benbristow 8y agoIsn't C++ a bit overkill for a web app?
- sgt 8y agoNot necessarily. You see web servers running on microcontrollers all the time and they are mostly written in C.
- qzy 8y agoYou are right, C++ is overkill. It would be much better if it was a javascript application with thousands of dependencies.
- jordache 8y agoahh so you're in the camp of wanting to re-create a graphing library for every project..
- WrtCdEvrydy 8y agoahh so you're in the camp of outsourcing your development cost to the user's hardware.
- drngdds 8y agoThere are memory-safe languages that aren't Javascript, you know
- stackmad 8y agoDepends, this was a question I tried to answer for myself with this project. I did not easily find a good library for Python that would work on my Mac for reading the HID messages, so writing the device part in C++ was easier for me ( and an interesting excercise in c++17'ifying C code ). I thought about just having the c++ app be called from python, but wanted to try and see how hard it would be in c++ and found it extremely easy with the cpprestsdk.
- 8y ago
- Sujan 8y agoAnyone know other, possibly cheaper, devices besides https://www.co2meter.com/products/co2mini-co2-indoor-air-quality-monitor https://www.co2meter.com/products/co2mini-co2-indoor-air-qua... that can display current CO2? I hoped there would be cheaper versions on Aliexpress, but no luck :(
- blakesterz 8y agoIt looks like the same thing is cheaper on Amazon.
- Heliosmaster 8y agoMH-Z19 is a sensor on sale on Aliexpress for ~20 USD. It works with Arduino and ESP32
- wyldfire 8y agoThis device's manufacturer claims an accuracy of "± 100ppm or ± 7% of reading". But there's a review on Amazon that describes someone getting three units and finding as much as 600ppm variation among them. Maybe they need some kind of calibration or tuning? Or their manufacturing process is way out of control.
- detaro 8y agoThey have a calibration feature, of course most of the reviews fail to mention if the person understood how it worked and used it. (I personally find the mechanism a bit odd, but I guess it makes some sense if you assume some things about the environment)
- stackmad 8y agoIt definitely shows that this is one of the cheapest meters on the market. But the values seem to be realistic, when having all windows open it shows 450-460 ppm which is at least close to the global 400ppm ( and I live next to a road in a bigger city ).
- deleted 8y ago[deleted]
- jackallis 8y agowhat is the baseline for CO2 on certain Sq.ft?
- stackmad 8y agoI guess it should match the outside air as close as possible. So around 400ppm
- blrhg 8y agoI am new to this one. I always wonder about accuracy. I think it depends on where you place your sensor in the room matters. If it is in place where lot of window air is hitting, it might alter the values. Or am I completely wrong? Or are you using multiple devices to get the average of those devices?
- stackmad 8y agoYes, absolutely. I only have one device at the moment, but it sure would be interesting to see how fast the levels equalize between rooms
- edoo 8y agoArchitecturally speaking this should be a super simple script that pulls the sensor data into a database for any use instead of a custom written http server that manages the sensor.
- stackmad 8y agoYes, I agree. But this was way more fun :)
- bhouston 8y agoI would have just had the CO2 level read via a $8 I2C device connected to an Esp8266/Esp32 running Arduino. I would post the result to a web service in this fashion from the Esp8266: https://techtutorialsx.com/2016/07/21/esp8266-post-requests/ https://techtutorialsx.com/2016/07/21/esp8266-post-requests/ Then just setup a nice Graphana+Prometheus as a service, graphana.com is nice and can expose a Prometheus end point over basic http auth - easy to post to. Then you can setup alerts, graphs, dashboards, etc. In fact you could have a whole suite of IoT reports flowing in from various Arduinos really easily. Or at least a couple CO2 sensors spread around the house. Total investment of coding would be about 30-50 lines of Arduino code for the Esp8266 and you may even get away with the free plan on Graphana.com. I obviously like to outsource as much as possible these days. Less learning, but more efficient.
- stackmad 8y agoTotally true, but my soldering iron is in the basement, so ... ;)
- Hobohodo 8y agoWould you be able to share where you might get such a cheap CO2 sensor/the name of it? I've had trouble finding them for less than £60 in the UK and would like to set one up.
- RossM 8y agoAdafruit sell a 1-60,000 ppm equivalent-CO2 sensor for £15. https://www.adafruit.com/product/3709 https://www.adafruit.com/product/3709
- aaaaaaaaaab 8y agoThis doesn't measure CO2 levels. It measures volatile organic compounds and calculates the amount of CO2 that would cause the same greenhouse effect. >The SGP30 does have built in calibration capabilities, note that eCO2 is calculated based on H2 concentration, it is not a 'true' CO2 sensor for laboratory use.
- Waterluvian 8y agoI'm looking around for an affordable household CO2 measurement tool but they're all wildly expensive. Is this technology complicated and cannot be obtained for $30? They're all like $120+ Edit: I realised that this is a perfect item for public libraries to loan out. Expensive, only needed occasionally, easy to use, potential for significant positive public impact on becoming more informed and healthier. If you're looking for a cause that's affordable, practical, and local, consider buying and donating one to your local library.
- gsich 8y agoMH-Z14 or Z19. But this is just the sensor, you'll need an Arduino/ESP/Rpi too.
- AYBABTME 8y agoWhat's particular about these sensors? I've been researching technologies to monitor plant growth and haven't yet looked into CO2 sensors, hence my asking. Do they come in an IC package?
- gsich 8y agoThey use optical measurement, are reasonable in pricing. Outputs are UART, PWM and analoge. They have pins with 2.54mm spacing if that helps you.
- linuxlizard 8y agoI've been using the Microsoft cpprestsdk, too, but for client stuff. I've been enjoying using it.
- stackmad 8y agoYeah, its quite ok.
- t0mek 8y agoShameless plug: I wanted to measure PM10 and PM2.5 pollution level in my neighbourhood, so I built the ESP8266-based sensor using instructions from Luftdaten [1] and since the original interface is pretty ugly, I created my own UI: http://smog.rekawek.eu/ http://smog.rekawek.eu/ https://github.com/trekawek/air-quality-info https://github.com/trekawek/air-quality-info (I know, it's PHP, but can be hosted virtually anywhere!) [1] https://luftdaten.info/feinstaubsensor-bauen/ https://luftdaten.info/feinstaubsensor-bauen/
- blacksmith_tb 8y agoI built a pretty similar rig around an RPi Zero W, same SDS011 AQ sensor and BME280 temp/pressure/humidity sensors as Luftdaten, just polled by a couple of python scripts on cronjobs.
- anoncake 8y agoI believe the title should be "I wanted to build a C++ WebServer/App, so I built a C++ WebServer/App". Not that there anything wrong with that :)
- stackmad 8y ago:) But the CO2 measurement part honestly came first.
- thinkcontext 8y agoSounds like you have a ventilation problem, buildings are required by code to get a certain amount of fresh air from outside so that CO2, VOCs, chloroform, etc don't get too high. Incidentally, NHTSA projects in 2100 CO2 will be at 789ppm [0] in the atmosphere, up from 410 today and 350 pre-industrial. And there are higher projections. One would assume that this would make ventilation more urgent, I guess building codes will have to be updated and existing buildings retrofitted. [0] https://www.washingtonpost.com/national/health-science/trump-administration-sees-a-7-degree-rise-in-global-temperatures-by-2100/2018/09/27/b9c6fada-bb45-11e8-bdc0-90f81cc58c5d_story.html https://www.washingtonpost.com/national/health-science/trump...
- rhcom2 8y agoI wanted to do this in my office and was told, "if we find out something is wrong then we'd have to fix it." facepalm
- stackmad 8y agoLOL
- cherrypepsi 8y agoI think it's safe to say CO2 levels in your office are already over the limit with coworkers making arguments like that lol The company saved $25 though!
- khaki54 8y ago@dhh highly recommends Awair for air quality monitoring. He gave some talk on it after be bought one for his whole staff (can't find the talk for some reason) I got one and it's pretty cool. A bit of a game to get a high score.
- echofavor 8y agoThanks for sharing. You can also share your ideas for free on www.echofavor.com
- starbugs 8y agoFriend of stackmad here. Just wanted to let you know that he got himself a plant as a result of the CO2 measurements :)
- stackmad 8y agoActually its 9 plants ;)