Advice needed on a much needed upgrade

So, I'm looking to upgrade several greenhouse controllers. They've been in place for 3-4 years now and I'm looking to not only neaten them up but also add WiFi at the same time.

Currently, I'm using a Mega 2560 R3 with a 1602 LCD shield controlling an 8 relay unit. Each relay controls a high amperage power relay to control the appropriate equipment. I have 3 of these setups in use.

Here's what I'd like to do

  1. Put each of them in some sort of enclosure
  2. Add WiFi (Wemos D1 Mini module with 16 pins)
  3. Change the relay board from 8 to 4, as I only use 4
  4. Swap sensors from DHT22 to SHT31
  5. Add a power supply
  6. I also have LM2596 DC-DC converters to drop the voltage for the D1 minis. Will these work?

My questions are as follows...

a) How many volt power supply should I get? I'll be adding the power to the Mega through the barrel connector and it'll power the LCD shield and the SHT sensor. The relays will be powered separately from the Mega.

b) I assume that I'll need level shifters for the TX/RX lines from the Mega to the D1, correct?

b) Should I consider ditching the Mega for just the D1? If so, what is the best route? I need 4 digital outputs for the relay. The SHT sensor is I2C. Connecting the LCD I'm also unsure of although I see that there are I2C LCD modules. I don't know how well they work, as I have no experience with them.

Sorry for the long-winded post. I'm trying to get this all sorted before I deploy them, as it's a production environment and interruptions cannot be tolerated.

Swap cumbersome Mega 2560 to a WeMOS D1 Mini plus a port expander.

Terrible idea in any case, the Mega 2560 requires 5 V to the "5V" pin.

Indeed.

So they share two I²C pins.

They work great!

Use Bill's HD44780 library in the IDE Library Manager.

Common power supply is 5 V, WeMOS D1 Mini has regulator down to its 3.3 V working voltage, remove any 5 V pullups on the I²C modules and provide pullups to 3.3 V.

2 Likes

Thanks for the reply, Paul. Very much appreciated.

I've gleaned as much regarding using only the Wemos and ditching the Mega. I'm good with that! What port expander do you recommend? I thought I'd seen them with I2C pins, but I don't recall seeing one with the digital pins that I need.

Also just to clarify, are you saying that the Wemos will regulate 5V down to 3.3V on its own, or do I need to use the DC buck adapter? I see both 3.3 and 5 pins on it.

I'm a bit confused as to what you mean about removing pullups on the I2C modules. I know the SHTs don't have them and I still have to find the appropriate LCD units. And I'm not sure what you mean about adding the pullups to the 3.3V.

It interfaces with the ESP using I²C, the PCF8574/ PCF8575 has 8 / 16 digital I/O pins. If you wanted PWM you would use the PCA9685.

You probably cannot (easily) connect a DHT22 to these though. No idea about the SHT31.

It includes a regulator as long as you do not need to draw very much current.

The I²C "backpack" on the 1602 LCD which requires 5 V includes pull-ups to 5 V on SDA and SCL. You do not want the ESP pins to be pulled up to 5 V so you need to remove these on the backpack and provide pull-ups to 3.3 V instead.

2 Likes

Thanks. I'll look into those interfaces tonight. I'm ditching the DHT in favor of the SHT. As long as I don't have reliability issues with the I2C bus. I had problems trying to swap one of my controllers over and it kept freezing up. I now think it was either interference or too much current being drawn through the Mega, possibly to activate relays that are powered through it. No PWM need.

I think I get what you're saying on the pullups. What would I go with? 4k7? 10k?

Why does the Wemos have a 5v pin if it's 3.3v?

You cannot really "draw current through" a Mega 2560.

Because it can be powered by the USB port. USB supplies 5 V - though the actual data levels are strictly 3.3 V. 5 V power supplies - such a phone chargers - are ubiquitous.

1 Like

I meant that the relays are drawing their power through the 5v pin on the Mega, taxing the onboard regulator.

Ah yes. I forgot about the USB.

Thought's on the pullup value? I assume I'd use on on each clock and data line for each I2C device?

Basically one on each clock and data line for the whole lot - since all are connected together.

1 Like

Couple more things.

You say "As long as I do not need to draw very much current" with respect to the Wemos. Doesn't that module draw a pretty decent amount on its own, especially at boot up and when transmitting data? I just want to make sure that I'd be better off using a DC-DC converter.

Also, I'm looking at the LCDs now and I see they come with the I2C backpack. Is that what you were referring to? Do I just eliminate it? If so, how does the LCD connect to the Wemos?

It draws a couple of hundred milliamps on transmit which is well within the capability of the regulator on the board which only has to drop 1.7 V (1.7 V x 200 mA = 340 mW). But you would not want to add too many other 3.3 V loads.

There is no reason the boot process would require significant power.

Why on earth would you want to do that? :roll_eyes:

Because you said this...
"The I²C "backpack" on the 1602 LCD which requires 5 V includes pull-ups to 5 V on SDA and SCL. You do not want the ESP pins to be pulled up to 5 V so you need to remove these on the backpack and provide pull-ups to 3.3 V instead"
How would I remove the pullups without removing the backpack?

This is what I assumed, thanks. 10k value?

By removing the pullups. :sunglasses:


The two "472" (4k7) resistors to the right of the "POWER" marking.

1 Like

They look like SMTs. Forgive my ignorance, although I'm pretty handy with electrical, I have no experience with the tiniest of components. If you are referring to those, do I just unsolder and bridge the connections over?

And, 10Ks on the ones I need to add? Sorry if I asked this before. I 'm just trying to get my shopping list complete so I can begin testing!

Why would you want to short circuit them once you removed them? :cold_sweat:

What is the value of the pullups I told you to remove? :grin:

1 Like

Lol. I should probably think a little more before I post!

I swear that the second half of your post where you said that and the picture wasn't there!

I should really stop day drinking, or maybe I should start!

Thanks for all of your help Paul. Off to place my order.

I should perhaps mention that the one in the top row is something else - part of the backlight control.

1 Like

Perfect. Thanks again!

I've used sht21 and sht31 sensors in projects. They are i2c. They are available on small breakout PCBs, which are fine for indoor use. For outdoor use or in a greenhouse, I would recommend the version that comes in a water resistant cylindrical tube (it has a section that is vapour permeable). These cost more but I think worth it because they will last far longer in harsh environments.


big

The ones I have used do have pull-up resistors, usually 10K.

How many i²c devices do you plan to connect to each wemos? If just one, plus the LCD backpack and an I/o expander, you might not need to remove their built-in pull-ups. But if you do, those built into the sensor PCB might be difficult to remove because some of them have a 4 x 10K resistor package, 2 of which are used as i²c pull-ups, so you can't remove them without removing the other 2, which might be needed.

EDIT: to clarify, you do need to remove the pull-ups on the LCD backpack because they are connected to 5V. But you can run the sht31 at 3.3V, so those pull-ups will be to 3.3V so don't need to be removed unless you have so many of them that all those weak pull-ups combine into a strong pull-up which might prevent the devices communicating on the i²c bus.

1 Like

You do need to remove the pullups on the 5 V LCD backpack for use with an ESP8266.

Yes, already edited my previous post to clarify that.