GPIO-1 and GPIO-3. Can I use them?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

GPIO-1 and GPIO-3. Can I use them?

#1 Post by onlize » 21 Mar 2018, 21:49

I have NodeMCU running for some time now. I configured it about a year ago and everything works great. This is how I have it configured.
SDA uses GPIO-9
SCL uses GPIO-10

This device uses 7 pins to monitor my security. Basically it notifies me when my doors or windows are opened or closed. I use the following GPIOs for monitoring:
GPIO-0, GPIO-2, GPIO-4, GPIO-5, GPIO-12, GPIO-13, GPIO-14.

Now I want to add HC-SR04 sensor to this device. This sensor require two GPIOs. I found that when I disable Serial Port in Advanced settings, I can select GPIO-1 and GPIO-3, but when I do it, my sensor does not work. I test it using different NodeMCU and it works if I use GPIO-12 and GPIO-13, but if I try to move this sensor to GPIO-1 and GPIO-3, it stop working. The plan is to learn how to enable them, test, and connect this sensor to my existing NodeMCU if possible.

Am I missing something? Can I use GPIO-1 and GPIO-3? Or will I have to use the second NodeMCU?

Thank you.

spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Re: GPIO-1 and GPIO-3. Can I use them?

#2 Post by spachal » 21 Mar 2018, 22:59

https://www.letscontrolit.com/wiki/inde ... figuration :)
May be used but observe that signal might flicker due to serial activity during boot.
Please excuse my English, thanks!

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#3 Post by onlize » 21 Mar 2018, 23:46

I saw this information, but it does not work.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: GPIO-1 and GPIO-3. Can I use them?

#4 Post by toffel969 » 22 Mar 2018, 07:56

Read here : http://www.letscontrolit.com/forum/viewtopic.php?t=1462

Do yourself a favour and get an i2c i/o expander for that unit. This will free up enough gpio
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: GPIO-1 and GPIO-3. Can I use them?

#5 Post by grovkillen » 22 Mar 2018, 08:29

Totally agree.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#6 Post by onlize » 22 Mar 2018, 13:17

Do you mean PCF8574? I will definitely try, thank you for your advice.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: GPIO-1 and GPIO-3. Can I use them?

#7 Post by toffel969 » 22 Mar 2018, 14:24

onlize wrote: 22 Mar 2018, 13:17 Do you mean PCF8574? I will definitely try, thank you for your advice.
Yes, either PCF8574 or MCP23017.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: GPIO-1 and GPIO-3. Can I use them?

#8 Post by Shardan » 22 Mar 2018, 14:38

For some Clarification:

ESPEasy uses GPIO1 and GPIO3 as serial communication port by default.

This says that serial communication is enabled in a fresh installation of ESPEasy and GPIO 1+3 can not be used as In/Out by default!

If you want to use them you have to deactivate the serial port in the ESPEasy settings first.

Please beware:
- GPIO 1 and 3 are the standard ports for serial - deactivating serial takes place when ESPEasy has already started.
So on Startup there will be some signals on the TX line as the ESP itself sends some boot messages.
This cannot be disabled by ESPEasy.

- If you use these ports for other purposes then serial, the diagnosing possibilities via serial are lost!
Be very sure your project runs, diagnosing without serial can be somewhat tricky.

- Take measurements for re-flashing with your circuit.
You may need to reflash your firmware some day - via serial. Make sure you have jumpers in your circuit to disconect
GPIO1 and GPIO3 from circuit and make it availlable for flashing.


All in all i agree with grovkillen: A GPIO expander like PCF8574 or MCP23017 should be preferred over using GPIO 1/3

Regards
Shardan
Regards
Shardan

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#9 Post by onlize » 22 Mar 2018, 16:02

Thank you for your help.

I bought th PCF8574 device.

It will take a couple of week to come from China, but I am trying to understand how to use it. I found this article: https://www.letscontrolit.com/wiki/index.php/PCF8574, but have a few questions.

First of all, are the connections on the right and on the left the same? Can I use either one of them?
Also, the article says that there will be eight additional pins, but I see nine pins on the board. Do you know why?
It is not clear how to connect it in the ESPEasy. The example show Port: 1 and IDX/Var: 22. What are those numbers? I do not understand that table with A0, A1, A2, Address, and Port range. Can you please explain?

