User Tools

Site Tools


esp8266:how-to-use-all-esp01-gpio-pins

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
esp8266:how-to-use-all-esp01-gpio-pins [2019/10/23 15:24]
Ilias Iliopoulos [Introduction] WeeMos D1 to WeMos D1
esp8266:how-to-use-all-esp01-gpio-pins [2019/10/31 20:38]
Ilias Iliopoulos Modified code blocks to <code c++>
Line 1: Line 1:
-====== How to use all ESP-01 GPIO pins ======+====== How to use "all" ​ESP-01 GPIO pins ======
  
 ===== Introduction ===== ===== Introduction =====
Line 54: Line 54:
 The solution is to implement a **negative logic** in our code. This means that HIGH voltage on the pin will signify an **"​Off"​** state, whereas a LOW voltage will be the **"​On"​** state. The circuit to implement this method employs a PNP transistor, followed by an NPN transistor. In this example circuit, a relay is driven by GPIO0. When we want to activate the relay, we write LOW to pin 0: The solution is to implement a **negative logic** in our code. This means that HIGH voltage on the pin will signify an **"​Off"​** state, whereas a LOW voltage will be the **"​On"​** state. The circuit to implement this method employs a PNP transistor, followed by an NPN transistor. In this example circuit, a relay is driven by GPIO0. When we want to activate the relay, we write LOW to pin 0:
  
-<​code>​+<​code ​c++>
 digitalWrite(0,​ LOW); digitalWrite(0,​ LOW);
 </​code>​ </​code>​
Line 60: Line 60:
 And when we want to de-activate the relay, we write HIGH. And when we want to de-activate the relay, we write HIGH.
  
-<​code>​+<​code ​c++>
 digitalWrite(0,​ HIGH); digitalWrite(0,​ HIGH);
 </​code>​ </​code>​
Line 66: Line 66:
 Because I try to write code that can be re-used in several projects, I introduce a constant such as **gpioLogic** and the code goes like: Because I try to write code that can be re-used in several projects, I introduce a constant such as **gpioLogic** and the code goes like:
  
-<​code>​+<​code ​c++>
 /* /*
   Set true for a positive logic or false for a negative logic   Set true for a positive logic or false for a negative logic
Line 118: Line 118:
 In terms of software, in order to force pins TXD/GPIO1 and RXD/GPIO3 to operate as I2C pins functioning as SDA and SCL respectively,​ we must set in our code: In terms of software, in order to force pins TXD/GPIO1 and RXD/GPIO3 to operate as I2C pins functioning as SDA and SCL respectively,​ we must set in our code:
  
-<​code>​+<​code ​c++>
 Wire.begin(1,​ 3) Wire.begin(1,​ 3)
 </​code>​ </​code>​
Line 124: Line 124:
 The syntax is: The syntax is:
    
-<​code>​+<​code ​c++>
 Wire.begin(sda_pin,​ scl_pin). Wire.begin(sda_pin,​ scl_pin).
 </​code>​ </​code>​
esp8266/how-to-use-all-esp01-gpio-pins.txt ยท Last modified: 2024/02/02 21:49 by Ilias Iliopoulos