Skip to content

libdriver/veml7700

English | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어

LibDriver VEML7700

MISRA API License

VEML7700 is a high accuracy ambient light digital 16-bit resolution sensor in a miniature transparent 6.8 mm x 2.35 mm x 3.0 mm package. It includes a high sensitive photo diode, a low noise amplifier, a 16-bit A/D converter and supports an easy to use I2C bus communication interface.

LibDriver VEML7700 is a full-featured driver for VEML7700, launched by LibDriver.It provides data reading, interrupt threshold, auto range and additional features. LibDriver is MISRA compliant.

Table of Contents

Instruction

/src includes LibDriver VEML7700 source files.

/interface includes LibDriver VEML7700 IIC platform independent template.

/test includes LibDriver VEML7700 driver test code and this code can test the chip necessary function simply.

/example includes LibDriver VEML7700 sample code.

/doc includes LibDriver VEML7700 offline document.

/datasheet includes VEML7700 datasheet.

/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.

/misra includes the LibDriver MISRA code scanning results.

Install

Reference /interface IIC platform independent template and finish your platform IIC driver.

Add the /src directory, the interface driver for your platform, and your own drivers to your project, if you want to use the default example drivers, add the /example directory to your project.

Usage

You can refer to the examples in the /example directory to complete your own driver. If you want to use the default programming examples, here's how to use them.

example basic

#include "driver_veml7700_basic.h"

uint8_t res;
uint32_t i;
veml7700_bool_t auto_range = VEML7700_BOOL_ENABLE;

/* basic init */
res = veml7700_basic_init(auto_range);
if (res != 0)
{
    return 1;
}

/* delay 1000ms */
veml7700_interface_delay_ms(1000);

...
    
/* loop */
for (i = 0; i < 3; i++)
{
    uint16_t raw;
    double lux;

    /* basic read */
    res = veml7700_basic_read(&lux);
    if (res != 0)
    {
        (void)veml7700_basic_deinit();

        return 1;
    }

    /* basic read white */
    res = veml7700_basic_read_white(&raw);
    if (res != 0)
    {
        (void)veml7700_basic_deinit();

        return 1;
    }

    /* output */
    veml7700_interface_debug_print("%d/%d.\n", i + 1, 3);
    veml7700_interface_debug_print("%.2f lux.\n", lux);
    veml7700_interface_debug_print("%d white raw.\n", raw);

    /* delay 1000ms */
    veml7700_interface_delay_ms(1000);
    
    ...
}

...
    
/* deinit */
veml7700_basic_deinit();

return 0;

example interrupt

#include "driver_veml7700_interrupt.h"

uint8_t res;
uint32_t i;
uint16_t low_threshold = 1000;
uint16_t high_threshold = 3000;

/* interrupt init */
res = veml7700_interrupt_init(low_threshold, high_threshold);
if (res != 0)
{
    return 1;
}

/* 1000ms */
veml7700_interface_delay_ms(1000);

....
    
/* loop */
for (i = 0; i < 3; i++)
{
    uint16_t raw;
    veml7700_bool_t low_bool;
    veml7700_bool_t high_bool;
    double lux;

    /* get interrupt status */
    res = veml7700_interrupt_get_interrupt_status(&low_bool, &high_bool);
    if (res != 0)
    {
        veml7700_interface_debug_print("veml7700: get interrupt status failed.\n");
        (void)veml7700_interrupt_deinit();

        return 1;
    }
    if (low_bool == VEML7700_BOOL_ENABLE)
    {
        veml7700_interface_debug_print("veml7700: find low threshold interrupt.\n");
    }
    if (high_bool == VEML7700_BOOL_ENABLE)
    {
        veml7700_interface_debug_print("veml7700: find high threshold interrupt.\n");
    }

    /* interrupt read */
    res = veml7700_interrupt_read(&lux);
    if (res != 0)
    {
        (void)veml7700_interrupt_deinit();

        return 1;
    }

    /* interrupt read white */
    res = veml7700_interrupt_read_white(&raw);
    if (res != 0)
    {
        (void)veml7700_interrupt_deinit();

        return 1;
    }

    /* output */
    veml7700_interface_debug_print("%d/%d.\n", i + 1, 3);
    veml7700_interface_debug_print("%.2f lux.\n", lux);
    veml7700_interface_debug_print("%d white raw.\n", raw);

    /* delay 1000ms */
    veml7700_interface_delay_ms(1000);
    
    ...
}

...
    
/* deinit */
veml7700_interrupt_deinit();

return 0;

Document

Online documents: https://www.libdriver.com/docs/veml7700/index.html.

Offline documents: /doc/html/index.html.

Contributing

Please refer to CONTRIBUTING.md.

License

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

Contact Us

Please send an e-mail to lishifenging@outlook.com.

About

VEML7700 full-featured driver library for general-purpose MCU and Linux.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages