Brian Boyles
Published

Homemade CO2 Sensor Unit

A quick and easy guide for making your own carbon-dioxide sensor unit to measure the percentage of carbon dioxide gas.

IntermediateFull instructions provided2 hours6,724
Homemade CO2 Sensor Unit

Things used in this project

Story

Read more

Schematics

SCD30 schematic

Connected devices

BME280 schematic

Code

peripherals.py code

Python
Code snippet to replace in peripherals.py python file in your CO2 folder.
from values import environment  
class Peripherals:  
   def __init__(self, sendQueue):  
       self.env = environment.Environment(sendQueue)  
   def get_value_sensors_co2(self):  
       return self.env.get_co2()  
   def get_value_sensors_temperature(self):  
       return self.env.get_temperature()  
   def get_value_sensors_pressure(self):  
       return self.env.get_pressure()  
   def get_value_sensors_humidity(self):  
       return self.env.get_humidity()

PuTTY connect to Pi

snippets
Commands to connect to the Raspberry Pi
sudo apt-get install rpi.gpiowiringpi python3-dev python3-pip i2c-tools

sudo apt-get update

I2C Detect

snippets
Commands for activating I2C on your device
sudo rasp-config

sudo i2cdetect -y 1

Device json file

JSON
The Code for creating a CO2 Device in "Seluxit IoT Creator" in Wappsto. You can just copy-paste this code when you click "Create from JSON"
{
	"meta": {
		"type": "network",
		"version": "2.0"
	},
	"name": "Co2",
	"device": [{
		"meta": {
			"type": "device",
			"version": "2.0"
		},
		"name": "Sensors",
		"version": "2.0",
		"value": [{
			"meta": {
				"type": "value",
				"version": "2.0"
			},
			"name": "CO2",
			"permission": "r",
			"type": "co2",
			"number": {
				"unit": "PPM",
				"max": 10000,
				"min": 0,
				"step": 1
			},
			"status": "ok",
			"state": [{
				"meta": {
					"type": "state",
					"version": "2.0",
					"contract": []
				},
				"data": "0",
				"status": "Send",
				"type": "Report",
				"timestamp": "2019-07-04T09:01:07Z"
			}]
		}, {
			"meta": {
				"type": "value",
				"version": "2.0"
			},
			"name": "Temperature",
			"permission": "r",
			"type": "temperature",
			"number": {
				"unit": "Celsius",
				"max": 150,
				"min": -40,
				"step": 0.1
			},
			"status": "ok",
			"state": [{
				"meta": {
					"type": "state",
					"version": "2.0",
					"contract": []
				},
				"data": "0",
				"status": "Send",
				"type": "Report",
				"timestamp": "2019-07-04T09:01:07Z"
			}]
		}, {
			"meta": {
				"type": "value",
				"version": "2.0"
			},
			"name": "Pressure",
			"permission": "r",
			"type": "pressure",
			"number": {
				"unit": "Pa",
				"max": 10000,
				"min": 0,
				"step": 1
			},
			"status": "ok",
			"state": [{
				"meta": {
					"type": "state",
					"version": "2.0",
					"contract": []
				},
				"data": "0",
				"status": "Send",
				"type": "Report",
				"timestamp": "2019-07-04T09:01:07Z"
			}]
		}, {
			"meta": {
				"type": "value",
				"version": "2.0"
			},
			"name": "Humidity",
			"permission": "r",
			"type": "humidity",
			"number": {
				"unit": "%",
				"max": 100,
				"min": 0,
				"step": 0.1
			},
			"status": "ok",
			"state": [{
				"meta": {
					"type": "state",
					"version": "2.0",
					"contract": []
				},
				"data": "0",
				"status": "Send",
				"type": "Report",
				"timestamp": "2019-07-04T09:01:07Z"
			}]
		}]
	}]
}

Start connection and reporting

snippets
Commands to connect your device to the cloud and start extracting the data generated from the sensors.
sudo pip3 installsmbus2 numpy

cd 12d53bd7-4954-40a0-a5cf-ee9c39c4681a

sudo python3 main.py

Credits

Brian Boyles

Brian Boyles

2 projects • 4 followers
Thanks to Karsten Tonnesen, Daniel Lux and Evelina Mihailova, Martin Balgarinov.

Comments