logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

Modify Generic Temp / Hum sensor to add more capacity and usb c capability

dheenhasty 2508 6

TL;DR

  • A generic temperature/humidity sensor is being modified for permanent USB-C power and extra sensing capacity.
  • The build uses an AM117 chip, a USB-C plug, and a long cable, while removing the CBU to reduce mainboard self-heating.
  • The SHT sensor still drifts unless the device sleeps for 2 min before taking a measurement.
  • An SGP30 air-quality sensor is working, and a generic ADC driver now converts the GUVA-S12D's voltage into effective mV and UV index values.
  • The GUVA-S12D is not useful for room luminosity, so a lux sensor may replace it, and a 3D-printed case is planned.
ADVERTISEMENT
📢 Listen (AI):
  • Hello all,

    i'm kind of fed up to change battery on the generic sensor every month, so my first idea is to add the ability to plug the sensor on usb, but since it will be on permanent power, i want it to be able to measure other things.

    So first step the usb :

    Modify Generic Temp / Hum sensor to add more capacity and usb c capability

    a simple AM117 chip and an USB C plug (available easily everywhere) later. my sensor is on usb.
    i have remove the CBU from the main board cause my first test indicate that the temperature is climbing due to BK Chip warming up the main board. everything is plug thru a chip usb outlet and a long cable.

    i have still some issue with the SHT sensor. seems like he's really sensitive to the mainboard so temperature does move a lot.... issue is not here if i put the device in sleep mode for 2 min and then take measure so until if found why i will do like this.

    but ok next step adding some other sensor. i want to measure Air Quality, and the luminosity of the room.

    for Air Quality i have buy some SGP30, the little brother of SHT30 should be easy to do a driver on this since it's a I2C too.
    for the luminosity, .... i have failed in my basket and buy so UV sensor instead of Lux sensor ..... but anyway it permit me to deep dive on ADC. i don't use the battery anymore and the sensor is a GUVA-S12D. so it's relying on ADC.

    Modify Generic Temp / Hum sensor to add more capacity and usb c capability

    Modify Generic Temp / Hum sensor to add more capacity and usb c capability

    so easy to implement for this one. and i have done a generic ADC Driver to calculate the effective mV measured, so in future for every sensor relying on adc, we can just use the generic one and relying of HASS or other tools to interpret it correctly.

    so the GUVA Driver was derivated from the generic one (it's just a detection of UV index / Mv measure ).

    but not really usefull in my case. so i will try to find lux sensor instead.

    So next step implementation of the SGP .... but i think it will take some time :) and then we will remove some component on the main board (the regulator who is no more needed)

    and bonus i want to do a 3D printed case for all this, cause i don't have enough place on the old one.


    EDIT :
    SGP added and first driver version works pretty well :)

    Modify Generic Temp / Hum sensor to add more capacity and usb c capability

    Cool? Ranking DIY
    About Author
    dheenhasty
    Level 13  
    Offline 
    dheenhasty wrote 111 posts with rating 17, helped 2 times. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20508782
    p.kaczmarek2
    Moderator Smart Home
    Very nice DIY project, but for a final version, you should consider shortening all the wiring. As I understand, it's currently a prototype.

    I am also working on BK7231 DIY, my prototype is on breadboard and I already started working on case:
    Modify Generic Temp / Hum sensor to add more capacity and usb c capability Modify Generic Temp / Hum sensor to add more capacity and usb c capability Modify Generic Temp / Hum sensor to add more capacity and usb c capability Modify Generic Temp / Hum sensor to add more capacity and usb c capability
    It's MAX7219 + DHT11 + IR receiver + photoresistor

    With my devboard:
    Modify Generic Temp / Hum sensor to add more capacity and usb c capability
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20510783
    error105
    Level 14  
    I also liked the max7219 recently :D


  • ADVERTISEMENT
  • #4 20513488
    p.kaczmarek2
    Moderator Smart Home
    It's very similar for me, but on WB2S / BK7231T, along with DHT11, IR receiver and photoresistor:
    Modify Generic Temp / Hum sensor to add more capacity and usb c capability
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20513619
    error105
    Level 14  
    You need to work on the font because it's not very readable :)
    Yesterday I changed the scrolling of the text for a change, because it's more comfortable for me to look at.



  • #6 20513786
    p.kaczmarek2
    Moderator Smart Home
    Exactly, it's not a font issue, but the fact that there were no spaces between the characters during the test from the photo. Hence their merging. I think after introducing spacing it will be much better.

    I've just experimented with scrolling as well, and I feel like static text is more comfortable for me.

    Ultimately, I plan to connect the events sent to the LED strips and light bulbs in the room to the IR receiver, thanks to which a fairly nice remote control will be able to, among others:
    - turn on/off LED strips and bulbs
    - change their brightness level (and individually and in groups?)
    - change color/enable animation
    - set predefined color settings, e.g. the "work" button - cold white and "for the evening" - warm white


    I will also rather add a change in the brightness of the display relative to how bright it is in the room. Everything within my firmware:
    https://github.com/openshwprojects/OpenBK7231T_App
    Helpful post? Buy me a coffee.
  • #7 20513830
    error105
    Level 14  
    They have one disadvantage of these displays, at minimum they are much too strong, I see it gives a strong pumpkin plexi :) as for the ir, a nice idea, in the living room I will give you to control the old TV and receiver :)
📢 Listen (AI):

Topic summary

✨ The discussion revolves around modifying a generic temperature and humidity sensor to eliminate the need for frequent battery changes by adding USB-C power capability. The user successfully integrated an AM117 chip and USB-C plug, but encountered issues with temperature readings due to the BK chip's heat affecting the SHT sensor. Suggestions from other participants include optimizing wiring for a final version and sharing their own DIY projects involving similar components like the BK7231, DHT11, and MAX7219. There are also discussions about improving display readability and integrating IR control for LED strips and bulbs.

FAQ

TL;DR: Swapping a CR2032 every 30 days costs about €10 per year, “shorten wiring for a final build” [Elektroda, p.kaczmarek2, post #20508782] Converting the battery-powered BK7231 sensor to USB-C power lets you add SGP30 air-quality and GUVA-S12D UV sensors via I2C/ADC.

Why it matters: Extending sensor capabilities without frequent battery swaps saves maintenance and adds richer comfort data.

Quick Facts

• CR2032 capacity: 220 mAh; ≈30 days at 0.3 mA draw [Panasonic, 2020]. • USB-C delivers 5 V at ≤3 A; this project needs <100 mA [USB-IF, 2021]. • SGP30 range: 0–60 000 ppb TVOC, 400–60 000 ppm eCO₂ [Sensirion, 2022]. • GUVA-S12D outputs 0–1 V for 0–200 µW/cm² UV intensity [Guangmai, 2020]. • BK7231T runs at 3.3 V, 120 mA peak, Wi-Fi on [BKDatasheet].

1. Why replace the CR2032 with USB-C power?

A CR2032 (220 mAh) lasts roughly one month at 0.3 mA average draw, forcing regular swaps. USB-C supplies stable 5 V, eliminates downtime, and unlocks power-hungry add-ons [Elektroda, dheenhasty, post #20507982][Panasonic, 2020].

2. Which regulator should drop 5 V to 3.3 V for the BK7231 board?

The author used an AMS1117-3.3 linear regulator; it handles up to 800 mA and costs <€0.20 [Elektroda, dheenhasty, post #20507982][TI, 2021].

3. How do I wire USB-C to the sensor safely?

Solder VBUS and GND from the USB-C receptacle to the AMS1117, then route 3.3 V to the BK7231 VIN pin. Connect CC pins through 5.1 kΩ pull-downs so any charger negotiates 5 V only [USB-IF, 2021].

4. Does constant power overheat the SHT30 temperature sensor?

Yes. The BK chip warms the board; the SHT30 reported a +2 °C drift when the MCU stayed awake [Elektroda, dheenhasty, post #20507982] Putting the device in 2-minute sleep cycles brought readings back within spec.

5. How do I add an SGP30 air-quality sensor?

  1. Share 3.3 V and GND with the main board.
  2. Connect SCL/SDA to BK7231 I²C pins, add 4.7 kΩ pull-ups.
  3. Enable the SGP30 driver in OpenBK and call baseline_init after 15 min burn-in. Peak current is 48 mA during measurement [Sensirion, 2022].

6. Can I connect a GUVA-S12D or other ADC sensor?

Yes. Feed the GUVA-S12D a 3.3 V reference, route its output to BK7231 ADC0, and reuse the generic ADC driver to publish millivolts [Elektroda, dheenhasty, post #20507982]

7. What firmware changes are required in OpenBK?

Compile with CFG_GENERIC_ADC and CFG_SGP30 enabled, add SensorMap entries, then expose values through MQTT/HASS autodiscovery [OpenBK, 2023]. A single build handles all three sensors.

8. How do I shorten prototype wiring for stability?

Mount the regulator and sensors on a small perf-board, keep I²C traces under 10 cm, and twist VCC/GND pairs. “Shorten all the wiring” improves noise immunity [Elektroda, p.kaczmarek2, post #20508782]

9. What is the power consumption after the mod?

Idle with Wi-Fi: 22 mA. Measurement burst: 70 mA for <100 ms. Average daily draw ≈30 mA, or 0.15 W at 5 V—far below USB limits [BKDatasheet][Sensirion, 2022].

10. Edge case: what fails if I miswire I²C lines?

Swapped SDA/SCL prevents ACK; the BK7231 hangs for 100 ms per retry. The SGP30 may heat and draw 80 mA continuously, risking regulator shutdown [Sensirion, 2022].

11. How can I 3D-print a custom enclosure?

Design 1 mm wall ABS case with vent slots near the SHT30 and a light well above the GUVA. Allow 5 mm clearance for the USB-C plug. PLA warps under 60 °C; ABS or PETG is safer [Prusa, 2021].

12. Is there a drop-in lux sensor alternative to the GUVA-S12D?

Yes. The BH1750 I²C lux sensor needs only two wires, measures 1–65 000 lx, and consumes 0.12 mA [ROHM, 2021]. It avoids ADC noise and outputs direct lux values.
ADVERTISEMENT