Wemos D1 Mini with multiple sensors

Hello,

I’m looking to create an all-in-one sensor module. I purchased a 5pk of Wemos D1 Minis which I was hoping to use for the main board but also have a couple ESP8266 (esp-12) laying around as well.

On this board I want to power a BME680, TEMT6000 Lux Sensor, HC-SR501 Motion sensor and a SSD1306 display to show the BME680 info. I also want to power this via ESPHome within HA to configure into automations and dashboards.

I currently have a D1 Mini and ESP280 running fine with ESPHome but I wasn’t sure if I could plug multiple sensors into the same D1/D2 ports or if they have to be independent. Also, can all of these safely be powered via the 3.3v port or would that cause a power draw issue?

If anyone could help with a wiring diagram on how this should be configured I would be grateful.

I have some programming experience but i’m just getting into small electronic components and trying to self learn. I’ve seen diagrams with just one sensor, but not multiple to one board.

Thank you for any help you can provide!

BME680 and SSD1306 are I²C, TEMT6000 is analogue, HC-SR501 needs one digital GPIO pin, and prefers 5V to 3.3V.

In theory, you should have no problem connecting this lot up, but it won’t be all to D1/D2. Check out the ESPHome docs linked above, and this excellent article for choosing pins.

Thank you for the links!

So it seems BME680 and SSD1306 can utilize D1 and D2, TEMT6000 out should be to A0 and the HC-SR501 can be plugged into D3 using 5v instead of 3.3v for VCC. Is that correct?

Next I just have to figure out how to utilize the screen to display what I’m looking for - I guess I should dig more into the site.

I wouldn’t use D3 for the input, as per the table in that article. Use D5, D6 or D7.

1 Like

This article may interest you Time & Temperature on OLED Display — ESPHome

Thank you for all the help so far!

I got my TEMT6000 wired in today, but for some reason it doesn’t seem to be calculating lx correctly.

I used the formula from the link provided, but in complete darkness it’s returning: (5v):
[22:32:03][D][adc:058]: ‘Office Illuminance’: Got voltage=2.94V
[22:32:03][D][sensor:117]: ‘Office Illuminance’: Sending state 587.30469 lx with 2 decimals of accuracy

in a decently lit up room it’s returning (5v):
[22:32:13][D][adc:058]: ‘Office Illuminance’: Got voltage=3.95V
[22:32:13][D][sensor:117]: ‘Office Illuminance’: Sending state 789.06250 lx with 2 decimals of accuracy

3v side dark is:
[22:34:09][D][adc:058]: ‘Office BME Voltage’: Got voltage=2.95V
[22:34:09][D][sensor:117]: ‘Office BME Voltage’: Sending state 2.95312 V with 2 decimals of accuracy

3v Light is:
[22:34:33][D][adc:058]: ‘Office Illuminance’: Got voltage=3.52V
[22:34:33][D][sensor:117]: ‘Office Illuminance’: Sending state 704.29688 lx with 2 decimals of accuracy

If I unplug the sensor completely, it still returns 2.95v

esphome:
  name: weather1
  platform: ESP8266
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxx"

i2c:
  scan: True
  id: bus_a
  
sensor:
  - platform: bme280
    temperature:
      name: "Office Temperature"
      id: bme280_temperature
    pressure:
      name: "Office Pressure"
      id: bme280_pressure
    humidity:
      name: "Office Relative Humidity"
      id: bme280_humidity
    address: 0x76
    update_interval: 35s
  - platform: template
    name: "Office Absolute Humidity"
    lambda: |-
      const float mw = 18.01534;    // molar mass of water g/mol
      const float r = 8.31447215;   // Universal gas constant J/mol/K
      return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) /
        (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) /
        ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3
    accuracy_decimals: 2
    update_interval: 35s
    icon: 'mdi:water'
    unit_of_measurement: 'g/m³'
    
  - platform: adc
    name: "Office BME Voltage"
    pin: VCC
    id: "VCC"
    internal: true
    update_interval: 35s
    
  - platform: adc
    pin: A0
    name: "Office Illuminance"
    unit_of_measurement: lx
    filters:
      - lambda: |-
          return (x / 10000.0) * 2000000.0;
    update_interval: 5s

binary_sensor:
  - platform: gpio
    pin: D5
    name: "Office Motion Sensor"
    device_class: motion

wifi:
  ssid: "xxx"
  password: "xxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Weather1 Fallback Hotspot"
    password: "xxx"

captive_portal:

How have you wired it up? Did you read the note on the ESPHome TEMT6000 page? D1 Mini is an ESP8266 device, so can only accept 0–1V on the A0 pin.

You’ll need some sort of voltage divider (two resistors in series, with the TEMT output at the “top”, ground at the “bottom” and A0 connected to the “middle”). The value of the resistors will determine the division — for example, if you wanted to divide it by five, you’d need the top resistor to be four times the value of the bottom one.

If you’re not short on space, the easiest method would be to get a pack of e.g. 4.7k resistors, and use two in series for the “top” (9.4k) and two in parallel for the “bottom” (2.35k).

D1 mini has resistors built in so you can put 0v–3.3v over A0.

Oh, good catch. I run many D1 Minis but haven’t used the analogue input yet.

In that case, so long as you connect Vcc on the TEMT6000 to 3.3V not 5V, you can connect SIG straight to A0. If you’re seeing voltages over 3.3V, you’re powering it from 5V and might let the magic smoke out.

Thank you for the replies, i’m very new to small electronics I’m still struggling understanding when things like resistors and capacitors are needed.

That said, I have it currently hooked up with VCC to the 3.3v port, Ground to Ground and SIG to the A0 port - but i’m getting the same results as above. No less than 2.95v and a max of 3.5v which based on the lambda equation only converts to a minimum of 588 lux and a max of 704 lux.

It ran all night wired this way and no change.

Try removing the BME voltage platform: adc block. The docs say not to use that at the same time as the analogue input:

For example, on the ESP8266, you can measure the value of an analog pin (A0 on ESP8266) or VCC (see below) but NOT both simultaneously. Using both at the same time will result in incorrect sensor values.

That seems to be working better - I’m getting 200 lx and when I put my hand over the sensor, it drops to 100 lx. Reading the article it seems it maxes out at 200 lx with the 8266 - I assume there isn’t a way around that?

Also, I’m planning on powering this with a battery, if I have to remove the voltage block do you have a recommendation on how I can monitor the battery level?

Yes, an esp32 will have more ADC inputs.

Did you not read to the end?

I saw that, but unfortunately I don’t know what that means or how to divide the voltage.

I did explain that a few posts back, but you don’t need to with the D1 Mini, as pointed out above. It has this potential divider built in, and should work with the full range of the sensor.

You ought to be able to read from 0lx to the maximum.

If you can manage another sensor on the I²C bus and don’t get any joy with the TEMT600, I use a BH1750 with good results.

Here you are https://bfy.tw/RF32

Not only is that sarcastic, it gives four misleading ads before the useful Wikipedia article. :face_with_monocle:

1 Like

Hm, interesting - it’s hooked up to the mini now and won’t go above 200lx.

I’ll have to do some further research it seems or just deal with it :slightly_smiling_face: