current sensing

Hello everyone,
i'm trying to deal with the ACS714T sensor 
but i can't find any samples or guide through internet 
the communication need to be done through ADC and SAADC HAL
but i don't know from where to begin with this 
i tried the ADC sample on the Zephyr documentation to have a closer look but it didn't help me a lot
is there a guide on how to do with the sensors that are not premade by Nordic 
what do i need to do first to deal with this sensor ?  
i'm a bit lost with it 
can you give me some guidance please 
i would appreciate your help 

Parents
  • Hello,
    i found this tutorial ADC conf
    i tried to make something similar but i don't succeed to run it 
    i'm putting it below 
    please correct me 
    acs714 t.zip

  • Hello everyone,
    i created a new version of project based on ADC sample 
    on the NRF5340dk 
    but i think i'm missing something related to the overlay file 
    this is my projectp_adc.zip
    i'm keeping getting the error of the device tree it says #error "No suitable devicetree overlay specified"

    Rebuilding ‘C_COMPILER__app_’ from project ‘app/libapp.a’ from solution ‘build’ in configuration ‘Common’
    2> Compiling ‘main.c’
    2> C:\Users\rzaafouri\ncs\v1.7.0\toolchain\opt/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.6.99-ncs1 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/Users/rzaafouri/ncs/v1.7.0/zephyr/include -Izephyr/include/generated -IC:/Users/rzaafouri/ncs/v1.7.0/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/Users/rzaafouri/ncs/v1.7.0/nrf/include -IC:/Users/rzaafouri/ncs/v1.7.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/Users/rzaafouri/ncs/v1.7.0/modules/hal/nordic/nrfx -IC:/Users/rzaafouri/ncs/v1.7.0/modules/hal/nordic/nrfx/drivers/include -IC:/Users/rzaafouri/ncs/v1.7.0/modules/hal/nordic/nrfx/mdk -IC:/Users/rzaafouri/ncs/v1.7.0/zephyr/modules/hal_nordic/nrfx/. -isystem C:/Users/rzaafouri/ncs/v1.7.0/zephyr/lib/libc/minimal/include -isystem c:/users/rzaafouri/ncs/v1.7.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem c:/users/rzaafouri/ncs/v1.7.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -Os -imacros C:/Users/rzaafouri/ncs/v1.7.0/Projects/p_adc/build_nrf5340dk_nrf5340_cpuapp_ns/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.7.0/Projects/p_adc=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.7.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.7.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MF C:/Users/rzaafouri/ncs/v1.7.0/Projects/p_adc/build_nrf5340dk_nrf5340_cpuapp_ns/CMakeFiles\app.dir\src\main.c.obj.d -fno-diagnostics-show-caret -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
    2> ../src/main.c:7:2: error: #error "No suitable devicetree overlay specified"
    2> In file included from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/arch/arm/aarch32/arch.h:20,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/arch/cpu.h:19,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/kernel_includes.h:33,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/kernel.h:17,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/zephyr.h:18,
    2>                  from ../src/main.c:1:
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:81:17: error: 'DT_N_S_zephyr_user_P_io_channels_LEN' undeclared here (not in a function)
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2542:24: note: in definition of macro 'DT_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:560:36: note: in expansion of macro 'DT_PROP'
    2> ../src/main.c:10:26: note: in expansion of macro 'DT_PROP_LEN'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/sys/util_internal.h:84:26: note: in expansion of macro 'UTIL_PRIMITIVE_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2524:2: note: in expansion of macro 'UTIL_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2524:11: note: in expansion of macro 'DT_ROOT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:129:22: note: in expansion of macro 'DT_PATH_INTERNAL'
    2> ../src/main.c:10:38: note: in expansion of macro 'DT_PATH'
    2> ../src/main.c:31:28: note: in expansion of macro 'ADC_NUM_CHANNELS'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:81:17: error: 'DT_N_S_zephyr_user_P_io_channels_IDX_0_VAL_input' undeclared here (not in a function)
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2542:24: note: in definition of macro 'DT_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:1075:2: note: in expansion of macro 'DT_PROP'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree/io-channels.h:274:2: note: in expansion of macro 'DT_PHA_BY_IDX'
    2> ../src/main.c:32:2: note: in expansion of macro 'DT_IO_CHANNELS_INPUT_BY_IDX'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/sys/util_internal.h:84:26: note: in expansion of macro 'UTIL_PRIMITIVE_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2524:2: note: in expansion of macro 'UTIL_CAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:2524:11: note: in expansion of macro 'DT_ROOT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/devicetree.h:129:22: note: in expansion of macro 'DT_PATH_INTERNAL'
    2> ../src/main.c:32:30: note: in expansion of macro 'DT_PATH'
    2> In file included from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/toolchain/gcc.h:66,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/toolchain.h:43,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/kernel_includes.h:19,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/kernel.h:17,
    2>                  from C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/zephyr.h:18,
    2>                  from ../src/main.c:1:
    2> ../src/main.c: In function 'main':
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:80:39: error: '__device_dts_ord_DT_N_S_zephyr_user_P_io_channels_IDX_0_PH_ORD' undeclared (first use in this function)
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:80:31: note: in expansion of macro '_CONCAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:232:37: note: in expansion of macro 'DEVICE_NAME_GET'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    2> ../src/main.c:61:33: note: in expansion of macro 'DEVICE_DT_GET'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:80:39: note: each undeclared identifier is reported only once for each function it appears in
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:80:31: note: in expansion of macro '_CONCAT'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:232:37: note: in expansion of macro 'DEVICE_NAME_GET'
    2> C:/Users/rzaafouri/ncs/v1.7.0/zephyr/include/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    2> ../src/main.c:61:33: note: in expansion of macro 'DEVICE_DT_GET'
    2> At top level:
    2> ../src/main.c:38:16: warning: 'sample_buffer' defined but not used [-Wunused-variable]
    2> ../src/main.c:31:16: warning: 'channel_ids' defined but not used [-Wunused-variable]
    Build failed

    can you help me with this please 

  • Hello,

    The tutorial you linked used NCS v1.4.0, but the board names has since changed, so you will need to rename the overlay file from nrf5340dk_nrf5340_cpuappns to nrf5340dk_nrf5340_cpuapp_ns for this to work with newer versions of the NCS SDK.
    Please try this, and let me know if the issue persists.

    Best regards,
    Karl

  • Hello,
    i did changed the overlay file name but it doesn't work anymore
    it's not even opening 

