├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── githubci.yml ├── .gitignore ├── Adafruit_VEML6075.cpp ├── Adafruit_VEML6075.h ├── README.md ├── examples ├── veml6075_fulltest │ └── veml6075_fulltest.ino └── veml6075_simpletest │ └── veml6075_simpletest.ino └── library.properties /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v3 14 | - uses: actions/checkout@v3 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: test platforms 23 | run: python3 ci/build_platform.py main_platforms 24 | 25 | - name: clang 26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 27 | 28 | - name: doxygen 29 | env: 30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 31 | PRETTYNAME : "Adafruit VEML6075 UV Sensor Library" 32 | run: bash ci/doxy_gen_and_deploy.sh 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Our handy .gitignore for automation ease 2 | Doxyfile* 3 | doxygen_sqlite3.db 4 | html 5 | -------------------------------------------------------------------------------- /Adafruit_VEML6075.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_VEML6075.cpp 3 | * 4 | * @mainpage Adafruit VEML6075 UV sensor 5 | * 6 | * @section intro_sec Introduction 7 | * 8 | * Designed specifically to work with the VEML6075 sensor from Adafruit 9 | * ----> https://www.adafruit.com/products/3964 10 | * 11 | * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required 12 | * to interface with the breakout. 13 | * 14 | * Adafruit invests time and resources providing this open source code, 15 | * please support Adafruit and open-source hardware by purchasing 16 | * products from Adafruit! 17 | * 18 | * @section dependencies Dependencies 19 | * 20 | * 21 | * @section author Author 22 | * 23 | * Written by Limor Fried/Ladyada for Adafruit Industries. 24 | * 25 | * @section license License 26 | * 27 | * MIT license, all text here must be included in any redistribution. 28 | * 29 | */ 30 | 31 | #if (ARDUINO >= 100) 32 | #include "Arduino.h" 33 | #else 34 | #include "WProgram.h" 35 | #endif 36 | #include "Wire.h" 37 | 38 | #include "Adafruit_VEML6075.h" 39 | 40 | /**************************************************************************/ 41 | /*! 42 | @brief constructor initializes default configuration value 43 | */ 44 | /**************************************************************************/ 45 | Adafruit_VEML6075::Adafruit_VEML6075() { 46 | setCoefficients(VEML6075_DEFAULT_UVA_A_COEFF, VEML6075_DEFAULT_UVA_B_COEFF, 47 | VEML6075_DEFAULT_UVB_C_COEFF, VEML6075_DEFAULT_UVB_D_COEFF, 48 | VEML6075_DEFAULT_UVA_RESPONSE, VEML6075_DEFAULT_UVB_RESPONSE); 49 | 50 | _commandRegister.reg = 0; 51 | } 52 | 53 | /**************************************************************************/ 54 | /*! 55 | @brief setup and initialize communication with the hardware 56 | @param itime The integration time to use for the data. Defaults to 100ms 57 | @param forcedReads True for triggered read, false for continuous (default) 58 | @param highDynamic Whether to read in normal or high dynamic mode - defaults 59 | to normal 60 | @param theWire Optional pointer to the desired TwoWire I2C object. Defaults 61 | to &Wire 62 | @returns True if sensor found, false if sensor not detected 63 | */ 64 | /**************************************************************************/ 65 | boolean Adafruit_VEML6075::begin(veml6075_integrationtime_t itime, 66 | bool highDynamic, bool forcedReads, 67 | TwoWire *theWire) { 68 | i2c_dev = new Adafruit_I2CDevice(VEML6075_ADDR, theWire); 69 | 70 | if (!i2c_dev->begin()) { 71 | return false; 72 | } 73 | 74 | Adafruit_I2CRegister ID_Register = 75 | Adafruit_I2CRegister(i2c_dev, VEML6075_REG_ID, 2); 76 | uint16_t id; 77 | 78 | if (!ID_Register.read(&id)) { 79 | return false; 80 | } 81 | if (id != 0x26) { 82 | return false; 83 | } 84 | 85 | Config_Register = new Adafruit_I2CRegister(i2c_dev, VEML6075_REG_CONF, 2); 86 | // Start from scratch 87 | _commandRegister.reg = 0; 88 | 89 | shutdown(true); // Shut down to change settings 90 | 91 | // Force readings 92 | setForcedMode(forcedReads); 93 | 94 | // Set integration time 95 | setIntegrationTime(itime); 96 | 97 | // Set high dynamic 98 | setHighDynamic(highDynamic); 99 | 100 | shutdown(false); // Re-enable 101 | 102 | return true; 103 | } 104 | 105 | /**************************************************************************/ 106 | /*! 107 | @brief Set the UVI calculation coefficients, see datasheet for some example 108 | values. We use the default "no cover glass" values if none are specified when 109 | initializing the sensor. 110 | @param UVA_A the UVA visible coefficient 111 | @param UVA_B the UVA IR coefficient 112 | @param UVB_C the UVB visible coefficient 113 | @param UVB_D the UVB IR coefficient 114 | @param UVA_response the UVA responsivity 115 | @param UVB_response the UVB responsivity 116 | */ 117 | /**************************************************************************/ 118 | void Adafruit_VEML6075::setCoefficients(float UVA_A, float UVA_B, float UVB_C, 119 | float UVB_D, float UVA_response, 120 | float UVB_response) { 121 | _uva_a = UVA_A; 122 | _uva_b = UVA_B; 123 | _uvb_c = UVB_C; 124 | _uvb_d = UVB_D; 125 | _uva_resp = UVA_response; 126 | _uvb_resp = UVB_response; 127 | } 128 | 129 | /**************************************************************************/ 130 | /*! 131 | @brief Shut down the sensor 132 | @param sd True if you want to shut down, false to enable 133 | */ 134 | /**************************************************************************/ 135 | void Adafruit_VEML6075::shutdown(bool sd) { 136 | _commandRegister.bit.SD = sd; 137 | Config_Register->write(_commandRegister.reg); 138 | } 139 | 140 | /**************************************************************************/ 141 | /*! 142 | @brief Set the time over which we sample UV data per read 143 | @param itime How many milliseconds to integrate over 144 | */ 145 | /**************************************************************************/ 146 | void Adafruit_VEML6075::setIntegrationTime(veml6075_integrationtime_t itime) { 147 | // Set integration time 148 | _commandRegister.bit.UV_IT = (uint8_t)itime; 149 | Config_Register->write(_commandRegister.reg); 150 | 151 | _read_delay = 0; 152 | switch (itime) { 153 | case VEML6075_50MS: 154 | _read_delay = 50; 155 | break; 156 | case VEML6075_100MS: 157 | _read_delay = 100; 158 | break; 159 | case VEML6075_200MS: 160 | _read_delay = 200; 161 | break; 162 | case VEML6075_400MS: 163 | _read_delay = 400; 164 | break; 165 | case VEML6075_800MS: 166 | _read_delay = 800; 167 | break; 168 | } 169 | } 170 | 171 | /**************************************************************************/ 172 | /*! 173 | @brief Get the time over which we sample UV data per read from the sensor 174 | @returns How many milliseconds to integrate over 175 | */ 176 | /**************************************************************************/ 177 | veml6075_integrationtime_t Adafruit_VEML6075::getIntegrationTime(void) { 178 | // Get register 179 | Config_Register->read(&_commandRegister.reg); 180 | 181 | // extract and return just the integration time 182 | return (veml6075_integrationtime_t)_commandRegister.bit.UV_IT; 183 | } 184 | 185 | /**************************************************************************/ 186 | /*! 187 | @brief Sets whether to take readings in 'high dynamic' mode 188 | @param hd True if you want high dynamic readings, False for normal dynamic 189 | */ 190 | /**************************************************************************/ 191 | void Adafruit_VEML6075::setHighDynamic(bool hd) { 192 | // Set HD mode 193 | _commandRegister.bit.UV_HD = hd; 194 | Config_Register->write(_commandRegister.reg); 195 | } 196 | 197 | /**************************************************************************/ 198 | /*! 199 | @brief Gets whether to take readings in 'high dynamic' mode 200 | @returns True if set to high dynamic readings, False for normal dynamic 201 | */ 202 | /**************************************************************************/ 203 | bool Adafruit_VEML6075::getHighDynamic(void) { 204 | // Get register 205 | Config_Register->read(&_commandRegister.reg); 206 | 207 | // extract and return just the HD setting 208 | return _commandRegister.bit.UV_HD; 209 | } 210 | 211 | /**************************************************************************/ 212 | /*! 213 | @brief Sets whether to take readings on request 214 | @param flag True if you want readings on request, False for continuous reads 215 | */ 216 | /**************************************************************************/ 217 | void Adafruit_VEML6075::setForcedMode(bool flag) { 218 | // Set forced mode 219 | _commandRegister.bit.UV_AF = flag; 220 | Config_Register->write(_commandRegister.reg); 221 | } 222 | 223 | /**************************************************************************/ 224 | /*! 225 | @brief Gets whether to take readings on request 226 | @returns True if readings on request, False for continuous reads 227 | */ 228 | /**************************************************************************/ 229 | bool Adafruit_VEML6075::getForcedMode(void) { 230 | // Get register 231 | Config_Register->read(&_commandRegister.reg); 232 | 233 | // extract and return just the AF setting 234 | return _commandRegister.bit.UV_AF; 235 | } 236 | 237 | /**************************************************************************/ 238 | /*! 239 | @brief Perform a full reading and calculation of all UV calibrated values 240 | */ 241 | /**************************************************************************/ 242 | void Adafruit_VEML6075::takeReading(void) { 243 | 244 | if (getForcedMode()) { 245 | // trigger one reading 246 | _commandRegister.bit.UV_TRIG = 1; 247 | Config_Register->write(_commandRegister.reg); 248 | 249 | // Wait until we're done, add 10% just to be sure 250 | delay(_read_delay * 1.1); 251 | // Serial.print("Delay (ms): "); Serial.println(_read_delay); 252 | } 253 | // otherwise, just take the reading immediately 254 | 255 | Adafruit_I2CRegister UVA_Register = 256 | Adafruit_I2CRegister(i2c_dev, VEML6075_REG_UVA, 2); 257 | Adafruit_I2CRegister UVB_Register = 258 | Adafruit_I2CRegister(i2c_dev, VEML6075_REG_UVB, 2); 259 | Adafruit_I2CRegister UVCOMP1_Register = 260 | Adafruit_I2CRegister(i2c_dev, VEML6075_REG_UVCOMP1, 2); 261 | Adafruit_I2CRegister UVCOMP2_Register = 262 | Adafruit_I2CRegister(i2c_dev, VEML6075_REG_UVCOMP2, 2); 263 | float uva = UVA_Register.read(); 264 | float uvb = UVB_Register.read(); 265 | float uvcomp1 = UVCOMP1_Register.read(); 266 | float uvcomp2 = UVCOMP2_Register.read(); 267 | 268 | if (uva == 0xFFFFFFFF || uvb == 0xFFFFFFFF || uvcomp1 == 0xFFFFFFFF || 269 | uvcomp2 == 0xFFFFFFFF) { 270 | uva = NAN; 271 | uvb = NAN; 272 | uvcomp1 = NAN; 273 | uvcomp2 = NAN; 274 | } 275 | 276 | /* 277 | Serial.print("UVA: "); Serial.print(uva); 278 | Serial.print(" UVB: "); Serial.println(uvb); 279 | Serial.print("UVcomp1: "); Serial.print(uvcomp1); 280 | Serial.print(" UVcomp2: "); Serial.println(uvcomp2); 281 | */ 282 | // Equasion 1 & 2 in App note, without 'golden sample' calibration 283 | _uva_calc = uva - (_uva_a * uvcomp1) - (_uva_b * uvcomp2); 284 | _uvb_calc = uvb - (_uvb_c * uvcomp1) - (_uvb_d * uvcomp2); 285 | } 286 | 287 | /**************************************************************************/ 288 | /*! 289 | @brief read the calibrated UVA band reading 290 | @return the UVA reading in unitless counts or NAN if reading failed 291 | */ 292 | /*************************************************************************/ 293 | float Adafruit_VEML6075::readUVA(void) { 294 | takeReading(); 295 | return _uva_calc; 296 | } 297 | 298 | /**************************************************************************/ 299 | /*! 300 | @brief read the calibrated UVB band reading 301 | @return the UVB reading in unitless counts or NAN if reading failed 302 | */ 303 | /*************************************************************************/ 304 | float Adafruit_VEML6075::readUVB(void) { 305 | takeReading(); 306 | return _uvb_calc; 307 | } 308 | 309 | /**************************************************************************/ 310 | /*! 311 | @brief Read and calculate the approximate UV Index reading 312 | @return the UV Index as a floating point or NAN if reading failed 313 | */ 314 | /**************************************************************************/ 315 | float Adafruit_VEML6075::readUVI() { 316 | takeReading(); 317 | return ((_uva_calc * _uva_resp) + (_uvb_calc * _uvb_resp)) / 2; 318 | } 319 | 320 | /**************************************************************************/ 321 | /*! 322 | @brief read the calibrated UVA & UVB band reading and calculate the 323 | approximate UV Index reading 324 | @param a pointer to store UVA reading or NAN if reading failed 325 | @param b pointer to store UVB reading or NAN if reading failed 326 | @param i pointer to store UVI reading or NAN if reading failed 327 | */ 328 | /**************************************************************************/ 329 | void Adafruit_VEML6075::readUVABI(float *a, float *b, float *i) { 330 | takeReading(); 331 | *a = _uva_calc; 332 | *b = _uvb_calc; 333 | *i = ((_uva_calc * _uva_resp) + (_uvb_calc * _uvb_resp)) / 2; 334 | } 335 | -------------------------------------------------------------------------------- /Adafruit_VEML6075.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_VEML6075.h 3 | * 4 | * Designed specifically to work with the VEML6075 sensor from Adafruit 5 | * ----> https://www.adafruit.com/products/3964 6 | * 7 | * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required 8 | * to interface with the breakout. 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing 12 | * products from Adafruit! 13 | * 14 | * Written by Limor Fried/Ladyada for Adafruit Industries. 15 | * 16 | * MIT license, all text here must be included in any redistribution. 17 | * 18 | */ 19 | 20 | #include "Arduino.h" 21 | #include 22 | #include 23 | #include 24 | 25 | #define VEML6075_ADDR (0x10) ///< I2C address (cannot be changed) 26 | #define VEML6075_REG_CONF (0x00) ///< Configuration register 27 | #define VEML6075_REG_UVA (0x07) ///< UVA band raw measurement 28 | #define VEML6075_REG_DARK (0x08) ///< Dark current (?) measurement 29 | #define VEML6075_REG_UVB (0x09) ///< UVB band raw measurement 30 | #define VEML6075_REG_UVCOMP1 (0x0A) ///< UV1 compensation value 31 | #define VEML6075_REG_UVCOMP2 (0x0B) ///< UV2 compensation value 32 | #define VEML6075_REG_ID (0x0C) ///< Manufacture ID 33 | 34 | #define VEML6075_DEFAULT_UVA_A_COEFF 2.22 ///< Default for no coverglass 35 | #define VEML6075_DEFAULT_UVA_B_COEFF 1.33 ///< Default for no coverglass 36 | #define VEML6075_DEFAULT_UVB_C_COEFF 2.95 ///< Default for no coverglass 37 | #define VEML6075_DEFAULT_UVB_D_COEFF 1.74 ///< Default for no coverglass 38 | #define VEML6075_DEFAULT_UVA_RESPONSE 0.001461 ///< Default for no coverglass 39 | #define VEML6075_DEFAULT_UVB_RESPONSE 0.002591 ///< Default for no coverglass 40 | 41 | /**************************************************************************/ 42 | /*! 43 | @brief integration time definitions 44 | */ 45 | /**************************************************************************/ 46 | typedef enum veml6075_integrationtime { 47 | VEML6075_50MS, 48 | VEML6075_100MS, 49 | VEML6075_200MS, 50 | VEML6075_400MS, 51 | VEML6075_800MS, 52 | } veml6075_integrationtime_t; 53 | 54 | /**************************************************************************/ 55 | /*! 56 | @brief CMSIS style register bitfield for commands 57 | */ 58 | /**************************************************************************/ 59 | typedef union { 60 | struct { 61 | uint8_t SD : 1; ///< Shut Down 62 | uint8_t UV_AF : 1; ///< Auto or forced 63 | uint8_t UV_TRIG : 1; ///< Trigger forced mode 64 | uint8_t UV_HD : 1; ///< High dynamic 65 | uint8_t UV_IT : 3; ///< Integration Time 66 | uint8_t high_byte; ///< unused 67 | } bit; ///< Bitfield of 16 bits 68 | uint16_t reg; ///< The raw 16 bit register data 69 | } veml6075_commandRegister; 70 | 71 | /**************************************************************************/ 72 | /*! 73 | @brief Class that stores state and functions for interacting with VEML6075 74 | sensor IC 75 | */ 76 | /**************************************************************************/ 77 | class Adafruit_VEML6075 { 78 | public: 79 | Adafruit_VEML6075(); 80 | 81 | boolean begin(veml6075_integrationtime_t itime = VEML6075_100MS, 82 | bool highDynamic = false, bool forcedReads = false, 83 | TwoWire *theWire = &Wire); 84 | 85 | void shutdown(bool sd); 86 | 87 | void setIntegrationTime(veml6075_integrationtime_t itime); 88 | veml6075_integrationtime_t getIntegrationTime(void); 89 | void setHighDynamic(bool hd); 90 | bool getHighDynamic(void); 91 | void setForcedMode(bool flag); 92 | bool getForcedMode(void); 93 | 94 | void setCoefficients(float UVA_A, float UVA_B, float UVA_C, float UVA_D, 95 | float UVA_response, float UVB_response); 96 | 97 | float readUVA(void); 98 | float readUVB(void); 99 | float readUVI(void); 100 | void readUVABI(float *a, float *b, float *i); 101 | 102 | Adafruit_I2CRegister *Config_Register; ///< Chip config register 103 | 104 | private: 105 | void takeReading(void); 106 | 107 | uint16_t _read_delay; 108 | 109 | // coefficients 110 | float _uva_a, _uva_b, _uvb_c, _uvb_d, _uva_resp, _uvb_resp; 111 | float _uva_calc, _uvb_calc; 112 | 113 | veml6075_commandRegister _commandRegister; 114 | 115 | Adafruit_I2CDevice *i2c_dev; 116 | }; 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adafruit_VEML6075 [![Build Status](https://github.com/adafruit/Adafruit_VEML6075/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_VEML6075/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_VEML6075/html/index.html) 2 | 3 | 4 | This is a library for the Adafruit VEML6075 UV sensor breakout: 5 | * https://www.adafruit.com/products/3964 6 | 7 | Check out the links above for our tutorials and wiring diagrams. This chip uses I2C to communicate 8 | 9 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 10 | 11 | Written by Limor Fried/Ladyada for Adafruit Industries. 12 | MIT license, all text above must be included in any redistribution 13 | -------------------------------------------------------------------------------- /examples/veml6075_fulltest/veml6075_fulltest.ino: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file veml6075_fulltest.ino 3 | * 4 | * A complete test of the library API with various settings available 5 | * 6 | * Designed specifically to work with the VEML6075 sensor from Adafruit 7 | * ----> https://www.adafruit.com/products/3964 8 | * 9 | * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required 10 | * to interface with the breakout. 11 | * 12 | * Adafruit invests time and resources providing this open source code, 13 | * please support Adafruit and open-source hardware by purchasing 14 | * products from Adafruit! 15 | * 16 | * Written by Limor Fried/Ladyada for Adafruit Industries. 17 | * 18 | * MIT license, all text here must be included in any redistribution. 19 | * 20 | */ 21 | 22 | #include 23 | #include "Adafruit_VEML6075.h" 24 | 25 | Adafruit_VEML6075 uv = Adafruit_VEML6075(); 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | Serial.println("VEML6075 Full Test"); 30 | if (! uv.begin()) { 31 | Serial.println("Failed to communicate with VEML6075 sensor, check wiring?"); 32 | } 33 | Serial.println("Found VEML6075 sensor"); 34 | 35 | // Set the integration constant 36 | uv.setIntegrationTime(VEML6075_100MS); 37 | // Get the integration constant and print it! 38 | Serial.print("Integration time set to "); 39 | switch (uv.getIntegrationTime()) { 40 | case VEML6075_50MS: Serial.print("50"); break; 41 | case VEML6075_100MS: Serial.print("100"); break; 42 | case VEML6075_200MS: Serial.print("200"); break; 43 | case VEML6075_400MS: Serial.print("400"); break; 44 | case VEML6075_800MS: Serial.print("800"); break; 45 | } 46 | Serial.println("ms"); 47 | 48 | // Set the high dynamic mode 49 | uv.setHighDynamic(true); 50 | // Get the mode 51 | if (uv.getHighDynamic()) { 52 | Serial.println("High dynamic reading mode"); 53 | } else { 54 | Serial.println("Normal dynamic reading mode"); 55 | } 56 | 57 | // Set the mode 58 | uv.setForcedMode(false); 59 | // Get the mode 60 | if (uv.getForcedMode()) { 61 | Serial.println("Forced reading mode"); 62 | } else { 63 | Serial.println("Continuous reading mode"); 64 | } 65 | 66 | // Set the calibration coefficients 67 | uv.setCoefficients(2.22, 1.33, // UVA_A and UVA_B coefficients 68 | 2.95, 1.74, // UVB_C and UVB_D coefficients 69 | 0.001461, 0.002591); // UVA and UVB responses 70 | } 71 | 72 | 73 | void loop() { 74 | Serial.print("Raw UVA reading: "); Serial.println(uv.readUVA()); 75 | Serial.print("Raw UVB reading: "); Serial.println(uv.readUVB()); 76 | Serial.print("UV Index reading: "); Serial.println(uv.readUVI()); 77 | 78 | delay(1000); 79 | } 80 | -------------------------------------------------------------------------------- /examples/veml6075_simpletest/veml6075_simpletest.ino: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file veml6075_simple.ino 3 | * 4 | * A basic test of the sensor with default settings 5 | * 6 | * Designed specifically to work with the VEML6075 sensor from Adafruit 7 | * ----> https://www.adafruit.com/products/3964 8 | * 9 | * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required 10 | * to interface with the breakout. 11 | * 12 | * Adafruit invests time and resources providing this open source code, 13 | * please support Adafruit and open-source hardware by purchasing 14 | * products from Adafruit! 15 | * 16 | * Written by Limor Fried/Ladyada for Adafruit Industries. 17 | * 18 | * MIT license, all text here must be included in any redistribution. 19 | * 20 | */ 21 | 22 | #include 23 | #include "Adafruit_VEML6075.h" 24 | 25 | Adafruit_VEML6075 uv = Adafruit_VEML6075(); 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | while (!Serial) { delay(10); } 30 | Serial.println("VEML6075 Simple Test"); 31 | 32 | if (! uv.begin()) { 33 | Serial.println("Failed to communicate with VEML6075 sensor, check wiring?"); 34 | while (1) { delay(100); } 35 | } 36 | Serial.println("Found VEML6075 sensor"); 37 | } 38 | 39 | 40 | void loop() { 41 | Serial.print("UV Index reading: "); Serial.println(uv.readUVI()); 42 | delay(1000); 43 | } 44 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit VEML6075 Library 2 | version=2.2.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for VEML6075 6 | paragraph=Arduino library for VEML6075 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_VEML6075 9 | architectures=* 10 | depends=Adafruit BusIO 11 | --------------------------------------------------------------------------------