Thank you.
Attachments
Capture.JPG
Capture.JPG (29.08 KiB) Viewed 22704 times

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: GPIO-1 and GPIO-3. Can I use them?

#10 Post by Shardan » 22 Mar 2018, 16:33

I'm still in the office and don't have a module at hands.

The yellow pins are the additional input/output pins, the 9th pin might be a ground pin, i have to check that myself.

The four pins left and right are identical, yes.
You can chain max. 8 of these modules by just plugging one module to the other.
At this point the A0...A2 comes up: This selects the address the PCF chip uses on the I²C bus.
As you have three jumpers and every possible combination from all jumpers "on" to all jumpers "off" is valid you can select up to 8 addresses.

Connecting to ESP is as simple. I²C is a two wire bus system. The bus consists of SDA (data) and SCL (clock).
On top you need Ground and 3.3V (Vcc). Connect GPIO5 (D1) to SCL, GPIO4 (D2) to SDA, Vcc to Vcc and Gnd to Gnd.
That's it.

For input you need a task per input.
The input port number depends on the address you've chosen with A0...A2. If you have set A0-A3 to "0" or "Off", this is chip address 0,
so input pins for the setup in ESPEasy are pins 1 ... 8 (so called "Port Range")
If you set for example A0 = 0, A1 = 1 and A2 = 0 you selected the chip address 2. Port range will be 17 ... 24 then.

For output just send command:
For example: PCFGPIO,6,1 to switch the pin 6 on chip 0 to "on".

For a detailed description of I²C and how to get it to work see wiki: https://letscontrolit.com/wiki/index.ph ... C2%B2C_Bus

Regards
Shardan
Regards
Shardan

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#11 Post by onlize » 22 Mar 2018, 16:39

Great, thank you very much. I will try it when I receive this device.

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#12 Post by onlize » 22 Mar 2018, 23:58

Shardan wrote: 22 Mar 2018, 16:33 The input port number depends on the address you've chosen with A0...A2. If you have set A0-A3 to "0" or "Off", this is chip address 0,
so input pins for the setup in ESPEasy are pins 1 ... 8 (so called "Port Range")
If you set for example A0 = 0, A1 = 1 and A2 = 0 you selected the chip address 2. Port range will be 17 ... 24 then.
Does it mean that example has a mistake? They have Port 1 and IDX/Var is 22, but in your explanation IDX/Var 22 (17-24) would be with the port 2, not port 1. Am I correct? Or maybe I do not understand it.

Thank you.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: GPIO-1 and GPIO-3. Can I use them?

#13 Post by toffel969 » 23 Mar 2018, 13:43

onlize wrote: 22 Mar 2018, 23:58
Shardan wrote: 22 Mar 2018, 16:33 The input port number depends on the address you've chosen with A0...A2. If you have set A0-A3 to "0" or "Off", this is chip address 0,
so input pins for the setup in ESPEasy are pins 1 ... 8 (so called "Port Range")
If you set for example A0 = 0, A1 = 1 and A2 = 0 you selected the chip address 2. Port range will be 17 ... 24 then.
Does it mean that example has a mistake? They have Port 1 and IDX/Var is 22, but in your explanation IDX/Var 22 (17-24) would be with the port 2, not port 1. Am I correct? Or maybe I do not understand it.

Thank you.
Port number and IDX are not related.

In the example in the wiki:

The 3 adress bits (A0-A2) of the PCF chip are all set to 0.
This means the chip will have the I2C-Adress 0x20 and the port range is 1-7.

If the adress bits were set to 1 0 0 the adress of the chip changes to 0x21 with the port range 8-15.

This way, up to 8 chips can be daisy chained.

The IDX is the unique identifier for Domoticz. It has nothing to do with the adress/port of the PCF.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

onlize
Normal user
Posts: 44
Joined: 12 Aug 2017, 03:44

Re: GPIO-1 and GPIO-3. Can I use them?

#14 Post by onlize » 23 Mar 2018, 14:29

Got it. That IDX value confused me. Thank you for explaining.

Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests