I have been working with many HATs along with Raspberry Pi such as Sense HAT, Pimoroni Enviro pHAT; and so on. However, HATs report its existence to the device tree in /proc/device-tree/hat
and /sys/firmware/devicetree/base/hat
(see details from here). I could extract few information (such as product, vendor; and so on) that were answered in that Q/A. I could enlist the list of sensors (i.e temperature, pressure, humidity; and so on) available on a HAT from vendor/manufacturer end (through website/guidelines) manually. The complexity increases as the number of HATs increases. Anyway, is it possible to read these information (list of available sensors on a HAT) either from PROM / EPROM / EEPROM?
1 Answer
There is nothing in HAT requirements about supplying a machine-readable list of sensors. Therefore, there is no generic methods to list sensors on a HAT: even if such a method exists, it will be manufacturer-specific at best and HAT-unique at worst.
HAT EEPROM contains either a device tree overlay or a name of such overlay in an external file. See if parsing that gives you the information you need (though it's far from a "list of sensors").
-
1In addition: There are Hats that don't even have an EEPROM module on them.– PMFCommented Apr 26, 2020 at 8:52
-
3
-
Are you suggesting to make an API to enlist the available sensors? For example, Sense HAT has six different sensors: 1) Temperature, 2) Humidity, 3) Pressure, 4) Accelerometer, 5) Magnetometer; and 6) Gyroscope.– testuserCommented Apr 28, 2020 at 7:19
How many sensors a HAT has on it and what are those?
andCould we enlist those sensors by reading the PROM / EPROM / EEPROM or DEVICE-TREE or manufacturer's API once the HAT (SenseHAT, or pHAT or whatever) determined?