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
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
Hello Philip,
I see that you've left the case open for the forum to chime in (which is great) since we don't write drivers for third party devices. All the third party drivers that are present within nRF Connect SDK (NCS) comes through Zephyr, which NCS is based upon.
But that said, there are a driver present within the SDK. You can find it here: https://github.com/nrfconnect/sdk-zephyr/tree/main/drivers/sensor/vishay
There's a couple of samples found within <SDK>\zephyr\samples\sensor\vcnl4040 which works for the adafruit stm feather, meaning that you will have to add the board support for the nRF52DK yourself.
https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/ and https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/ (maybe with focus on Lesson 7 Device driver model) should be very helpful with this.
In addition, since you're reaching out to the forums, I would also recommend that you have a look at the Zephyr discord forums (https://discord.com/invite/Ck7jw53nU2) found at https://zephyrproject.org/learn-about/
There might be other developers who's done the same thing that you're trying to do there.
Let me know if this answers your question and I would recommend you to go through the academy courses if you're relatively new to Nordic and NCS
Kind regards,
Andreas
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
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
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.