Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul sensor configuration and management #36

Closed
Conr86 opened this issue Dec 6, 2019 · 0 comments · Fixed by #38
Closed

Overhaul sensor configuration and management #36

Conr86 opened this issue Dec 6, 2019 · 0 comments · Fixed by #38
Assignees
Milestone

Comments

@Conr86
Copy link
Member

Conr86 commented Dec 6, 2019

Is your feature request related to a problem? Please describe.
At the moment, the temperature key in the config file (within the sensors section) will use the MLX90614 wrapper. I've written untested support for a different temp sensor as an example in some new documentation I'm writing and we could even make it a supported sensor. The issue is that temperature is hardcoded to mlx90614.

Describe the solution you'd like
We could change it to mlx90614 of course, that would fix the problem. This would mean using the sensor name as the key in the JSON file for sensors. So, bme280 for the new type of temperature sensor and mlx90614 for the type we use.

However, this still doesn't allow for multiple sensors of the same type.

My proposed solution would be to change the sensors section of the config file to an array.

Here's an example of how the sensors section will look. Note how we have multiple of one type of sensor, as well as multiple different types of temperature sensors.

"sensors": [
	{
		"type": "amg8833",
		"name": "Thermal Camera",
		"enabled": true,
		"frequency": 0.5,
		"width": 32,
		"height": 24
	},
	{
		"type": "mlx90614",
		"name": "Temperature Sensor (front)",
		"enabled": true,
		"frequency": 2,
		"address": "0x5A"
	},
	{
		
		"type": "bme280",
		"name": "Temperature Sensor (back)",
		"enabled": true,
		"frequency": 4
	},
	{ 
		"type": "vl53l0x",
		"name": "Distance Sensor (1)",
		"enabled": true,
		"frequency": 2,
		"address": "0x2A"
	},
	{ 
		"type": "vl53l0x",
		"name": "Distance Sensor (2)",
		"enabled": true,
		"frequency": 2,
		"address": "0x2B"
	},
	{
		"type": "sgp30",
		"name": "Gas Sensor",
		"enabled": true,
		"frequency": 2
	}
	{
		"type": "memory",
		"name": "System Memory",
		"enabled": true,
		"frequency": 3
	},
	{
		"type": "cpu_temp",
		"name": "CPU Temperature",
		"enabled": true,
		"frequency": 5
	},
},

Additionally, this means we can implement proper sensor management.

sensor_stream.py needs to look through the config file, find active sensors, lookup their respective SensorWrapper class (we need to make a basic lookup table) and create a new instance of that class and append it to the sensors array

The lookup table basically needs to function like this, that takes the type key from the configuration file and returns the appropriate class:

{
	"mlx90614": MLX90614Wrapper,
	"sgp30": SGP30Wrapper,
	"bme280": BME280Wrapper
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant