1

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?

testuser
  • 85
  • 1
  • 2
  • 10
  • 2
    "It would be very easy if there is an automated way." This made me laugh :) – Seamus Apr 23 '20 at 14:39
  • 1
    My point is not that actually for what you have been laughing. The point was that How many sensors a HAT has on it and what are those? and Could 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? – testuser Apr 23 '20 at 15:55
  • Yes, sorry - my humor was inappropriate. – Seamus Apr 23 '20 at 15:56

1 Answers1

3

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").

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
  • 1
    In addition: There are Hats that don't even have an EEPROM module on them. – PMF Apr 26 '20 at 08:52
  • 3
    @PMF Those are add-on boards, not HATs. – Dmitry Grigoryev Apr 26 '20 at 12:10
  • 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. – testuser Apr 28 '20 at 07:19