Code Monkey home page Code Monkey logo

firmware-nordic-nrf52840dk-nrf5340dk's Introduction

Edge Impulse firmware for nRF52840 DK / nRF5340 DK

Edge Impulse enables developers to create the next generation of intelligent device solutions with embedded Machine Learning. This repository contains the Edge Impulse firmware for the Nordic Semiconductor nRF52840 DK / nRF5340 DK development boards, in combination with the ST X_NUCLEO-IKS02A1 shield. This combination supports all Edge Impulse device features, including ingestion, remote management and inferencing.

Note: Do you just want to use this development board with Edge Impulse? No need to build this firmware. See the instructions for the nRF52840 DK and the nRF5340 DK for prebuilt images and instructions, or use the data forwarder to capture data from any sensor.

Building the device firmware (locally)

  1. Install the nRF Connect SDK in a separate folder from this repository (e.g. ~/repos/ncs).

  2. Clone this repository:

    $ git clone https://github.com/edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk
  3. Build the application:

    nRF52840 DK

    $ west build -b nrf52840dk_nrf52840

    nRF5340 DK

    $ west build -b nrf5340dk_nrf5340_cpuapp

Building the device firmware (Docker)

  1. Clone this repository:

    $ git clone https://github.com/edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk
  2. Build the Docker container:

    $ docker build -t edge-impulse-nordic .
  3. Build the application:

    nRF52840 DK

    $ docker run --rm -v $PWD:/app edge-impulse-nordic west build -b nrf52840dk_nrf52840

    nRF5340 DK

    $ docker run --rm -v $PWD:/app edge-impulse-nordic west build -b nrf5340dk_nrf5340_cpuapp

Flashing (JLink Mass Storage)

  1. Connect the board and power on.
  2. Copy build/zephyr/zephyr.bin to the JLINK mass storage device.

Flashing (command line)

  1. Connect the board and power on.

  2. Flash the board controller firmware:

    $ cd board-controller/
    $ west flash

Working with other sensors

You can easily add support for other accelerometers, PDM microphones or even completely different sensors to this firmware through either built-in Zephyr drivers, or through the Zephyr sensor API. Here's an example of adding the IIS2DLPC accelerometer through the sensor API:

  1. Connect to the sensor using the device tree through an overlay file, and add the sensor definition in the project configuration.

    nrf52840dk_nrf52840.overlay

    &i2c0 {
        clock-frequency = <I2C_BITRATE_FAST>;
        iis2dlpc@19 {
            compatible = "st,iis2dlpc";
            reg = <0x19>;
            drdy-gpios =  <&gpio0 30 GPIO_ACTIVE_HIGH>; /* A4 - INT2 */
            label = "IIS2DLPC";
        };
    };
    

    prj.conf

    CONFIG_SENSOR=y
    CONFIG_IIS2DLPC=y
    CONFIG_IIS2DLPC_ACCEL_RANGE_2G=y
    CONFIG_IIS2DLPC_ODR_1600=y
    CONFIG_IIS2DLPC_POWER_MODE=4
    
  2. Update the source code to reference the new sensor. The IMU sensor source is located in ei_inertialsensor.cpp.

    Declare any objects required by the sensor:

    const struct device *accel;
    struct sensor_value accel_x;
    struct sensor_value accel_y;
    struct sensor_value accel_z;

    Then, initialize the sensor in the bool ei_inertial_init() function:

    accel = DEVICE_DT_GET("IIS2DLPC");
    if(accel == NULL){
        ei_printf("No device IIS2DLPC found; did initialization fail\n");
    }
    else{
        ei_printf("Found device IIS2DLPC\n");
    }

    And, finally, read from the sensor in the void ei_inertial_read_data(void) function:

    if(accel) {
        sensor_sample_fetch(accel);
        sensor_channel_get(accel, SENSOR_CHAN_ACCEL_X, &accel_x);
        sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Y, &accel_y);
        sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Z, &accel_z);
        acceleration_g[0] = sensor_value_to_double(&accel_x);
        acceleration_g[1] = sensor_value_to_double(&accel_y);
        acceleration_g[2] = sensor_value_to_double(&accel_z);
    
        cb_sampler((const void *)&acceleration_g[0], SIZEOF_N_AXIS_SAMPLED);
        k_usleep(sample_interval_real_us);
    }

    Last, delete all code related to the old sensor driver.

  3. Compile and flash the application.

You can find more information in the Zephyr RTOS sensors API documentation, and the Sensor samples.

firmware-nordic-nrf52840dk-nrf5340dk's People

Contributors

automatiek avatar janjongboom avatar mmajchrzycki avatar rajames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.