[SOLVED] Blue pill (stm32f1) + VEML6075 UV sensor



  • Hi

    Has anyone forced this pair to work?
    My VEML6075 board works well with Arduino but not with Blue pill.
    I tried both TwoWire and SoftWire, changing i2c freq, lowering pull up value (board has 10k resistors) etc
    Other sensors (like bosch weather sensors) works well.


  • Mod

    @fedor Which arduino library do you use to communicate to the VEML6075?
    Maybe the library just isn't compatible with STM32. You could try with some alternative libraries.



  • @Yveaux
    I tried adafruit, sparkfun, schizobovine, Kris Winer libraries
    Then I tried to work without library - the sensor is very simple, just several i2c commands

    uint8_t msb = 0;
    uint8_t lsb = 0;

    Wire.beginTransmission( (uint8_t)VEML6075_ADDR);
    Wire.write((uint8_t)reg);
    Wire.endTransmission(false);

    Wire.requestFrom((uint8_t)VEML6075_ADDR, (byte)2);
    lsb = Wire.read();
    msb = Wire.read();

    To get device ID
    But nothing works


  • Mod

    @fedor If you have an oscilloscope or logic analyzer you could connect that to see what's going on.
    Unfortunately I don't have any VEML6075 so I'm not able to replicate your setup.

    Are you sure you have the right i2c address btw (might be configurable on your breakout board)? Try performing an i2c scan...



  • @yveaux
    surprisingly but the sensor detected during i2c scan with correct address 0x10
    I tried to explore dataflow using dso138 but this device is very simple, trigger works even at 50 us, clock looks like sine wave, but I see that some "1" on SDA are less that 3.3 volts, about 2 volts. Can this be a problem? However BMP280 sensor has the same but works well.
    I tried 3.3v arduino and it works too. Resistance between sensor boards SCL/SDA and VIN is 10K just like BMP280


  • Mod

    @fedor said in Blue pill (stm32f1) + VEML6075 UV sensor:

    Can this be a problem?

    I'm not sure if you can really trust the readings of this 'oscilloscope'. You can try slowing down the i2c clock to make it visible.
    The 10k pullup is rather high IMO for a 3v3 system, I'd rather try 4k7 or even lower. But you say you already tried lowering the pullups.



  • @yveaux said in Blue pill (stm32f1) + VEML6075 UV sensor:

    Can this be a problem?

    I'm not sure if you can really trust the readings of this 'oscilloscope'.

    I agree 🙂

    You can try slowing down the i2c clock to make it visible.

    100Khz is already minimum in blue pill Wire 😞

    The 10k pullup is rather high IMO for a 3v3 system, I'd rather try 4k7 or even lower. But you >say you already tried lowering the pullups.

    but 10k works well in arduino 3.3v, arduino 5v with level converter to 3.3v. 10k BMP280 works with stm32 😞
    I ordered esp8266, it looks like someone is using VEML6075 with it



  • OK I finally managed it
    The sensor requires i2c repeated start
    But both Roger Clarks and official STM core for Blue Pill TwoWire libs don't support it.
    Wire.endTransmission( bool stop ) where stop is just a stub and not processed
    but SoftWire handles it
    so just few changed to any lib (SparkFun/Adafruit/etc) like:

    #ifdef ARDUINO_ARCH_STM32F1
    #include "SoftWire.h"
    #else
    #include "Wire.h"
    #endif

    and
    SoftWire SWire(PA1,PA2,SOFT_STANDARD);
    #define Wire SWire

    solves the problem
    I hope this is useful to someone


  • Mod

    @fedor good to hear you got it working!
    What I don't understand is that in your original post you mention you already tried softspi and failed, so what's different now?



  • @yveaux
    I tried to use SoftWire in sketch without any libs and missed repeated start.


Log in to reply
 

Suggested Topics

  • 87
  • 3
  • 5
  • 9
  • 8
  • 10

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts