coniferconifer / AIR-BENTO

Air quality monitor by ESP32
Apache License 2.0
8 stars 3 forks source link

GY-21 with SHT21 / GP2Y1014AU0F voltage #1

Open rafalmag opened 6 years ago

rafalmag commented 6 years ago

Hi, I am not very good at the electronics subject. I read the readme.md and I do not get few parts.

GY-21 board with SHT21 has 5V SDA/SCL pins , use FET 3.3V-5V level converter to connect to ESP32 I2C bus.

I checked the documentation and it looks it can work fine with 3.3V, so why you did you use 5V + level converter here?

Second thing regarding GP2Y1014AU0F:

Vo output goes up to 3.7V, so Vo is clipped by shotkey diode 1N5819 to protect GPIO33.

I checked "Dust sensor -> wiring", but how does this work? Should not be the diode connected in serial - I mean between V0 and GPIO33? I assume that the Shottky diode should drop the 3.7V to something like 3.3V? Alternatively could the level converter be used here instead?

The photos and documentation are very helpful, however could you please add a wiring scheme? It may be a hand draw. Alternatively I can recommend a fritzing software to make a digital one.

PS: I am really curious, because I am building a similar project - an "indoor air station" with following sensors:

See my repos: ESP32-pms5003 , ESP32-MH-Z14A with LCD

Best regards, Rafal

coniferconifer commented 6 years ago

Hi rafalmag,

Visualization of air condition is really amazing and thank you for comments and feedback.

  1. GY-21 connection

GY-21 has 3.3V LDO(low dropout regulator connected to VIN) on board , so 3.3V from ESP32 was connected to VIN. GY-21 schematics is here. https://www.ebay.com/itm/New-HTU21D-GY-21-HTU-Temperature-Humidity-Sensor-Breakout-Board-Module-Hot-/271731131299 (pull up resisters are 10KOhm for GY-21 I got) Observed external SDA and SCL pins were 3.3V (thanks to Low dropout regulator ) , this should work OK , but I got [W] [esp32-hal-i2c.c:334] i2cRead() Ack Error! Addr:40 for access to SHT21(GY-21 board). I have no oscilloscope to check the waveform of I2C bus , sigrok pulseview logic analyzer showed no ACK on I2C bus.

Another try was to connect 5V to VIN of GY-21 and added 5V - 3.3V FET gate level converter between GY-21 and ESP32 I2C bus, but still got the same error.

I added 4.7kOhm pull up resisters to SDA and SCL lines from GY-21 and pull up to 5V. This fixed the i2cRead() Ack error. The waveform I2C may be shaped by lower pull up resisters, but could not figure out exact reason.

  1. Vo clipping

Since max Vo from GP2Y1014AU0F exceeds ESP32's max input voltage 3.6V for GPIO , I added the shotkey diode to Vo-GPIO39 line. Its cathode was connected to 3.3V and anode is connected to Vo-GPIO39. if dust is 0.45mg/m3 , Vo is 3.7V > 3.3V at cathode, current flows from anode (Vo) to cathode (3.3V) and reduces Vo to 3.3V. If Vo is smaller than 3.3V , no current flows from Vo(anode) to 3.3V(cathode) and Vo remains the same.

This may cause overload to internal amplifier in GP2Y1014AU0F , so this is not recommended for product level design.

Your suggestion to add diode in series seems good. Voltage divider by two resisters or operational amplifier designed to have x0.8 amplification factor may be other solution.
However, entire Vo - dust relation is affected and new formula to calculate dust from Vo is necessary.

I will learn how to draw schematics by computer , sorry for inconvenience.

Thanks

coniferconifer commented 6 years ago

I have prepared another ESP32 board and tested another GY-21 , GY-68 board ( GY-21-(2) , GY-68-(2) )by connecting 3.3V to VIN of GY-boards , SCL and SDA are connected directly to ESP32(SDA,SCL). GY-21-(1) :i2C Ack error GY-21-(2) :OK GY-68-(1) and GY-21-(1) : i2C Ack error GY-68-(2) and GY-21-(2) : OK indicating GY-21-(1) has some problem for VIN=3.3V operation.

coniferconifer commented 6 years ago

with Arduino uno (5V I2C bus) VIN=5V GY-21-(1) :OK GY-21-(2) :OK GY-68-(1) and GY-21-(1) : OK GY-68-(2) and GY-21-(2) : OK

rafalmag commented 6 years ago

Many thanks for the verbose answer. As a professional software developer I keep forgetting that the hardware can misbehave :wink: The bare metal - electronics world is still new to me. :sweat: