This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Color sensor pca20035

Dear, 

I am using thingy:91 pca20035 and try to test the color sensor BH1749NUC

I tried to run the /samples/sensor/bh1749

I got the output: 

SPM: NS image at 0xc000
SPM: NS MSP at 0x20020a78
SPM: NS reset vector at 0xde51
SPM: prepare to jump to Non-Secure image.
***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1270-gb1d603491de8 *****
device is 0x20021d9c, name is BH1749
[00:00:00.004,913] [1B][0m<inf> BH1749: BH1749 initialized[1B][0m

I expected it will return the color in process(dev); but I got nothing. 

Do I need to do some "trigger" to enable sensor? 

Thanks, 

BR, 

Hoang Nguyen

Parents
  • The reason you're not getting any input is because it's stuck at process(..)→while(1)k_sem_take(..). In order for the program to continue from there, k_sem_give(..) has to be called (this is because the count it zero, and the give function will increase it, read more about semaphores here). In trigger_handler(..) this function is called, and it will allow the program to continue.

    When I ran the program, the trigger function was never called, I am not sure why, since sensor_trigger_set() executed without any errors. It might be something wrong with the configuration of the bh1479 sensor, and it will never trigger GPIO PIN 27.

    However, I was able to make the sensor work by disabling triggering, which can be done by setting CONFIG_BH1749_TRIGGER=n in prj.conf. Then you have to call sensor_sample_fetch_chan(..) followed by sensor_channel_get(..) at regular intervals.

    If you would like to use the sensor in interrupt mode, I can look into it.

    Best regards,

    Simon

  • Hi @

    I tried to disable trigger: CONFIG_BH1749_TRIGGER=n in prj.conf. then 

    call sensor_sample_fetch_chan(..) followed by sensor_channel_get(..) at regular intervals.

    But it doesnt work with me. Could you plz share the code, which you have fixed it. Thanks, 

    BR,

    Hoang

Reply Children
No Data
Related