overthesun / simoc-sam

Live backend for SAM at Biosphere 2
2 stars 1 forks source link

Document sensors setup #20

Open ezio-melotti opened 2 years ago

ezio-melotti commented 2 years ago

We should either document how to install the sensors, or link to the Adafruit docs that explain how to do it.

On a desktop/laptop, the MCP-2221 should be installed first. This guide explains how to do it on Linux, but most steps can be skipped except the "Setup udev rules". libusb and libudev should already be installed on recent distros, and I'm not entirely sure they are needed (but they can be installed anyway just to make sure). hidapi and adafruit-blinka are needed, but can be installed later with the rest. Removing the hid_mcp2221 is not necessary (it will segfault on exit, but it works). Setting the env var is done by the driver already.

In summary:

  1. write SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTR{idProduct}=="00dd", MODE="0666" into /etc/udev/rules.d/99-mcp2221.rules
  2. run python3 -m pip install hidapi adafruit-blinka adafruit-circuitpython-scd30

This will setup both the MCP2221 and the SCD-30 on Linux, with all the modules needed by both. On MacOS, the first step can be skipped.

This could be documented either in the sensor driver file directly, and or in the README.md or in a separate doc file.

ezio-melotti commented 1 year ago

On Linux, import board might fail with OSError: open failed. To fix the problem, on top of editing /etc/udev/rules.d/99-mcp2221.rules as suggested in the previous message, it might also be necessary to run

rmmod hid_mcp2221
sudo vim /etc/modprobe.d/blacklist.conf
# add this at the end, save, and exit: blacklist hid_mcp2221
sudo update-initramfs -u

If this still doesn't work, unplugging and replugging the MCP and/or rebotting the pc might help.

This issue describes the problem (and solutions) in detail: