Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)

30935
134
721
23.01.2021
StevesProjects

StevesProjects

226992
393
6
23.05.2011
US
Описание видео:

Control your Raspberry Pi's GPIO pins on any modern web browser using websockets and Node JS Code at: 🤍github.com/StevesRandomProjects/PiGpioWebServer IMPORTANT NOTES: Do not install node.js via the "apt" package manager. This project will not work if you don't install node manually by downloading from node.js.org instead. Following the instructions exactly except for: 1) Use the 32bit Raspberry Pi OS Desktop WITHOUT recommend software. The full desktop version of OS now includes a version of node preinstalled that will not work with this project. When I originally made this video, the full desktop version did not include node preinstalled. 2) Use a newer version of node. See below to see what versions of node worked for me. As of August 2022, Node JS v16.16.0 with npm v8.11.0 works fine for me. For the most part, the newest version of node work although occasionally you may need to revert to an earlier package if bugs are introduced. I did everything from an ssh connection from my Linux laptop to the Pi so I could film this video. But for those of you that use Windows, you will probably want to attach a keyboard, mouse, and display to your Pi and just do everything local on the Pi instead. Windows doesn't support the X-Windows System so you will probably find that geany does not work via an ssh connection. One thing I have notice lately however is that another version of Node.JS is already installed on the full desktop version of Raspberry Pi OS with recommended software. I now recommend using the Desktop version without recommended software. As far as I can tell, installing another version of Node JS on top of it doesn't cause any issues other than you may have to reboot the Pi before the new version of node is active. So after you install node, check the version. If it reports a different version of node or npm than what you installed, reboot the pi before running the npm init command or installing the npm packages. For those of you who prefer to program in Python or another language, you may want to check out my follow up video 🤍youtu.be/YvsOUkTUsxg that discusses how to interface Node JS to Python and other languages/devices. Others have reported that this project will not work on a Raspberry Pi 2. I myself own a Raspberry Pi model 3B, Model 3B+, Model 4B, Model 400, and Zero2W and have found this demo project works on all of them. While I have gotten this project to work on a Raspberry Pi Zero W (arm 6l) using Node v11, this version of node hasn't been supported for years so with the latest versions of Raspberry Pi OS, node no longer works. You could revert to the same versions of raspberry Pi OS that I specified in the documentation and then it will work. But it will not have any security updates so use at your own risk. As of August 7, 2021, the latest version Node (v14.17.4) and npm (v6.14.14) works on the Raspberry Pi 4. So you no longer need to use Node v12.x. However, if you are using a Raspberry Pi Zero W, you will have to use an even older version of Node and install a few more packages. See updated documentation on my github for special instructions if you are using a Zero W. Update November 27, 2021. The demo project still works with the new bullseye version of Raspberry Pi OS dated Oct 30, 2021. I recommend using the desktop version without recommend software as the full version has a different version of node JS preinstalled. . I have tested node.js v16.13.0 and found it does NOT work. Recommend you now use node v14.17.4 as I know it works. Be sure to reboot the pi after installing node but before running "npm init". For now, stick with 32 bit OS This project will probably not work with the 64 bit versions of Raspberry Pi OS. Update December 26, 2021. I've tested Node JS v16.13.1 with npm v8.1.2 and confirm that both the Raspberry Pi model 3B-Plus and model 4B works with this version of node. Works either with Raspberry Pi Buster or Bullseye OS's. You may consider using this newer version of Node as v12.x is getting quite old now. Update August 15, 2022. I've test Node JS v16.16.0 with npm v8.11.0 and confirmed that the Raspberry Pi Model 4B works with this version of node. I used Raspberry Pi OS 32-bit Desktop (WITHOUT recommend software) "2022-04-04-raspios-bullseye-armhf.img.xz".

Кадры из видео
Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)
Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)
Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)
Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)
Тэги из видео
Комментарии пользователей:
Jesusito Avg
2022-09-07 12:44:06

You know, how can I implement a humedity sensor?
And, can I add a database??

lastnamewhite
2022-08-15 04:36:58

can't get it to work. started getting errors at 'setcap' instruction ... i've never got a websocket program to work so no big surprise here...thanks anyways... you did a great job on the project... i just cant get it to work on my setup

NearlyPhantom
2022-07-04 15:42:29

very helpful tutorial. i just need to combine two gpio pins. can u tell me what to edit in the code to do that?

Amal Amara
2022-05-18 22:28:07

