ESPEasy plugin for LSM9DS1
Moderators: grovkillen, Stuntteam, TD-er
ESPEasy plugin for LSM9DS1
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
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 201 times
Re: ESPEasy plugin for LSM9DS1
What does to code for Arduino look like? Is it using a specific library, that initializes the device?
/Ton (PayPal.me)
Re: ESPEasy plugin for LSM9DS1
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.
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 192 times
-
- Arduino_LSM9DS1.zip
- (7.98 KiB) Downloaded 192 times
Re: ESPEasy plugin for LSM9DS1
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.
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)
Re: ESPEasy plugin for LSM9DS1
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?
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?
Re: ESPEasy plugin for LSM9DS1
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)
Re: ESPEasy plugin for LSM9DS1
Greetings.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.
What ESPeasy firmware is HMC5883 implemented in?
Trying to search for ESP8266 - unsuccessful
Re: ESPEasy plugin for LSM9DS1
Those sensors are in the TEST_E builds, but have not been included in a (nightly) release yet.Alex_UUU wrote: ↑05 Mar 2022, 09:17Greetings.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.
What ESPeasy firmware is HMC5883 implemented in?
Trying to search for ESP8266 - unsuccessful
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)
Re: ESPEasy plugin for LSM9DS1
Thank you very much.
Who is online
Users browsing this forum: No registered users and 30 guests