OPEnSLab-OSU/Loom

Test Loom_LIS3DH - Winnie

Closed this issue · 2 comments

Initializes but the values don't change, Sparkfun/Adafruit examples work. Loom 2.5 also doesn't work

 = = = = = Generate Objects = = = = =

[Device] Adding Module: Analog
[LIS3DH] Initialize sucessful
[Device] Adding Module: LIS3DH
= = = = = = = = = = = = = = = = =

[Device] Config:
	Device Name         : Device
	Instance Number     : 1
	Device Type         : Node
	Interval            : 500
[Device] Modules:
		[+] Analog
		[+] LIS3DH

 ** Setup Complete ** 
[Device] Json:
{
  "type": "data",
  "id": {
    "name": "Device",
    "instance": 1
  },
  "contents": [
    {
      "module": "Packet",
      "data": {
        "Number": 1
      }
    },
    {
      "module": "Analog",
      "data": {
        "Vbat": 4.311914,
        "A[0]": 2136,
        "A[1]": 1792,
        "A[2]": 1728,
        "A[3]": 1522,
        "A[4]": 1891,
        "A[5]": 1942
      }
    },
    {
      "module": "LIS3DH",
      "data": {
        "ax": 25.49219,
        "ay": 25.49219,
        "az": 25.49219
      }
    }
  ]
}
[Device] Json:
{
  "type": "data",
  "id": {
    "name": "Device",
    "instance": 1
  },
  "contents": [
    {
      "module": "Packet",
      "data": {
        "Number": 2
      }
    },
    {
      "module": "Analog",
      "data": {
        "Vbat": 4.311914,
        "A[0]": 1766,
        "A[1]": 1637,
        "A[2]": 1644,
        "A[3]": 1490,
        "A[4]": 1697,
        "A[5]": 1759
      }
    },
    {
      "module": "LIS3DH",
      "data": {
        "ax": 25.49219,
        "ay": 25.49219,
        "az": 25.49219
      }
    }
  ]
}

The issue was some apparent confusion when implementing the LIS3DH into Loom with the Sparkfun dependency. From the dependency, the LIS3DH.begin() method returns 0 upon a success and greater values to signify an error. In Loom, the code treated begin() as type bool, and assumed that the Sparkfun dependency would return 0 on a failure (like most other sensors). So Loom was misinterpreting the dependencies return values and deactivating the Loom LIS3DH module.

It is worth noting that the Adafruit dependency (which Loom does not use as of right now) uses a traditional begin() scheme, returning 0 on a failure and 1 on a success. As far as I can tell, these dependencies are only compatible with their respective hardware. In other words, if Loom continues to use the Sparkfun dependency, it shall only work with the Sparkfun LIS3DH hardware, and vice versa with Adafruit's hardware and software.

The reason the LIS appeared to "initialize" but not return any changing values was because we were testing with the Adafruit hardware. Meaning it was not actually initializing at all, Loom just thought it was.