element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Nicla ME standalone i2c to Raspberry Pi - easy open source code to read sensors -
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 2 replies
  • Subscribers 658 subscribers
  • Views 119 views
  • Users 0 members are here
  • raspberry-pi
  • raspberry_pi_projects
  • nicla ME
Related

Nicla ME standalone i2c to Raspberry Pi - easy open source code to read sensors -

robogary
robogary 7 days ago

Embedded coding help needed for an old padawan 

  1. Following this open source example to read NiclaME sensors using i2c, found at , https://github.com/werner-duvaud/nicla-sense-me-i2c

One step of the procedure requires "Arduino IDE" to load code into the NiclaME to setup i2c address, sensor calib, etc.  using   nicla_sens_me_i2c.ino

I get several IDE warning messages about the header files, and the .ino errors out on compile. 

C:\Users\GaryY\Data\Robotics\2025 Danger Will Robinson\Nicla_ME\nicla-sense-me-i2c-main\nicla-sense-me-i2c-main\arduino\nicla_sens_me_i2c\nicla_sens_me_i2c.ino: In function 'void setup()':

nicla_sens_me_i2c:213:14: error: 'NICLA_STANDALONE' was not declared in this scope

   BHY2.begin(NICLA_STANDALONE);


#include "Arduino_BHY2.h"
#include "Wire.h"

Here is the void setup() in nicla_sens_me_i2c.ino

void setup() {
// Init
BHY2.begin(NICLA_STANDALONE);
Wire.begin(I2C_ADDRESS);

// I2C callbacks.
Wire.onReceive(receiveEvent);
Wire.onRequest(requestHandler);
}

I poked around in the Arduino_BHY2.h code, there is no   'NICLA_STANDALONE" defined. Is that what the error is about ? 

2. Testing my Nicla ME using the Arduino IDE examples and the USB ports, it  seems to work fine.  The best open source code I've found so far has been this   werner-duvaud  package that I cant get past step 1 after trying out various different ways in the last 3 weeks. 

Can Anyone recommend another open source code for using this Nicla ME over i2c or SPI direct to the Raspberry Pi ? 

Thank you Obi Wan Kenobi , you're my only hope. 

 

  • Sign in to reply
  • Cancel
  • ralphjy
    ralphjy 6 days ago

    I can feel your pain.  I've been struggling to complete a 3 year old project using a Nicla Vision board.  I've been running into a ton of version incompatibility issues trying to get OpenMV, the Arduino CLI, and Edge Impulse CLI to work together.  I managed to almost work around my problems but have encountered issues trying to deploy my Edge Impulse model in OpenMV.  I'm about to call it quits for now since the Nicla Vision has other problems with vision models due lack of available RAM.

    Anyway back to your problem with the Arduino_BHY2 library, it's probably a mismatch of library versions.  I haven't used the Nicla Sense ME for a while so I thought that I'd try to compile the nicla_sens_me_i2c.ino program.  I used the latest Arduino_BHY2 v1.0.8 library with Arduino IDE v2.3.2 and Arduino Mbed OS Nicla Boards v4.3.1.

    NICLA_STANDALONE is defined in the BHY2.h file

    enum NiclaConfig {
      NICLA_I2C = 0x1, /*!< I2C Configuration, relevant for both ESLOV and Shield configurations */
      NICLA_BLE = 0x2, /*!< Bluetooth via the onboard ANNA-B112 module */
      NICLA_BLE_AND_I2C = NICLA_I2C | NICLA_BLE,/*!< Enable I2C (ESLOV/Shield) and BLE simultaneously */
      NICLA_STANDALONE = 0x4 /*!< Operate in standalone, without external data transfer */
    };

    I2C and BLE are enabled by default if the config is not specified.

    I was able to compile successfully after I fixed an error due to being unable to access _bhy2 from a calibration function "error: 'bhy2_dev BoschSensortec::_bhy2' is private within this context".  I fixed it by making it public (had to modify BoschSensortec.h).

    Not sure if any of this will help you but I think you should be able to get that program to compile so that you can try it out.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • robogary
    robogary 6 days ago in reply to ralphjy

    thank you ralphjy , good call , that is a great suggestion. This evening, I checked the library revs in my Arduino IDE. I'm using 1.8.19 Arduino, with Mbed Nicla 3.01 and Arduino_BHY2 1.04. 

    I upgraded Mbed Nicla to 4.3.1 and Arduino BHY2 to 1.08, skipping the Arduino IDE upgrade for now. I had to redo the mod to the BoschSensorTec.h  and voila, the code had warnings but it did compile and load to the NiclaME.

    YAY !   I just had to do one simple test tonight before bed and drifting off to dreamland. I wanted to see if the RPi could see it on i2c. 

    this is the nicla_sens_me_i2c.ino   relevant part of code:

    const uint8_t I2C_ADDRESS = 0x28;

    // I2C commands.
    // Naming from the point of view of the sensor.
    const uint8_t CMD_BEGIN = 0x60;
    const uint8_t CMD_SEND_CALIB = 0x5B;
    const uint8_t CMD_SEND_ORIENTATION = 0x1A;
    const uint8_t CMD_SEND_ACCELEROMETER = 0x08;
    const uint8_t CMD_SEND_LINEAR_ACCELERATION = 0x28;
    const uint8_t CMD_SEND_GYROSCOPE = 0x14;
    const uint8_t CMD_SEND_MAGNETOMETER = 0x0E;
    const uint8_t CMD_SEND_ROTATION = 0x20;
    const uint8_t CMD_SEND_TEMPERATURE = 0x50;
    const uint8_t CMD_FETCH_CALIB = 0x5A;
    const uint8_t CMD_RECEIVE_CALIB = 0x5D;
    const uint8_t CMD_APPLY_CALIB = 0x5E;
    const uint8_t CMD_DEFAULT = 0x00;
    const uint8_t CMD_DEFAULT_REPLY = 0xFF;

    To make sure a valid check, I wired in two more i2c sensors to the RPI4 i2Cbus with known i2c bus address (on stickers) from a previous project, a compass sensor (x1e) and an ADXL345  3 axis accelerometer/gyro (x53)

    image     image

    so......i2C doesnt see Nicla -----> more work to do, 

    Ran the Host setup Install the python library on the host to communicate with the sensor:

    git clone github.com/.../nicla-sense-me-i2c.git

    cd nicla-sense-me-i2c

    pip install .

    part of the install worked, part didnt. ( actually I tried a few more times different ways, pretty sure it did not install correctly)

    I retry the RPi i2c detect, still no x28.  

    Time to sleep before work tomorrow. Maybe the RPi4 needs to rest too. 

    Thank you for your help !  I will return in the next chapter of "Haphazard Adventures in Raspberry Pi Nicla ME Part Duex" 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube