Raspberry Pi GPIO Web Control

네오즈 · 2019-09-30 · 5
```html

1. GPIO Web Control Test Circuit Configuration

( The LED lighting circuit used in GPIO output testing is controlled through a web page over the network. )

Red Led : Connected to GPIO 23, Green Led : Connected to GPIO 24

2. Node.js and Express.js Installation

Register Node.js binary repository.

Install Node.js.

Verify Node.js installation.

Verify NPM installation.

Install Express.js.

3. LED Control Node Creation Using Express.js

Install Express.js node application 'led' with '--ejs' option.

Change working path to the generated 'led' node application folder.

Install all node packages that the generated 'led' node application depends on.

Install Raspberry Pi GPIO output node 'onoff'.

app.js

Edit app.js in the generated led node application folder.

Add the following 2 lines highlighted in yellow.

led.js

Create led.js in the routes folder.

Write the following content.

led.ejs

Create led.ejs in the public/views folder.

Write the following content.

4. Node Operation Test

Run the LED control web page.

The LED control web page URL is constructed as follows.

Therefore, the LED control web page URL in this example is "http://192.168.211.104:3000/led". Open this URL in a web browser on a PC, smartphone, etc. connected to the same network as the Raspberry Pi as shown in the figure below.

Click on the hyperlinks on the web page ( Turn On Red, Turn Off Red, … ) to verify that the LEDs connected to the Raspberry Pi are controlled.

```
5
댓글 0
등록된 댓글이 없습니다.