Wrapping Sensors in GenServers
From the previous chapter, you already know the VEML6030 sensor works well with the Circuits.I2C interface, and you can to interact with it by writing I2C commands and reading the response. While users could call the sensor straight from I2C, it would be nice to shield them from many tedious I2C details. The spec sheets have details, such as configuration settings and conversion factors, that our users shouldn’t have to know.
While we could put the GenServer wrapper directly in the sensor_hub project, it would be better for our architecture to instead lean on the poncho project structure and split this out into its own separate project. We can then lean on Mix’s ability to resolve path dependencies and use our ...
Get Build a Weather Station with Elixir and Nerves now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.