sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

BMA400 #186

Closed shanemc1982 closed 9 months ago

shanemc1982 commented 9 months ago

Subject of the issue Please consider adding support for BMA400 Micro Triple Axis Accelerometer Breakout for OLA. I see that the module already contains an Arduino library at https://github.com/sparkfun/SparkFun_BMA400_Arduino_Library .

This sensor has the capability of detecting specific movement types such as walking, running and standing still. This would be useful to compare along with the raw accelerometer data in a logging situation

Expected behavior When the BMA 400 QWIIC board is plugged in, the OLA log data include the data from the secondary sensor.

Actual behavior When the BMA 400 QWIIC board is plugged in, the log data says "unknown device present at address 0x14" and does not log any data from the sensor.

PaulZC commented 9 months ago

Hi @shanemc1982 ,

Thank you for the interest in these products. But, unfortunately, adding the BMA400 is not something we can do at present. It has a ton of options and would require a lot of additional code. Please see #148 .

You could add it yourself and send us a Pull Request. Details are here. To help, there will be a docker file included in v2.6. There will also be GitHub workflow actions which will compile the firmware for you too. v2.6 should be available tomorrow.

Best wishes, Paul

shanemc1982 commented 8 months ago

Thank you Paul for this. I am attempting this now but i am struggling unfortunately. Dos other thing need to be done as well as the items at the link you provided. I was hoping to be able to link the current sparkfun BMA400 library to this. is this possible

PaulZC commented 8 months ago

Hi @shanemc1982 ,

Start with the unmodified code. Can you get it to compile successfully, following these instructions? Then start adding the new code for the BMA 400...

I hope this helps, Paul

shanemc1982 commented 8 months ago

I will try this from scratch again and see how things go. Thank you . I may come back to you again.

shanemc1982 commented 8 months ago

I have tried the two links that you have sent now and when i compile i get a whole load of errors as shown below. This is the same stage i got to previously and i could not see what i needed to change. It is probably something simple. once i have these sorted i think from looking at the code that the ola should see the sensor and i will be able to log data. I can send you the code file if you wish. your help is greatly appreciated.

Arduino: 1.8.19 (Windows 10), Board: "RedBoard Artemis ATP, 460800, SparkFun Variable Loader (Recommended)"

In file included from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\zmodem.ino:22:

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\zmodem_zm.h:34: warning: "FALSE" redefined

define FALSE 0

In file included from C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/bma400_api/bma400.h:53,

             from C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:8,

             from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\OpenLog_Artemis.ino:337:

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/bma400_api/bma400_defs.h:86: note: this is the location of the previous definition

define FALSE UINT8_C(0)

In file included from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\zmodem.ino:22:

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\zmodem_zm.h:35: warning: "TRUE" redefined

define TRUE 1

In file included from C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/bma400_api/bma400.h:53,

             from C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:8,

             from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\OpenLog_Artemis.ino:337:

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/bma400_api/bma400_defs.h:82: note: this is the location of the previous definition

define TRUE UINT8_C(1)

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino: In function 'void gatherDeviceValues(char*, size_t)':

Sensors:522:13: error: 'struct_BMA400' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino:522:13: note: suggested alternative: 'struct_BME400'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

         struct_BME400

Sensors:522:28: error: 'nodeSetting' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino:522:28: note: suggested alternative: 'loadSettings'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

                        loadSettings

Sensors:522:58: error: expected primary-expression before ')' token

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                                                      ^

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino: In function 'void getHelperText(char*, size_t)':

Sensors:1549:13: error: 'struct_BMA400' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino:1549:13: note: suggested alternative: 'struct_BME400'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

         struct_BME400

Sensors:1549:28: error: 'nodeSetting' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\Sensors.ino:1549:28: note: suggested alternative: 'loadSettings'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

                        loadSettings

Sensors:1549:58: error: expected primary-expression before ')' token

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                                                      ^

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\autoDetect.ino: In function 'bool addDevice(deviceType_e, uint8_t, uint8_t, uint8_t)':

autoDetect:177:31: error: 'struct_BMA400' does not name a type; did you mean 'struct_BME400'?

     temp->configPtr = new struct_BMA400;

                           ^~~~~~~~~~~~~

                           struct_BME400

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\autoDetect.ino: In function 'bool beginQwiicDevices()':

