Porting from Nano to ESP8266

PaulRB:
No, resistors won't do that. Fortunately, you are not using an ESP8266, you are using a board which contains an ESP8266, and also contains a voltage regulator which can make 3.3V from a 5V input.

Thanks PaulRB - so are you saying I can just power by ESP8266 board with 5v and it will handle it ok? If so problem solved!

Yes, it will, but...

The esp pins are 3.3V. If you use them as outputs to control other components, and those components are designed for 5V signals, they may not work correctly with only 3.3V signals. Worse still, if you use the pins as inputs and feed 5V to them when they expect only 3.3V signals, they could be damaged. So logic-level shifters may be required between any 5V components and the 3.3V esp pins.

I guess I don't understand how you can hook up a 12v/12v relay to a board which only accepts 3v. I guess I don't understand how you can hook up a 12v/12v relay to a board which only accepts 3v.

When we say that a relay is 5V or 12V, what we mean is that the relay's coil, it's electromagnet, needs that voltage to operate, to mechanically move the contacts. But relay modules usually have an amplifier circuit (a transistor or opto-isolator) that enables a low voltage or low current input signal to activate the coil and move the contacts.

Ok, have I understand you correctly: even if I can feed 3v to the processor the input signals from the PIRs need to be converted to 3v also? Therefore if I powered the relays separately with 5v they would send a 5v signal to the input pins, which would damage them?

I'm wondering would it be simpler to get a Esp8266 to talk to the Arduino to accomplish the comms and timer issue?

the input signals from the PIRs need to be converted to 3v also?

Yes, but that's easy to do with a couple of resistors (eg. 4K7 & 10K).

if I powered the relays separately with 5v they would send a 5v signal to the input pins, which would damage them?

Why would relays send signals to the input pins? How are you planning to use the relays?

I'm wondering would it be simpler to get a Esp8266 to talk to the Arduino to accomplish the comms and timer issue?

That's easy to answer. No, it would be much less simple. Your Nano is 5V and the esp is 3.3V, so you have not removed the voltage problem, just moved it. And made the whole circuit and the code much more complex.

Hi PaulRD - Many thanks for staying with me on this! As you can gather, this is a new subject for me, so I am just learning. I appreciate your perseverance!

I got confused, as initially I read from your post that resisters would not work to reduce volt to ESP8266, but now I see from your last reply they will work to reduce the signals to and from the sensors. So resisters will work to reduce 5v input signals. But surely that still leaves the challenge of moving up from 3v to 5v?

Can I use these logic converters:- https://www.amazon.co.uk/ARCELI-Channels-Converter-Bi-Directional-Shifter/dp/B07RDHR315 to interface between the ESP8266 and the 5v PIRs and Relays?

Many thanks.

Sending a 3.3V logic signal to a 5V input will cause no harm. For a mega328 or 2650 processor Vih or the voltage level that will be recognized as a valid high is 0.6 * Vcc. For a 5.0V Vcc that works out to 3.0V, so 3.3V should be seen as a valid HIGH.

So you can connect a 3.3V output to a 5V input with no risk of damage and reasonable confidence that the signals will be properly read.

The other way, 5V output to a 3.3V input does require voltage level shifting. That can be resistor voltage divider (slower signals), unidirectional (CD4050) or bidirectional (MOSFET level shifter).

Here is a page that covers some level shifters.

joatmon13:
I got confused, as initially I read from your post that resisters would not work to reduce volt to ESP8266, but now I see from your last reply they will work to reduce the signals to and from the sensors.

Yes, a voltage divider (2 resistors) can reduce a 5V output signal to a 3.3V input. This is OK because the voltage is a "signal", which is a control voltage. Almost zero current flows between the output and the input.

But to reduce the voltage in order to power something, a voltage divider is not good. The output voltage of a voltage divider depends not only on the resistor values, but also on the current drawn. With something like an esp, the current will vary dramatically from one moment to the next, as it transmits WiFi signals, for example. As the current increases, the output of the voltage divider drops, and will probably drop too low for the esp to work. That's why you want to use the regulator built in to the esp board. A voltage regulator constantly adjusts itself, so that when the current changes, the voltage stays the same.

joatmon13:
But surely that still leaves the challenge of moving up from 3v to 5v?

As groundFungus explained, you probably don't need to. You can power the PIR sensors and relays with 5V directly from the buck converter, and step the 5V output signal from the PIRs down to 3.3V with resistor voltage dividers. You won't need to step up the 3.3V signal from the esp to the relay inputs, because relay modules have that circuit built-in, usually in the form of a transistor or opto-isolator, which requires only a low voltage or current to trigger it.

Thank you very much for the clarification. I will begin building the prototype using the ESP8266 as you suggest. Once I have that working the same as the Arduino Nano, I will delve into figuring out how to code in the additional Wifi and Time of Day functionality. No doubt I will be back seeking some further insights.

I have example code I can share for that if you need it.