hi thanks for the video but i have a question how can i get the data from my raspberry pi and send them to my website using websockets?(ps my website is hosted on my pc and it's angular js)

Jean-Pierre CATTOOR
2022-04-26 18:27:00

Hello, good tuto that works fine. I would like to start the server at the boot. I can't find how to do it. Can you help me? Thanks in advance

Eduardo Javier Rojas Barragán
2022-04-05 18:58:52

cuando corroe node -v me manda "illegal instruction " y no puedo continuar

Oscar Pantoja
2022-04-01 16:26:34

Really good video! thnaks

Rob Van Moorst
2022-04-01 09:01:46

Good presentation.

Miguel Circ
2022-03-12 09:12:25

Thank you! Great explanation! I’m going to make similar project and its very useful. Instead off control only by buttons or slides, I want to activate relays connects on Raspberry sending orders from another Raspberry or Arduino client.

Bram Recourt
2022-03-11 19:04:43

@stevesprojects, thanks great video! I have some problems running it on raspberry 2 b, or only working on a 4?

Anthony Hattar
2022-01-21 20:50:28

currently only one pin is working (GPIO 26) I cannot get the others to work. Any advice?

Ross Ridler
2022-01-15 16:01:38

very nice video, it was very informative and well presented.
I do have a question for you... is there a reason for the order in which you listed the GPIO ports (26, 20, 21, 16)?
and also is there a way to get the buttons to slide back to the "off" position when the server disconnects or shuts down?

Dániel Pálfi
2022-01-08 22:08:13

Great video with all the files! Can you write down how can I add extra ports to the program? I have already copied the relevant part with the free port number in index.html; main.js; webserver.js but doesn't react.

Marwan Alsouki
2022-01-07 19:51:44

Great presentation thank you

Havbaba
2021-12-21 20:43:57

In webserver.js function(handler) change:
return res.end(content,'utf'); //display 404 on error
to:
return res.end(content,'utf8'); //display 404 on error

This solves the error 404 error ;)

S A
2021-12-18 14:46:58

Anyone knows about a tutorial explaining how to do this with python instead of nodeJS? Thx.

Harish Betrabet
2021-11-24 04:21:53

Nice video, well explained.

ElectroCode
2021-11-18 13:37:29

hello sir,

i'm getting following error after entering node webserver.js

node:events:368
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE: address already in use :::80
at Server.setupListenHandle [as _listen2] (node:net:1334:16)
at listenInCluster (node:net:1382:12)
at Server.listen (node:net:1469:7)
at Object.<anonymous> (/home/pi/downloads/webserver.js:35:6)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1361:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 80
}

Teodor Lopataru
2021-11-15 08:01:36

Nice video. I hope to see more soon. Well explained and easy to follow! Cheers

Что ищут прямо сейчас
хаги ваги в реальной жизни selo skyrim challenge моретв lezioni di fisica america hoy faydalı bilgi HyperX Alloy Core RGB end miui обновление enseñanza world championships open office razer blackshark v2 review wp origami alexis colombo wasafi media луана смешные ролики q.c Home Buyer Remorse
Похожие видео
13.09.2018
A Beginner's Guide to WebSockets

A Beginner's Guide to WebSockets

05.07.2022
WiFi Garage Door Controller | Raspberry Pi Pico W Project

WiFi Garage Door Controller | Raspberry Pi Pico W Project

25.06.2014
µCast #17: Control Hardware Remotely With Socket.IO

µCast #17: Control Hardware Remotely With Socket.IO

15.07.2021
i built a Raspberry Pi SUPER COMPUTER!! // ft. Kubernetes (k3s cluster w/ Rancher)

i built a Raspberry Pi SUPER COMPUTER!! // ft. Kubernetes (k3s cluster w/ Rancher)

09.06.2021
Building the best Raspberry Pi NAS - Wiretrustee SATA

Building the best Raspberry Pi NAS - Wiretrustee SATA

04.09.2020
the Raspberry Pi PHONE SYSTEM! (3CX PBX at home)

the Raspberry Pi PHONE SYSTEM! (3CX PBX at home)

28.07.2020
Control Raspberry Pi LED with Webpage : Using Python and Flask

Control Raspberry Pi LED with Webpage : Using Python and Flask

24.02.2021
Raspberry Pi GPIO Switch Input - Part 3: Writing the Node.js Script

Raspberry Pi GPIO Switch Input - Part 3: Writing the Node.js Script

14.01.2021
Raspberry Pi versus AWS // How to host your website on the RPi4

Raspberry Pi versus AWS // How to host your website on the RPi4

22.04.2021
Control Your Raspberry Pi Remotely Using Your Phone | RaspController

Control Your Raspberry Pi Remotely Using Your Phone | RaspController

15.10.2020
Tutorial: Control Raspberry Pi GPIO via HTTP Web Server

Tutorial: Control Raspberry Pi GPIO via HTTP Web Server

15.09.2020
Python for Beginners - Learn Python in 1 Hour

Python for Beginners - Learn Python in 1 Hour

26.08.2018
A Beginner's Guide to WebSockets

A Beginner's Guide to WebSockets

03.10.2020
Web Server Concepts and Examples

Web Server Concepts and Examples

03.12.2020
I Hacked Into My Own Car

I Hacked Into My Own Car

11.11.2021
Cryptocurrency Mining on a Raspberry Pi (it's fun....trust me)

Cryptocurrency Mining on a Raspberry Pi (it's fun....trust me)

22.09.2019
Old laptop Screens on a Raspberry PI... Yes indeed.

Old laptop Screens on a Raspberry PI... Yes indeed.