Reply Children
  • what can i do please to figure out this issue, i can no longer open my project 
    can you help me please 

  • Hello again,

    I just looked over your overlay file. Please change your adc section to instead be:

    &adc{  
    
            compatible = "nordic,nrf_saadc,nrf_adc";
    
            status = "okay";
    
    };

    I.e remove the compatible line and add a semicolon at the end.

    Best regards,
    Karl

  • Hello again,
    i even created a new project with the same items within and with the config you recommended in previous comments but unfortunately always the same error 
    " create_nordic_project.py failed(1) and i can't open the project 

  • here's the output after the error " create_nordic_project.py failed(1)"

    Creating solution adc.emProject
    C:/Users/rzaafouri/ncs/v1.7.0/toolchain/opt/bin/cmake.exe -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp_ns -DBOARD_DIR=C:\Users\rzaafouri\ncs\v1.7.0\zephyr\boards\arm\nrf5340dk_nrf5340 -BC:\Users\rzaafouri\ncs\v1.7.0\zephyr\samples\drivers\adc\build_nrf5340dk_nrf5340_cpuapp_ns -SC:\Users\rzaafouri\ncs\v1.7.0\zephyr\samples\drivers\adc -DNCS_TOOLCHAIN_VERSION=1.7.0 -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=C:\Users\rzaafouri\ncs\v1.7.0\toolchain\segger_embedded_studio/html/configure_nordic_project_menuconfig.py
    -- Application: C:/Users/rzaafouri/ncs/v1.7.0/zephyr/samples/drivers/adc
    -- Zephyr version: 2.6.99 (C:/Users/rzaafouri/ncs/v1.7.0/zephyr), build: v2.6.99-ncs1
    -- Found Python3: C:/Users/rzaafouri/ncs/v1.7.0/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
    -- Board: nrf5340dk_nrf5340_cpuapp_ns
    -- Cache files will be written to: C:/Users/rzaafouri/ncs/v1.7.0/zephyr/.cache
    -- Found dtc: C:/Users/rzaafouri/ncs/v1.7.0/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: gnuarmemb (C:/Users/rzaafouri/ncs/v1.7.0/toolchain/opt)
    -- Found BOARD.dts: C:/Users/rzaafouri/ncs/v1.7.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_ns.dts
    -- Found devicetree overlay: C:/Users/rzaafouri/ncs/v1.7.0/zephyr/samples/drivers/adc/boards/nrf5340dk_nrf5340_cpuapp_ns.overlay
    -- Configuring incomplete, errors occurred!
    Including boilerplate (Zephyr base): C:/Users/rzaafouri/ncs/v1.7.0/zephyr/cmake/app/boilerplate.cmake
    -- Using NCS Toolchain 1.7.0 for building. (C:/Users/rzaafouri/ncs/v1.7.0/toolchain/cmake)
    Error: nrf5340dk_nrf5340_cpuapp_ns.dts.pre.tmp:741.2-742.1 syntax error
    FATAL ERROR: Unable to parse input tree
    CMake Error at C:/Users/rzaafouri/ncs/v1.7.0/zephyr/cmake/dts.cmake:219 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/Users/rzaafouri/ncs/v1.7.0/zephyr/cmake/app/boilerplate.cmake:553 (include)
      C:/Users/rzaafouri/ncs/v1.7.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Users/rzaafouri/ncs/v1.7.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:5 (find_package)
    
    
    
    error: cmake failed
    create_nordic_project.py failed (1)

  • Oh, my mistake, after closer inspection it seems the tutorial you are following does things a little bit differently - could you change your overlay file to contain just the following:

    / {
    
        zephyr,user {
    
            /* adjust channel number according to pinmux in board.dts */
    
            io-channels = <&adc 1>;
    
        };
    
    };

    Let me know if it compiles with this change, or what the error log says if it does not.

    Best regards,
    Karl

Related