autoDetect:454:11: error: 'struct_BMA400' was not declared in this scope

       struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr; //Create a local pointer that points to same spot as node does

       ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\autoDetect.ino:454:11: note: suggested alternative: 'struct_BME400'

       struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr; //Create a local pointer that points to same spot as node does

       ^~~~~~~~~~~~~

       struct_BME400

autoDetect:454:26: error: 'nodeSetting' was not declared in this scope

       struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr; //Create a local pointer that points to same spot as node does

                      ^~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\autoDetect.ino:454:26: note: suggested alternative: 'loadSettings'

       struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr; //Create a local pointer that points to same spot as node does

                      ^~~~~~~~~~~

                      loadSettings

autoDetect:454:56: error: expected primary-expression before ')' token

       struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr; //Create a local pointer that points to same spot as node does

                                                    ^

autoDetect:456:23: error: 'class BMA400' has no member named 'setI2CAddress'

       tempDevice->setI2CAddress(temp->address);

                   ^~~~~~~~~~~~~

autoDetect:457:52: error: no matching function for call to 'BMA400::beginI2C(TwoWire&)'

       temp->online = tempDevice->beginI2C(qwiic); //Wire port

                                                ^

In file included from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\OpenLog_Artemis.ino:337:

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: candidate: 'int8_t BMA400::beginI2C(uint8_t, TwoWire&)'

     int8_t beginI2C(uint8_t address = BMA400_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire);

            ^~~~~~~~

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: no known conversion for argument 1 from 'TwoWire' {aka 'arduino::MbedI2C'} to 'uint8_t' {aka 'unsigned char'}

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\autoDetect.ino: In function 'deviceType_e testDevice(uint8_t, uint8_t, uint8_t)':

autoDetect:1391:17: error: 'class BMA400' has no member named 'setI2CAddress'

     sensor1.setI2CAddress(i2cAddress);

             ^~~~~~~~~~~~~

autoDetect:1392:35: error: no matching function for call to 'BMA400::beginI2C(TwoWire&)'

     if (sensor1.beginI2C(qwiic) == true) //Wire port

                               ^

In file included from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\OpenLog_Artemis.ino:337:

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: candidate: 'int8_t BMA400::beginI2C(uint8_t, TwoWire&)'

     int8_t beginI2C(uint8_t address = BMA400_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire);

            ^~~~~~~~

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: no known conversion for argument 1 from 'TwoWire' {aka 'arduino::MbedI2C'} to 'uint8_t' {aka 'unsigned char'}

autoDetect:1400:17: error: 'class BMA400' has no member named 'setI2CAddress'

     sensor1.setI2CAddress(i2cAddress);

             ^~~~~~~~~~~~~

autoDetect:1401:35: error: no matching function for call to 'BMA400::beginI2C(TwoWire&)'

     if (sensor1.beginI2C(qwiic) == true) //Wire port

                               ^

In file included from C:\Users\shane\Documents\Arduino\OpenLog_Artemis\OpenLog_Artemis.ino:337:

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: candidate: 'int8_t BMA400::beginI2C(uint8_t, TwoWire&)'

     int8_t beginI2C(uint8_t address = BMA400_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire);

            ^~~~~~~~

C:\Users\shane\Documents\Arduino\libraries\SparkFun_BMA400_Arduino_Library\src/SparkFun_BMA400_Arduino_Library.h:70:16: note: no known conversion for argument 1 from 'TwoWire' {aka 'arduino::MbedI2C'} to 'uint8_t' {aka 'unsigned char'}

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\menuAttachedDevices.ino: In function 'void menuConfigure_BMA400(void*)':

menuAttachedDevices:692:3: error: 'struct_BMA400' was not declared in this scope

struct_BMA400 sensorSetting = (struct_BMA400)configPtr;

^~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\menuAttachedDevices.ino:692:3: note: suggested alternative: 'struct_BME400'

struct_BMA400 sensorSetting = (struct_BMA400)configPtr;

^~~~~

struct_BME400

menuAttachedDevices:692:18: error: 'sensorSetting' was not declared in this scope

struct_BMA400 sensorSetting = (struct_BMA400)configPtr;

              ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\menuAttachedDevices.ino:692:18: note: suggested alternative: 'sensorAttr'

struct_BMA400 sensorSetting = (struct_BMA400)configPtr;

              ^~~~~~~~~~~~~

              sensorAttr

