Vishay VCNL4010 device tree

Hi,

I'm integrating a VCNL4010 over an I2C connection via an nRF52 DK.

Noting there is a Vishay VCNL4040 sensor driver, has anyone written one for the VCNL4010?  It would be greatly received and save me a stack of time!

many thanks,  Philip

Parents Reply
  • Hi Andreas,

    Thanks for the response and advice to go to the Zephyr forum.  I've been through the fundamentals and intermediate course but practically implementing something through device tree is all new to me so any advice is great.

    I did see the vcnl4040 example and it looks as though reworking this is my direction of travel.  Fitting this in as a hobby means it may be a few weeks of work!

    Regards, Philip

Children
  • Hi,

    Glad to hear that!

    PhilipH said:
    but practically implementing something through device tree is all new to me so any advice is great.

    It will most likely take some time, but I firmly believe you have everything you need in the academy courses and the samples.

    What you will need to do is 

    1. Create your own board overlay, similar to what you find within boards/ in the vcnl4040 sample. Name it nrf52dk_nrf52832.overlay

    2. To use the sensor you need to add the same thing that is present within the stm overlay, but you will have to make some modificatiosn

    3. Compare the stm overlay with https://github.com/NordicDeveloperAcademy/ncs-fund/blob/main/v2.9.0-v2.7.0/l6/l6_e1_sol/boards/nrf52dk_nrf52832.overlay from the fundamentals lesson 6 w.r.t i2c. This is from the solution of the first exercise in that lesson. Here you can also use the pin-ctrl to change what gpio the i2c sensor should be driven from. Make sure to consult the datasheet and/or the backside of the DK to ensure you don't use one that is already physically in use on the DK.

    4. build for the nrf52dk build target, either with command line or VS Code extension. If you've added the sensor correctly to the board file it should build out of the box. I expect something like this should work. I've not tested it, but please feel free to start from step 1 and compare the 2 overlays, the i2c course and finally the suggestion I've posted and see if you can understand what's going on

    &i2c0 {
    	status="okay";
        pinctrl-0 = <&i2c0_default>;
        pinctrl-1 = <&i2c0_sleep>;
        pinctrl-names = "default", "sleep";
        vcnl: vcnl4040@60 {    
    		compatible = "vishay,vcnl4040";
    		reg = <0x60>;
    		#int-gpios = <&feather_header 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
    		led-current = <200>;
    		led-duty-cycle = <320>;
    		proximity-it = "8";
    		proximity-trigger = "close";
    		als-it = <640>;
    	};
    };
    &pinctrl {
    	/omit-if-no-ref/ i2c0_default: i2c0_default {
    		group1  {
    			psels = <NRF_PSEL(TWIM_SCL, 0, 24)>,
    					<NRF_PSEL(TWIM_SDA, 0, 25)>;
    		};
    	};
    
    	/omit-if-no-ref/ i2c0_sleep: i2c0_sleep {
    		group1  {
    			psels = <NRF_PSEL(TWIM_SCL, 0, 24)>,
    					<NRF_PSEL(TWIM_SDA, 0, 25)>;
    			low-power-enable;
    		};
    	};
    };

    Kind regards,
    Andreas

  • Being cheeky, I've realise that the vcnl4010 is basically an obsolete product.  So I've ordered the vcnl4040 module instead and go from there, hopefully fast tracking my application.  The 4040 code sample didn't build on first attempt but fingers crossed I can solve that.

    I certainly know more about creating device trees and bindings now - quite a journey.  Many thanks for your support.

    Ticket being closed off now.

Related