Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. VEML6075 reading value with STM32 HAL library

VEML6075 reading value with STM32 HAL library

Scheduled Pinned Locked Moved My Project
1 Posts 1 Posters 204 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ninjagregN Offline
    ninjagregN Offline
    ninjagreg
    wrote on last edited by
    #1

    Dear all,

    I am using VEML6075 with a NUCLEO board F030R8 using HAL Library to drive the sensor and i am facing a misterious issue:
    I am looping ID, UVB, UVA, UVD, UCOMP1, UCOMP2 data reading ( with a previous initialing configuration register of 01000000 (0x40) ) with a 5 sec pause between each reading sequence.
    The thing is that i read for each register the exact same value (!?) ID = UVB = UVA = UVD = UCOMP1 = UCOMP2.

    I have followed the reading sequence as :
    I2C write: slave address (read/write bit to 0) followed by the command code corresponding to the register code.
    I2C read: slave address (read/write bit to 1) followed by a reading of the 2 bytes of the sensor.

    Here is the oscilloscope screenshots...

    ID register reading (0x0C) whose the value read is 93
    test_6_10s_1milionpoints_10µsparpoint_PS1 --00000.csv--00000.jpg

    UVB register reading (0x09) whose the value read is 93
    test_6_10s_1milionpoints_10µsparpoint_PS1 --00000.csv--00001.jpg

    UVA register reading (0x7) whose the value read is 93
    test_6_10s_1milionpoints_10µsparpoint_PS1 --00000.csv--00002.jpg

    ...and i don't think that the rest is nessary to show..
    So, i guess there is something i do wrongly. Could you help please?
    You ll find below the piece of code i used:

    /* USER CODE BEGIN PFP */
     static const uint8_t VEML6075_ADDR = 0x10 << 1; // Use 8-bit address
     static const uint8_t REG_ID = 0x0C ;
     static const uint8_t REG_UVB = 0x09 ;
     static const uint8_t REG_UVA = 0x07 ;
     static const uint8_t REG_DARK_CURRENT = 0x08 ;
     static const uint8_t REG_VISIBLE_LIGHT = 0x0A ;
     static const uint8_t REG_IR_LIGHT = 0x0B ;
     static const uint8_t REG_UV_CONF = 0x00 ;
     static const uint8_t UV_CONF_DATA_BYTE_HIGH= 0x00 ;
     static const uint8_t UV_CONF_DATA_BYTE_LOW = 0x40 ; 
    
      buf[0] = REG_UV_CONF ; // register adresse for module configuration
       buf[1] = UV_CONF_DATA_BYTE_LOW ; // Data byte low for module configuration
       buf[2] = UV_CONF_DATA_BYTE_HIGH ; // Data byte high for module configuration
       ret = HAL_I2C_Master_Transmit(&hi2c1, VEML6075_ADDR , buf, 3, HAL_MAX_DELAY);  
       if ( ret != HAL_OK ) {
          strcpy((char*)buf, "Error Tx\r\n");
       }
    
    while (1)
      {   
        // Reading of the ID register of the VEML6075 sensor  
        buf[0] = REG_ID ;  
        // Send the Sensor I2C Address follow by the ID command register 
        ret = HAL_I2C_Master_Transmit(&hi2c1, VEML6075_ADDR , buf, 1, HAL_MAX_DELAY);  
        if ( ret != HAL_OK ) {
          strcpy((char*)buf, "Error Tx\r\n");
        } else {  
          // Read 2 bytes from the VEML6075 ID register
          ret = HAL_I2C_Master_Receive(&hi2c1, VEML6075_ADDR, buf, 2, HAL_MAX_DELAY);
          if ( ret != HAL_OK ) {
            strcpy((char*)buf, "Error Rx\r\n");
          } else {
       //Combine the bytes of the ID register to print by UART com
          val = ((int16_t)buf[1] << 8) | (buf[0] );  
          sprintf((char*)buf,
                  "%u ID et ",
                  ((unsigned int)val));     
          }  
       }      
       HAL_UART_Transmit(&huart2, buf, strlen((char*)buf), HAL_MAX_DELAY); 
    
      // Reading of the UVB register of the VEML6075 sensor  
       buf[0] = REG_UVB ;  
       ret = HAL_I2C_Master_Transmit(&hi2c1, VEML6075_ADDR , buf, 1, HAL_MAX_DELAY);  
       if ( ret != HAL_OK ) {
          strcpy((char*)buf, "Error Tx\r\n");
       } else {  
       // Read 2 bytes from the VEML6075 UVB register
          ret = HAL_I2C_Master_Receive(&hi2c1, VEML6075_ADDR, buf, 2, HAL_MAX_DELAY);
          if ( ret != HAL_OK ) {
            strcpy((char*)buf, "Error Rx\r\n");
          } else {
       //Combine the bytes
          val = ((int16_t)buf[1] << 8) | (buf[0] );  
          sprintf((char*)buf,
                  "%u UVB et ",
                  ((unsigned int)val));     
          }  
       }      
       HAL_UART_Transmit(&huart2, buf, strlen((char*)buf), HAL_MAX_DELAY);  
    
       HAL_Delay(2000) ;
    }
    
    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    19

    Online

    12.0k

    Users

    11.2k

    Topics

    113.4k

    Posts


    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • MySensors
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular