Wish VEML6075 Library wrap

Discussion in 'B4R Bugs & Wishlist' started by Chris Tyrie, Aug 29, 2019.

Similar threads

Games [XUI2D] Example Pack
B4R Tutorial HC 05 Classic Bluetooth
B4R Tutorial Inline C / C++
B4R Library rAdafruitGFX
B4R Library rAdafruitNeoPixel
B4R Library rAdafruitMotorShield (V2)
  1. Chris Tyrie

    Chris Tyrie Member Licensed User

  2. thetahsk

    thetahsk Active Member Licensed User

    Don't give up.
    Here's a small example of an quick and dirty transportation from veml6075_fulltest.ino to B4R.
    Install the Adafruit BUS-IO libs https://www.arduinolibraries.info/libraries/adafruit-bus-io and the VEML6075 libs in your Arduino IDE.

    #Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
    Public Serial1 As Serial
    Private UVA,UVB,UVI As Float
    Private timer1 As Timer
    End Sub

    Private Sub AppStart
    End Sub

    Sub timer1_Tick
    "read_UVA_UVB_UVIndex",1)    ' 0 for simulation / 1 for normal operation
        Log("UVA=",UVA," UVB=",UVB," UVI=",UVI)
    End Sub

    Sub VEML6075_Setup()
    End Sub

    #if C
     // https://github.com/adafruit/Adafruit_VEML6075/tree/master/examples/veml6075_fulltest
    #include <Wire.h>
    #include <Adafruit_VEML6075.h>

    Adafruit_VEML6075 uv = Adafruit_VEML6075();

    void setup(B4R::Object* o) {
      Serial.println("VEML6075 Full Test");
      if (! uv.begin()) {
        Serial.println("Failed to communicate with VEML6075 sensor, check wiring?");
      Serial.println("Found VEML6075 sensor");
       // Set the integration constant
      // Get the integration constant and print it!
      Serial.print("Integration time set to ");
      switch (uv.getIntegrationTime()) {
        case VEML6075_50MS: Serial.print("50"); break;
        case VEML6075_100MS: Serial.print("100"); break;
        case VEML6075_200MS: Serial.print("200"); break;
        case VEML6075_400MS: Serial.print("400"); break;
        case VEML6075_800MS: Serial.print("800"); break;

      // Set the high dynamic mode
      // Get the mode
      if (uv.getHighDynamic()) {
        Serial.println("High dynamic reading mode");
      } else {
        Serial.println("Normal dynamic reading mode");

      // Set the mode
      // Get the mode
      if (uv.getForcedMode()) {
        Serial.println("Forced reading mode");
      } else {
        Serial.println("Continuous reading mode");

      // Set the calibration coefficients
      uv.setCoefficients(2.22, 1.33,  // UVA_A and UVA_B coefficients
                         2.95, 1.74,  // UVB_C and UVB_D coefficients
                         0.001461, 0.002591); // UVA and UVB responses
     void read_UVA_UVB_UVIndex(B4R::Object* o) {
      if (o->toULong()<1) {
      Serial.println("Simulation ");
      Serial.print("Raw UVA reading:  "); Serial.println(uv.readUVA());
      Serial.print("Raw UVB reading:  "); Serial.println(uv.readUVB());
      Serial.print("UV Index reading: "); Serial.println(uv.readUVI());
    #end if
    Last edited: Aug 31, 2019
    Erel, Chris Tyrie and inakigarm like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice