@rickkas7 Hi Rick, can you tell me how to use the SPI mode with Electron and LIS3DH? I want to let Electron not sending any data when it is moving. So how to use your library?
I saw your MovingExample.cpp in your Github repository. But I am confused with the wire connection:
// LIS3DH is connected as in the AssetTracker, to the primary SPI with A2 as the CS (SS) pin, and INT connected to WKP
LIS3DHSPI accel(SPI, A2, WKP);
Does Electron have a pin named SPI? I know there is a WKP in on Electron, but I donāt find a SPI pin.
SPI uses three āfixedā pins (CLK, MISO, MOSI) and one free to choose SS/CS pin to select which SPI device you want to talk to, when you have more than one device sharing the same bus.
Only ever one slave is allowed to have its SS/CS pin pulled low at any given moment.
Thanks. Yes, I2C mode works fine and I can get X,Y, Z. I am wondering how I can determine whether the device is static or not by X,Y, Z. Should I use SPI mode because your moving example uses SPI mode.
No, use the moving example, just change the definition for accel to use the LIS3DI2C object instead. The motion detection options work for both I2C and SPI the same way, so I didnāt replicate every combination of test.
If I recall correctly, the LIS3DH does not have built-in gravity compensation. So if itās sitting flat, Iād expect it to have a Z acceleration of 9.8 meters/sec^2 due to gravity. Itās worse when itās tilted, because there will be some effects of gravity on X and Y as well. You either have to ignore Z, compensate for it, or do the math to handle tilting.
Some other accelerometers, like the ADXL365, have a mode where you calibrate its gravity cancellation, but I donāt think the LIS3DH does that.
How would you use this LIS3DH ( https://github.com/rickkas7/LIS3DH) library to only monitor the X axis and to ignore Y and Z? Do you you have to modify the library? Iāve got it working great using the examples, but Iām not sure how to customize the other settings. An example would be great.
Hello Rick,
I have no hardware yet and I am scoping out the support on the LIS3DH for a new project with a BluzDK.
I want to use the tapping feature and the temperature measure.
I read a couple coding examples from your library and Sparkfun to understand how to read the temperature.
I also tried to read here how to get temperature info and this file includes a comment that has me thinking I should use a different sensor:
//Note: By also setting tempEnabled = 1, temperature data is available
//on ADC3. Temperature differences can be read at a rate of
//1 degree C per unit of ADC3
First of all, do you expect I will be able to run your code on a BluzDK with I2C?
Have you tried reading the temperature? What is meant by differences? I see a comment in the header file about the sensor being āhorribly inaccurateā. There is very little coverage in the datasheet, but it states it is calibrated at Vdd=2.5V. The designs I found use 3.3V.
Finally, I am not sure how to adapt the Sparkfun ADC examples with your library to read the temperature.
Yes. sort of. You canāt use the AssetTracker class, which is the compatibility layer that makes it look like the regular AssetTracker library.
But you can use the LIS3DH and TinyGPS++ classes directly with the LIS3DH in I2C mode and the GPS in regular serial mode. Most of the AssetTracker compatibly methods are a thin layer on top of the LIS3DH and TinyGPS++ methods, so itās not hard to write to the underlying API. There are several examples that do that.
I noticed that the program would constantly use the previous GPS Fix location data even though it had zero satellites in view. If I would have moved the GPS unit it would have still used the old GPS position data even though I was someplace different.
I looked this up and others noticed the same issue with the gps.location.isValid() command.
Here is a way to force the code to get a new GPS fix if the old GPS position data is older than a preset threshold.
Thatās a reasonable workaround. Basically once the GPS goes valid, itās never not valid again. Itās just the way it works, but I didnāt understand that when I wrote the code. Checking the age is a reasonable way to work around it.
It states the device was no found, printing āāno sampleāā continously. In addition, using accel.calibrateFilter wonāt do anything either. However, the Wakeonmove example does seem to work as it will wake up the Electron and even the sensitivty seems adjustable with code.
When I use the code with my Asset Tracker it works flawlessly.