menuAttachedDevices:692:49: error: expected primary-expression before ')' token

struct_BMA400 sensorSetting = (struct_BMA400)configPtr;

                                             ^

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino: In function 'void recordDeviceSettingsToFile()':

nvm:614:13: error: 'struct_BMA400' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino:614:13: note: suggested alternative: 'struct_BME400'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

         ^~~~~~~~~~~~~

         struct_BME400

nvm:614:28: error: 'nodeSetting' was not declared in this scope

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino:614:28: note: suggested alternative: 'loadSettings'

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                        ^~~~~~~~~~~

                        loadSettings

nvm:614:58: error: expected primary-expression before ')' token

         struct_BMA400 *nodeSetting = (struct_BMA400 *)temp->configPtr;

                                                      ^

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino: In function 'bool parseDeviceLine(char*)':

nvm:1201:11: error: 'struct_BMA400' was not declared in this scope

       struct_BMA400 *nodeSetting = (struct_BMA400 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does

       ^~~~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino:1201:11: note: suggested alternative: 'struct_BME400'

       struct_BMA400 *nodeSetting = (struct_BMA400 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does

       ^~~~~~~~~~~~~

       struct_BME400

nvm:1201:26: error: 'nodeSetting' was not declared in this scope

       struct_BMA400 *nodeSetting = (struct_BMA400 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does

                      ^~~~~~~~~~~

C:\Users\shane\Documents\Arduino\OpenLog_Artemis\nvm.ino:1201:26: note: suggested alternative: 'loadSettings'

       struct_BMA400 *nodeSetting = (struct_BMA400 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does

                      ^~~~~~~~~~~

                      loadSettings

nvm:1201:56: error: expected primary-expression before ')' token

       struct_BMA400 *nodeSetting = (struct_BMA400 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does

                                                    ^

Multiple libraries were found for "SdFat.h"

Used: C:\Users\shane\Documents\Arduino\libraries\SdFat

Not used: C:\Users\shane\Documents\Arduino\libraries\SdFat_-_Adafruit_Fork

exit status 1

'struct_BMA400' was not declared in this scope

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

PaulZC commented 8 months ago

Hi @shanemc1982 ,

I don't have time to look at this. All I can do is give you a few pointers.

The first couple of errors are caused by FALSE and TRUE being defined in both the OLA code (zmodem.ino I think) and the bma400 library. They are just warnings so you are probably OK. But you may need to change one or the other. It will be easiest to change the OLA code if you do.

The next few errors are about struct_BMA400. Check you have updated settings.h correctly and have included the new struct for the BMA400.

The beginI2C error is caused by you not calling beginI2C correctly. It looks like you need to use temp->online = tempDevice->beginI2C(i2cAddress, qwiic); //Wire port and delete the calls to setI2CAddress.

Hope this helps, Paul

shanemc1982 commented 8 months ago

Thank you for your help. I understand that you are busy. I will try those suggestions and see how things go. hopefully they will sort most of the issues

shanemc1982 commented 8 months ago

Hi Paul,

Those comments have helped out a lot. thank you. I now have the BMA400 all added and compiling. now i can proceed to extract the data i wish to get from the sensor for logging.

Regards

Shane

shanemc1982 commented 8 months ago

Hi Paul,

Thank you for your help so far . Just one more query. I have the device added to the OLA code and i am able to read data from the BMA400. But i now have a problem where when i add the sd card the board does nothing. It will stream the data to the serial terminal no problem without the sd card connected. Any suggestions would be helpful

Regards

Shane

PaulZC commented 8 months ago

Hi Shane,

Do you see the same issue with unmodified firmware? Some SD cards take a big in-rush of current when the power is enabled, causing the OLA to brown-out. Please try a different SD card, and/or try:

https://github.com/sparkfun/OpenLog_Artemis/blob/main/COMPILE_BINARY.md#no-power-loss-protection

I hope this helps, Paul

shanemc1982 commented 8 months ago

Hi Paul,

I uncommented that line as suggested and logging to sdcard seems to be working. Your help is much appreciated.

Regards

Shane

shanemc1982 commented 8 months ago

OpenLog_Artemis BMA400 added.zip Attached is the code that i have modified to add the BMA400. It seems to be working. Not sure how it can be added to openlog main branch. Maybe needs more code written but it working for me