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

Показать описание
Control your Raspberry Pi's GPIO pins on any modern web browser using websockets and Node JS
Code at:
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.
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 video (Pi OS 2020-12-02-raspios-buster-armhf-full) and then it will work. But it will not have any security updates so use at your own risk.
As of August 2022, Node JS v16.16.0 with npm v8.11.0 works fine for me.
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 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.
Code at:
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.
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 video (Pi OS 2020-12-02-raspios-buster-armhf-full) and then it will work. But it will not have any security updates so use at your own risk.
As of August 2022, Node JS v16.16.0 with npm v8.11.0 works fine for me.
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 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.
Комментарии