ESPEasy plugin for LSM9DS1

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
fodome
New user
Posts: 7
Joined: 16 Feb 2022, 00:43

ESPEasy plugin for LSM9DS1

#1 Post by fodome » 16 Feb 2022, 19:17

Hi guys,

I'm currently working on a school project that requires me to measure acceleration. In order to do so, we are using the LSM9DS1 9-DOF accelerometer/gyroscope/magnetometer and an ESP32 microcontroller. We wish to connect the two using ESPEasy. All three components are mandatory (request of our client). However, there is no ESPEasy Plugin for this accelerometer. Therefore, we took the ESPEasy Plugin for the MPU6050 accelerometer and tried modifying it to work with the LSM9DS1. Here are the changes we implemented:

-Modification of the addresses for the registers (according to our accelerometer data sheet)
-Adjustment of the buffers according to the bytes format of our data (also taken from the data sheet)

The plugin that we've modified works, but only if we have used the accelerometer and microcontroller with Arduino IDE before hand. If we reset the controller and then try the plugin once again it returns 0 for the readings of the pins (we put an addLog in this section to see the output). It's as if the pins need to be activated (which Arduino would do, but our plugin doesn't do?)....

I'm not quite sure what to make of it. Any help would be appreciated :)
Attachments
Data_Sheets.zip
(1.51 MiB) Downloaded 197 times

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESPEasy plugin for LSM9DS1

#2 Post by Ath » 16 Feb 2022, 19:25

What does to code for Arduino look like? Is it using a specific library, that initializes the device?
/Ton (PayPal.me)

fodome
New user
Posts: 7
Joined: 16 Feb 2022, 00:43

Re: ESPEasy plugin for LSM9DS1

#3 Post by fodome » 16 Feb 2022, 19:47

The code that I'm using in Arduino is the one from the Adafruit LSM9DS1 library (see attachments). The Adafruit Unified Sensor library is also used (also in attachements).

I also set my board to the Adafruit ESP32 Feather that I added in the additional boards manager with the following: https://dl.espressif.com/dl/package_esp32_index.json

The big part of the initialization seems to be in the Adafruit_LSM9DS1.cpp, but I'm not super familiar with it.
Attachments
Adafruit_Unified_Sensor.zip
(4.89 KiB) Downloaded 189 times
Arduino_LSM9DS1.zip
(7.98 KiB) Downloaded 189 times

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESPEasy plugin for LSM9DS1

#4 Post by Ath » 16 Feb 2022, 20:22

The 'trouble' with that Adafruit library is that it's perfectly fine for an Arduino project, but less optimal for ESPEasy, as it does the management of the I2C or SPI bus all by itself, while ESPEasy is already perfectly fine in managing those buses. So that's not a good combo. I often prefer using the Sparkfun libraries, that usually offer the same functionality, but are less enforcing on the bus management, without pulling in other libraries. And they are a little easier to adjust for ESPEasy use.

Looking at the code, there is some initialization being done, that is required to get the device going.
Another issue is the number of measurement values available, as ESPEasy only supports up to 4 values per task (devices page), but with the proper implementation, you could define 3 separate tasks, and select what sensor values to present in each task.

NB: We've recently added support for the ITG3205, ADXL345 and HMC5883 sensors, that are available combined on a single board, and offer features similar to this LSM9DS1 sensor.
/Ton (PayPal.me)

fodome
New user
Posts: 7
Joined: 16 Feb 2022, 00:43

Re: ESPEasy plugin for LSM9DS1

#5 Post by fodome » 16 Feb 2022, 20:30

Unfortunately, we absolutely have to use the LSM9DS1.

Would there be a way to implement the part of the Arduino code that does the initialization to get the device going into the ESPEasy plugin?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESPEasy plugin for LSM9DS1

#6 Post by Ath » 16 Feb 2022, 20:40

Have a look at the begin() method in the .cpp file, after the I2C/SPI shenanigans you can probably ignore, there is some initialization written to the device, you could use that as 'inspiration' in the PLUGIN_INIT event of the plugin.
/Ton (PayPal.me)

Alex_UUU
New user
Posts: 2
Joined: 05 Mar 2022, 09:09

Re: ESPEasy plugin for LSM9DS1

#7 Post by Alex_UUU » 05 Mar 2022, 09:17

NB: We've recently added support for the ITG3205, ADXL345 and HMC5883 sensors, that are available combined on a single board, and offer features similar to this LSM9DS1 sensor.
Greetings.
What ESPeasy firmware is HMC5883 implemented in?
Trying to search for ESP8266 - unsuccessful

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESPEasy plugin for LSM9DS1

#8 Post by Ath » 05 Mar 2022, 09:42

Alex_UUU wrote: 05 Mar 2022, 09:17
NB: We've recently added support for the ITG3205, ADXL345 and HMC5883 sensors, that are available combined on a single board, and offer features similar to this LSM9DS1 sensor.
Greetings.
What ESPeasy firmware is HMC5883 implemented in?
Trying to search for ESP8266 - unsuccessful
Those sensors are in the TEST_E builds, but have not been included in a (nightly) release yet.
You can download from the latest merge build, to get all improved features, here (NB: After the next merge of a PR this build will be 'outdated'..., but will still work fine, of course ;) )
/Ton (PayPal.me)

Alex_UUU
New user
Posts: 2
Joined: 05 Mar 2022, 09:09

Re: ESPEasy plugin for LSM9DS1

#9 Post by Alex_UUU » 05 Mar 2022, 13:31

Thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests