ESP-12 Project (is the esp enough)

I have a long standing project that im finally getting time to work on.

Here are the functions I plan on implementing: Ammeter 2x PID devices (using 1 temp sensor and 1 relay each) 7x relays 3 onewire busses serial connection to a display (display is 5v) Ammeter with 2 CTs (one for each leg)

Here are the components that i plan on using: MCP23017 for the relays Songle 5v 10A relays x5 SSR 40A relay x2 CP2104 USB to Serial LM2576 to convert 12v to 5v AZ1117CH to convert 5v to 3.3v ADS1015 ADC to sample current

Here is where it is going in: |500x242

A couple concerns I have. i have a need for 2 serial ports (Rx AND Tx) one to debug/flash and the other to send and receive to a display like an ITEAD smart display. as far as i know Serial1 is Tx only so i was thinking a DPDT slider to switch between the 2. does that sound right?

I will have the MCP and the ADS on the I2C channel. MCP will be all output with no interrupts. The ADS will have a high sample rate. does the sample rate affect the communication across the channel?

now that the ADC is external, i "can" move to an ESP32 but it adds coding complications that I might not need.

3 onewire busses? Can you explain? I think that's the wildcard there - the rest of it should work. Make sure to level shift where necessary.

Do you really need a glitzy LCD screen like that? A 1602 or 2004 character LCD doesn't do it? They both work over I2C and would eliminate the need for the serial port.

DrAzzy: 3 onewire busses? Can you explain? I think that's the wildcard there - the rest of it should work. Make sure to level shift where necessary.

Do you really need a glitzy LCD screen like that? A 1602 or 2004 character LCD doesn't do it? They both work over I2C and would eliminate the need for the serial port.

sure thing. the LCD screen is a touch screen that will send commands back to the esp. turn on and off relays, show temps, etc. if there is something better, i am all ears.

as far as the 3 buses. I have 3 temp sensors that will be plugged in. I have no idea what the addresses will be, nor any intuitive way to determine what is what except for the pin that it is on. i am all ears if there is a solution to that one too. the temp sensors need to be dealt with individually. if you look at the pic, on the far right side, you will see 3 "microphone" connectors, that is how the temp sensors get plugged in. an example would be the bottom one (due to the orientation of the pic) would be a boiler. whatever temp sensor that is plugged in would need to be assigned to "boilerTempSensor" the only way i know how to do that is to keep the buses seperate.

What temp sensors? Onewire devices all have serial numbers. Determine them experimentally imo. That way you just need one onewire bus

ds18b20

i plan on making this reusable, so if there is some way to do a setup, and commit it to memory or something, that would work. otherwise i dont know.

theskaz: I plan on making this reusable, so if there is some way to do a setup, and commit it to memory or something, that would work. otherwise I don't know.

Yes, DS18B20 are "one wire" devices - though it is far more practical to use them with both (5 V) power supply lines.

Each device has an identity, so you connect any reasonable number (what is that? Probably up to a dozen as long as there is no more than a metre or two of wire involved) in parallel to a single Arduino pin.

There is code to ask the identity of a given device connected alone to the Arduino so that when many are connected, you can refer to a particular one by specifying its identity in your actual application code.

Paul__B: Yes, DS18B20 are "one wire" devices - though it is far more practical to use them with both (5 V) power supply lines.

im not sure what you mean by this. "both" 5v power lines?

Paul__B: Each device has an identity, so you connect any reasonable number (what is that? Probably up to a dozen as long as there is no more than a metre or two of wire involved) in parallel to a single Arduino pin.

There is code to ask the identity of a given device connected alone to the Arduino so that when many are connected, you can refer to a particular one by specifying its identity in your actual application code.

each sensor is connected to a 3 meter cable.

If i did a single bus, the only way i know how to get the device address is to plug one in, do a search, get the address, turn off, add another, turn on, get the new address, rinse, repeat. Shut it all down, program it, and boot it back up.

that sounds like a PITA.

vs 3 buses. whatever sensor is plugged in will be definitely the one I am looking for.

what exactly IS the issue with 3 buses. what problem does it present other than using 2 additional pins?

theskaz: I'm not sure what you mean by this. "both" 5v power lines?

5 V and ground. You can operate them without the 5 V line, but the library has to allow for this, switching between a pull-up and logic HIGH as required.

theskaz: each sensor is connected to a 3 meter cable.

Fairly long - could be a problem with three in parallel, so may actually favour using separate busses.

theskaz: If I did a single bus, the only way i know how to get the device address is to plug one in, do a search, get the address, turn off, add another, turn on, get the new address, rinse, repeat. Shut it all down, program it, and boot it back up.

And that is precisely how you do it. :grinning:

theskaz: that sounds like a PITA.

Can't see why. Building the thing is a PITA in any case. If you think it will work first time, you either have a lot to learn, or are better than anyone here. :astonished:

theskaz: vs 3 buses. whatever sensor is plugged in will be definitely the one I am looking for.

But then you have to keep track of which is connected to which pin. If you know the code for each sensor, which pin it connects to no longer matters.

With a single sensor per pin, the code still has to figure out the identity of the sensor (on each boot-up, if you don't want to write the identity into the code) before it can use it.

theskaz: what exactly is the issue with 3 buses. what problem does it present other than using 2 additional pins?

It relates to your initial question - "is the esp enough".

Here is my first draft of a schematic. Im going to go with the 3 different buses. I initially wired them to 3.3v, but moved them to 5v. |500x305

TODOs:

Wawa: I would use a voltage divider, to make ~1volt from the 3.3volt supply. Could be 220k to 3.3volt and 100k to ground. Add a ceramic bypass cap (1-10uF) from divider tap to ground. Two 100k resistors from the divider tap to two differential inputs of the A/D. CT also connected to those two differential inputs.

Questions: do i need to add optocouplers for the 5 relays? they will be switching 120v but only to activate a coil on a 240v contactor, so not much current. the exact amount escapes me.

Is there any glaring issues with this overall idea?

theskaz: Is there any glaring issues with this overall idea?

Yes.

theskaz: I initially wired them to 3.3v, but moved them to 5v.

And you connect that to an ESP-12?

yeah… didnt think that through.

revised:

Paul__B: 5 V and ground. You can operate them without the 5 V line, but the library has to allow for this, switching between a pull-up and logic HIGH as required.

i think i just now got what you were saying. Parasitic power? i was thinking you were talking about bumping 3.3v to 5v for them. hense my modification.

One-wire bus must run on 3.3volt. And the ADS must be powered from 3.3volt.

3k3 base resistor is not enough base current (0.8mA) to switch a ~75mA 5volt relay coil. The transistors do not fully saturate and could get hot. Lower to 470ohm. Leo..

added all of Leo's recommendations (from this thread and the other) Leo, can you make sure I wired the CT circuits up right? switched to MCP23008 changed the layout to enhance readability added addr pin on ADC will not have Alert Pin (dont need it, and dont have room for it on the esp12) |500x325

Don't forget a 100n ceramic decoupling cap on VDD of every chip. I also add a beefy tantalum (470uF/6.3volt) on VCC of an ESP module, to help the 3.3volt regulator (optional).

Why the 10k in series with the address pin of the ADS. Connect pin directly to ground or VDD.

You need (3k3) pull up resistors on the I2C lines.

Input circuit of the ADS is not what I explained. Leo..

Wawa: Don't forget a 100n ceramic decoupling cap on VDD of every chip.

for the ESP12, i have a 10uF (C3) cap there. are you suggesting adding an additional cap to the esp12 and the rest of the ICs or is the esp12 good?

Wawa: I also add a beefy tantalum (470uF/6.3volt) on VCC of an ESP module, to help the 3.3volt regulator (optional).

ok, will be in the next revision

Wawa: Why the 10k in series with the address pin of the ADS. Connect pin directly to ground or VDD.

i saw a couple of examples on the internet and most of them have a 10k there. i dont know its purpose, so i removed it.

Wawa: You need (3k3) pull up resistors on the I2C lines.

added. ill try to figure out why later.

Wawa: Input circuit of the ADS is not what I explained.

ok, ill put in your quote, and tell you what i understood, and please let me know where i went wrong.

"I would use a voltage divider, to make ~1volt from the 3.3volt supply. Could be 220k to 3.3volt and 100k to ground."

ran a line from the VDD of the ADC to a 220k res. to a 100k res to GND.

"Add a ceramic bypass cap (1-10uF) from divider tap to ground."

i took divider tap to mean the section in between the resistors, where it would be 1v. and the cap is 10uF

Two 100k resistors from the divider tap to two differential inputs of the A/D.

from the same "divider tap" to A0+ and A1+ each has a 100k resistor. I assumed the + was input. CT also connected to those two differential inputs.

from the 100k goes to a terminal for the CT.

should the 100k be between the 1v and the CT instead?

Here is a better look in case my upload is unreadable: |387x500

revision d, or e, or.....:

(Thanks guys for all your help so far!) |500x323

theskaz: for the ESP12, i have a 10uF (C3) cap there. are you suggesting adding an additional cap to the esp12 and the rest of the ICs or is the esp12 good?

i saw a couple of examples on the internet and most of them have a 10k there. i dont know its purpose

Wise to have 100n local decoupling very close to VDD/GND of every chip.

The ESP draws about 80mA, and ~400mA peaks during transmit. You can almost eliminate those peaks with a 220-1000uF buffer cap on the supply pin of the ESP. If you don't, then the supply and the 3.3volt regulator has to provide those peak currents. Up to you...

Sometimes a 10k pull up resistor is used from the address pin to VDD, and a solder bridge to ground. So you can change the I2C address with a blob of solder if you need to use more than one ADS chip.

The divider and the cap from tap to ground is ok.

But the CT must be connected directly to the inputs.

You need four 100k resistors. One from the tap to each of the four inputs. Leo..

Wawa: Wise to have 100n local decoupling very close to VDD/GND of every chip.

The ESP draws about 80mA, and ~400mA peaks during transmit. You can almost eliminate those peaks with a 220-1000uF buffer cap on the supply pin of the ESP. If you don't, then the supply and the 3.3volt regulator has to provide those peak currents. Up to you...

is this why you recommended the 470uF cap in a previous post? that was a ceramic cap, and im assuming that a ceramic can be a "buffer" cap. when i look up higher cap sizes, i tend to see the pth cylindrical caps. which as far as i know, can be swapped out. but there is more learning to be had.

Wawa: The divider and the cap from tap to ground is ok.

But the CT must be connected directly to the inputs.

You need four 100k resistors. One from the tap to each of the four inputs. Leo..

ok, like this?: |500x414

Tantalum can replace an an electrolytic buffer cap with a ceramic cap across. Usually more expensive though.

Diagram is ok now. Leo..