![StevesProjects](/img/default-banner.jpg)
- Видео 6
- Просмотров 252 601
StevesProjects
США
Добавлен 22 май 2011
Raspberry Pi OTA ATSC Tuner/DVR using Kaffeine and using minidlna to stream video to a Roku player
Use your Raspberry Pi 4 as an over the air ATSC tuner/DVR using Kaffeine to play/record TV stations in the USA. We will also cover using minidlna to stream your videos to a Roku player.
Documentation at:
drive.google.com/file/d/1OX3GrIHotBT_S4UueT-KHIQ7rAPm7e7B/view?usp=sharing
TIMESTAMPS:
00:00 Introduction
01:00 Hardware connections
02:57 Demo of kaffeine DVR software
07:27 Demo of using minidlna to stream videos to a Roku player
08:57 Hardware used in this project
10:10 Raspberry Pi OS version used and initial setup
11:00 Raspberry Pi Configuration
14:18 Mounting hard drive with correct permissions
21:14 Installing Kaffeine software
24:18 Setting up Kaffeine software
29:35 Fixing sound issues
32:29 ...
Documentation at:
drive.google.com/file/d/1OX3GrIHotBT_S4UueT-KHIQ7rAPm7e7B/view?usp=sharing
TIMESTAMPS:
00:00 Introduction
01:00 Hardware connections
02:57 Demo of kaffeine DVR software
07:27 Demo of using minidlna to stream videos to a Roku player
08:57 Hardware used in this project
10:10 Raspberry Pi OS version used and initial setup
11:00 Raspberry Pi Configuration
14:18 Mounting hard drive with correct permissions
21:14 Installing Kaffeine software
24:18 Setting up Kaffeine software
29:35 Fixing sound issues
32:29 ...
Просмотров: 2 152
Видео
Web server with WebSockets for other programs/devices (e.g. Python) on Raspberry Pi using Node JS
Просмотров 8 тыс.3 года назад
This is a follow up video to my "Web server to control GPIO on a Raspberry Pi with websockets" video. It demos using a UDP communication link in NodeJS to talk to other programs (e.g. Python) and devices. It also demos using a embedded video camera link, analog sliders, and text input/output in the browser. Video on how to install Node JS at: ruclips.net/video/TVxQROFPjy0/видео.html Code and do...
Web server to control GPIO on a Raspberry Pi with websockets (see description for important notes)
Просмотров 49 тыс.3 года назад
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...
Using pkexec instead of gksudo on a Raspberry Pi 4
Просмотров 1,1 тыс.5 лет назад
gksudo has be depreciated in the latest versions (July 2019) of Raspbian. This video shows you how to use pkexec instead to run gui applications as root via an ssh terminal. My references for this video were from: unix.stackexchange.com/questions/203136/how-do-i-run-gui-applications-as-root-by-using-pkexec and askubuntu.com/questions/799669/etc-sudoers-file-corrupted-and-i-cant-run-pkexec-visud...
Fixing an overheating Sony VPC-F11KFX/B laptop and keyboard replacement
Просмотров 5 тыс.10 лет назад
Fixing an overheating/noisy fan Sony Vaio VPC-F11KFX/B laptop and removing the keyboard.
Replacing a bathtub drain with corroded/broken cross members
Просмотров 187 тыс.12 лет назад
This is my own experience of replacing a bathtub drain with corroded cross members in my house. It was something I pondered on how to do for several week. After being successful, I though I would share my experience. I know there is a few spots where the camera drifts off focus. But once I had it fixed, I wasn't going to refilm it. YMMV.
Can I connect with arduino?
I tried to follow this tutorial and it has not be successful for me, I am not sure what is wrong but when trying to run the node webserver.js command i get a node:fs:2346 return binding.writeFileUtf8( ^ Error: EINVAL: invalid argument, write message and I have tried to fix the code with no success. Any suggestions?
Can i send other numbers then 1 or 0, bc i want to control a rgb stripe with a slider
Hi, Thanks for yours videos. I tried to implement your solucion in a Raspberry pi 3B, and i have problem when i execute you webserver.js.Do you know where is the problem: node:fs:2342 return binding.writeFileUtf8( ^ Error: EINVAL: invalid argument, write at Object.writeFileSync (node:fs:2342:20) at exportGpio (/home/losvolaos/webserver/node_modules/onoff/onoff.js:18:8) at new Gpio (/home/losvolaos/webserver/node_modules/onoff/onoff.js:172:36) at Object.<anonymous> (/home/losvolaos/webserver/gpio/webserver.js:7:13) at Module._compile (node:internal/modules/cjs/loader:1368:14) at Module._extensions..js (node:internal/modules/cjs/loader:1426:10) at Module.load (node:internal/modules/cjs/loader:1205:32) at Module._load (node:internal/modules/cjs/loader:1021:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) at node:internal/main/run_main_module:28:49 { errno: -22, code: 'EINVAL', syscall: 'write' } Node.js v21.7.2
Difficult so say why it is not working for you. I just installed the ARM 64 bit version on an Raspberry Pi 4 running Raspberry Pi 64 bit OS back a week or two ago and didn't have issues. But the most common reason for the project not working is are: 1) A binding error is usually caused by some other service already running on you Pi that is already using port 80. Be sure to start with a clean installation to ensure no other web servers are running on your pi. 2) You tried to install node via the apt packet manager. Be sure to read the video description and the pdf on my github and following the instructions exactly. 3) The latest version of node may have a bug in it. Installing the previous major release will usually work when that happens. In particular, I would try v20.12.1(LTS). 4) I know the 32 bit version of Node JS has work on the Pi3B running 32 bit OS in the past. However I have not tried it with the 64 bit version so I cannot say for sure the 64 version works with the Pi3B
@@highfidelityinc Thank you very much for the answer, I have a 64-bit Raspberry pi 3B. Is the latest version of your project on github or how can I access it? It seems that the problem occurs when accessing the onoff program. If you would like to help me I would love to have your help. Thank you so much!!
@@franciscojaviernunez8191 Sorry, I have not idea why you cannot get it to run other than what I already mentioned. Of course if you are using a 64 bit OS, you need to use the 64 bit arm version of Node. It could be that the Pi3B just will not run the 64 bit version of node. Like I suggested, start with a clean install of the lite or basic desktop 32 bit OS and install absolutely no other software. Use long term support version (LTS) of node and do not update Node if it says there is a update -- many times that will break node. If that doesn't work, it could be a case like the original raspberry Pi zero W being too old to run the latest version of node. In which case you will have to use a very old version of Raspberry Pi OS and a very old version of Node.
@@franciscojaviernunez8191 Did you ever get this working? I am also getting the same error on both my Pi 2B and Pi 4B, have tried multiple versions of nodejs and different OS (32 and 64 bit versions)
I managed to get it working on a legacy OS, it looks like something in the latest OS has changed pin numbers and onoff no longer works
Hi, very nice projet. Can you tell me if that could be the way to go for me? I need a local web server (no internet access) that would constantly refresh a page that would show my total energy use of my house. I already wrote the python software that shows the energy on the pi itself but I wish to convert it to web server.
I have a follow up video the explains one method of interfacing a Python program to a node JS web interface. ruclips.net/video/YvsOUkTUsxg/видео.html This video is running two programs. The first is a python program that controls the GPIO and the second is a Node JS program to serve up the web pages. I cover how the interface between the two programs works. It also demo's other types of web interfaces such as gauges and text boxes although it is up to you to write the python code to control them.
@@highfidelityinc thanks.
Hello, how can we take the value from a DHT 11 connected to PI3 and display it in an text next to the buttons?
Hello, how can we make this file xx run automatically every time node webserver.js is opened?
I am not sure exactly what you are asking. If if you are asking how to start the node webserver.js automatically, refer to the last section of the pdf documentation that is included in my github link at the top of the video description.
@@highfidelityinc I'm sorry I didn't see it. Thanks
hey Steve, nice video! . One question, it this gone work on the PI itself in the browser? So if I connect the screen to the pi and run browser in kiosk mode it will give me gui ?
You most certainly can connect a screen to the pi and run in kiosk mode while node is running in the background on the same pi. For the web address you type in your web browser, you would use the loopback address which would be either localhost or 127.0.0.1
Thanks for replying, much appreciated!
Does this only work while on the same network?
This project will work across subnets. So the web interface will work on other networks as long as the network equipment doesn't have any firewall rules to block that traffic.
December 2023 - Thanks for this video and the example files.. I tried all of this yesterday on a Raspberry Pi Model 3B and it all worked. I tried installing the latest version on NODE.JS but I could not get NODE.JS or NPM to correctly install then return their version numbers. I don't know if this is the problem you were encountering. I was able to make it work with NODE.JS version: " node-v18.19.0-linux-armv7l.tar.gz " so I'm happy with that. I'm planning on using a high (above port 1024) port number so I may not need the capability that " libcap2-bin " provides. I then played with / tweaked the stylesheet a bit and again the framework you provided was very helpful. Now to expand on all of this since I want digital inputs in addition to the digital outputs, so I'm going to try working on adding that next. Thanks again.
Glad it worked out for you. Yes, sometimes the latest version of Node has a bug and you have to revert to an earlier version. Usually happens when they first release a new major version.
Thanks Steve 🤗 very insightful video! quick question, Any clue on how I can do the same using java springboot framework?
Sorry. I am not familiar with java springboot framework. Perhaps someone else who reads this can answer your question.
If you use Tailscale you can control this from anywhere in the world. You can also put a domain name to log straight in to the control page, all for free. I want to ask where I can download your code? I did similar project but your implementation is much better then mine :) Please share if you want to!
Look at the video description. The link to the code is near the top of the description. There are many ways to do remote access. I myself have an OpenVPN server built into my router. No cloud service required so I never have to worry about the cloud server going away someday.
HI Steves, thank you, well explained. Great project i do that and works fine. But I need one think for you, I need to put that on startup because i dont have monitor to see what happen, do you have something our do you now something to do that? Thanks
Good to hear you found the video useful. In terms of your question, I personally prefer to use System-D to start programs automatically. I just downloaded a new updated document to my github that explains how to add a System-D process to start node JS automatically. See the last section of the document at github.com/StevesRandomProjects/PiGpioWebServer/blob/main/GPIO%20Webserver%20for%20Raspberry%20Pi%202023-07-15.pdf
@@highfidelityinc works fine, thanks. I make same code upgrades, activated a bottom sequencing.
Thank you so much 4 this! MAGNIFICENT!!!MUCH NEEDED!! EXCELLENT 👌🏻👍🏽👌🏻
You're so welcome!
Never been more excited for an hour long video in my life
Glad you found it interesting.
Does anybody know how to use node js in aarch64
This is a great project. I am trying to add the server clock to the webpage but am not able to get it to work sending a message via python? Any ideas? I've tried to send: CLOCK = datetime.datetime.now().strftime('%a, %b %d %Y, %H:%M:%S') sockTX.sendto(({"S3":"CLOCK"}), "utf-8"),(UDP_TX_IP, UDP_TX_PORT) but I seem to be getting nowhere. Kepp getting errors like 'not dict" If you have any ideas it would be appreciated.
Hi! This video is wonderful ,it has a nice presentation and a very good documentation ,you did a very nice job explaining everything. I have a question , I'm trying to automate this site (to auto start the server , with the pi powers on ), I tried creating a service .... long story short it's not working() , I tried rc.local it's not working either, I'm stuck at this banal problem for like 3 days . How would you do this ? I'm still trying with services but i don't even know if it's possible ,I'm not very experienced with Linux , but I'm not new either.
Glad you found the video useful. In terms of your program not auto starting, my guess you are starting node before some service is available (such as the network adapter), you don't have your working directory pointed to the ~/webserver/gpio directory, or you are using a user other than pi when you start the node program. My prefer method of auto starting a program is SystemD. Sparkfun has excellent tutorial on auto starting a program. SystemD is one of the methods they discuss. learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/all The main advantages of using SystemD are: 1) You can have system D automatically restart the program if it crashes. 2) You can specify to start the program only after certain processes, such at the network adapter, are available. 3) You can use systemD to check the status of the process and it will give you some error information if the process fails. Here is a .service file that I find works for me to auto start node. [Unit] Description=webserver service After=network.target [Service] ExecStart=node /home/pi/webserver/gpio/webserver.js WorkingDirectory=/home/pi/webserver/gpio StandardOutput=inherit StandardError=inherit Restart=always User=pi [Install] WantedBy=multi-user.target You might want to look at the "Installing Kaffeine software" section my video "Raspberry Pi OTA ATSC Tuner/DVR using Kaffeine and using minidlna to stream video to a Roku player". I used SystemD to start Kaffeine because I could delay starting the program until the hard drive was ready.
Thanks a lot.. I'll give it a go..
You're welcome.
Silver banded resistors. Family heirloom? :) Great content. Exactly what people need to 'hello world' this type of project. So many possibilities come into view.
Hey Steve, thanks for the tutorial! I was wondering. Will this also work over 4G/5G or only when on the same Wifi network?
The 4G services that I have seen or used have all been behind some type of firewall or nat. 5G is probably the same. To access remotely, you will probably have to set up a remote server that has a public IP and then create a link between your 4/5G device and the remote server. One way to do that is to set up an OpenVPN server on your remote server and an OpenVPN client on the devices that is on your 4/5G network. Essentially you will be creating your own cloud service.
@@highfidelityinc i think "web rtc" could be a solution.
Sorry for the late response -- been busy at work. I haven't used "web rtc" but just quick look at it appears it is some type of cloud service. So yes if you want to use it, go for it. For myself, I wouldn't consider it because it is just too easy to set up my own service. Every cloud service I have used has eventually failed -- be it a change in terms and condition, a change in the protocol, a data breach, going out of business, or etc.
Ok I found it, In plane sight. Silly me. Thanks for the help.
Glad I could help
Hey? Where is the build/install instructions you mentioned? I don’t see them any where in the Git download?
It is right there at the top of the video description and I just confirmed it still works. Here is again: github.com/StevesRandomProjects/PiGpioWebServer
i fixed my problem. was something wrong with my user account setup.
Good to hear you figure out your issue.
I am having an odd problem, the switches are not switching and just acting like momentary buttons, and sends the commands "GPIO26T":1 and then 0. Any ideas? Using node ver 16.17.1, maybe I need to downgrade?
I haven't seen the particular symptom you are describing. Every 6 months are so, I do test the demo with the latest versions of Raspberry Pi OS and node JS and post what works and does not on the first video I made on GPIO control from a pure Node JS implementation. So you may want to look at the show notes in that video description. Here is an excerpt from that video description: 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". You might want to try those versions instead. The next time I set up a Pi, I will test the demo with the latest versions of Raspberry Pi OS and node. Those notes have other information for different versions of Pi. In particular, if you are using the original Raspberry Pi Zero W, you must use a very old version of Raspberry Pi OS and Node JS as specified in the show notes. I have not tested the demo with the 64 bit version of Raspberry Pi OS yet. But more likely, you have a previous txrx.py still running in the background when you run the txrx.py python program. You can search if you have multiple txrx.py processes running using htop and then kill it from there. However the easiest thing to do is just reboot the pi as that will kill orphan processes. I might note that the Python txrx.py program ignores the {"GPIO26T":0}. If the python program is receiving a single {"GPIO26T":1 } command for each press of the toggle button, it would be kind of hard for the button to act as a momentary button. However, if you are getting two {"GPIO26T":1} for each press, well yes that would cause the LED to come on and then back off again. It is only the {"GPIO26M":0} signal that should cause the LED to go off when the button is released.
@@highfidelityinc trying to investigate it further, I found the function is working correctly, its the switch in the html that doesn't always go blue and back. If i click, hold, and drag it I can sometimes get it to work right.
hey your video is out of focus here on my tablet
Looks fine on my computer monitor. Your tablet probably does not have enough resolution or its internet speed is too slow. Watch on a 1080p monitor and ensure you are streaming in 1080P mode. It should be clear then.
how/where is js calling the python functions to run?
Communication between the webserver.js node program and the txrx.py python program is done by a UDP loopback socket connections between the two programs.
You know, how can I implement a humedity sensor? And, can I add a database??
For a humidity sensor, I would use an off the shelf sensor that interfaces easily with the Pi. Search for humidity sensors on Mouser or DigiKey. I am using a Mouser 403-SHT40-AD1B-R2 temperature/humidity sensor on another project. It has an I2C interface that should work in the Pi's GPIO I2C pins. However this sensor is tiny. You will have to make a custom PCB and then mount the sensor using a hot plate, reflow oven, or hot air station. There is a I2C module in npm although I have not used it yet -- so I don't know if it works. Or you could use a Python I2C module and send that data to node (see my follow up video). For a database, something like MariaDB SQL database should work. But details on how to do both of these is way more involve that what I can describe in just a few lines. Good luck.
hey Steve. do you have a video showing how to install netcat and get it running? I'd like to replicate this project exactly as you have presented it but as you know from my attempt on the last project, im weak on Linux. Are you running netcat on your laptop or on your pi? thanks again
In your case, it would better to run netcat on your Raspberry PI instead since netcat is install by default on the Raspberry Pi. You can even do it through an ssh connection if you prefer -- no X-Window support is required for netcat. However, if you look at the documentation, you want to execute following command instead if you are running netcat on the same Pi has your node server. netcat -u 127.0.0.1 3000 -p 3001 Make sure you have started the webserver first with node ~/webserver/webgui/webserver.js Also make sure the Python3 txrx.py example program is not running at the same time since both cannot use the same port at the same time. The main purpose of this example was to give you a framework where you can use Node as a front end webserver for another program such as Python. So I include text boxes, different types of buttons, and sliders in the node webserver side to demo the interface. The python program only implements the 4 GPIO LED interfaces as was in the first video. Good Luck, Steve
@@highfidelityinc I really like the idea of using Python and Node together. I have a lot of Python code that communicates though serial or bluetooth etc. would be great to move some of that over to websockets. thanks again for working with me.
Good to hear you got it working.
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
To confirm that this project still works, I just tested this demo project and found it still works with the latest software and hardware. I am using the following: 1) Raspberry Pi Model 4B 2) 32 bit Raspberry Pi OS version "2022-04-04-raspios-bullseye-armhf.img.xz" (Desktop WITHOUT recommended software). 3) Node JS v16.16.0 with npm v8.11.0 (do not updated to a newer version of npm when you run 'npm init'") I suggest you use the same hardware and software as above, start with a clean install and do not install anything else, and follow the instructions very carefully. Also be sure to look at the video description as I post updates on what works and what does not there. Good luck, Steve
@@highfidelityinc i've got a Raspberry Pi Model 3B+ maybe that's the difference. I've tried other tutorials but always run into a snag. w3schools has one very similar to yours... I get to the last page and it stops working... havent figured out why.
The Raspberry Pi Model 3B+ should be fine. Any Pi with an arm7l processor will probably work. I have both a Model 3B and 3B+ and never had issues with running node JS on them. Do NOT use the raspberry Pi OS desktop with recommended software -- Starting about a year ago, that version comes with another version of Node JS that will mess up your setup. All the setcap command does is allow node to use port 80 without running node as a root user. Be sure to use sudo with netcap command. You don't need to use the setcap command if you use any port over 1024 for the webserver port.
@@highfidelityinc thanks. I'm goin to be trying again. I followed the pdf but i guess i'm missing something. I really dont mind using 8000 or whatever port number for now, just like to get it working then figure out the details and changes
If I had to make a guess, I would say "setcap" command did not work for you because you did not install node in the proper directory. That could be because you tried to install Node via the "apt" package manager instead of downloading from Node JS from node.js.org. I made that mistake the first time I tried to use node. When you use "apt", it will put node in different directories. I could never get node to work from the "apt" package manager. Do not deviate from the instructions other then using a newer version of node and using the raspberry pi desktop without recommended software.
very helpful tutorial. i just need to combine two gpio pins. can u tell me what to edit in the code to do that?
If they released a Pi TV Hat in ATSC, would you have used that instead of the Hauppauge?
You are 100% correct -- I would probably have purchased a Pi TV Hat instead of they had a ATSC version. But the Hauppauge works just fine and I can use it with other platforms too. I have recently replace the Pi4 with a Pi400 because there have been times where a keypad would have been handy. All I had to do is move the SD card and USB devices over to the Pi400 and it worked first boot. It would have been a little more difficult to use a hat with the Pi400.
@@highfidelityinc I was just in contact with somebody that’s involved in the manufacturing of the TV HAT. They told me the ATSC version will be released soon. If it does, would you keep your project the same or switch over?
@@RadiationNeon No I probably wouldn't buy the Pi ATSC hat if they came out with one. What I have works well and the Pi hat may not be as good. Plus I prefer a USB tuner over a Hat. You know the old saying, "If it works, don't fix it".
@@highfidelityinc thank you for your responses. I’m planning to make a handheld television in the future using the pi. All the best.
wish they make the ATSC hat. i would be in heaven. the 3.0 is really killing me on the plex version. can't record 3.0 but i get later in day from a 1.0 channel. so it's good
This guy is awesome, sure to achieve all goals of his life
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)
Sorry, I know very little about angular other than it is a framework developed by Google. And using websockets to communicate to another web server is way beyond the scope of this video. However, you may want to watch my follow up video where I have a demo program that uses a simple UDP connection to talk to another program.
@@highfidelityinc yes I'll watch it thank you❤
I have the demo running with the latest Node version 16.15 on Pi4b running Bullseye and it all works fine. My question is, I need to add a physical switch (bridging pins 12 and Gnd that will activate pin 21. So basically have a switch on the website on my screen in my van that activates a light and a switch in my cab that will activate the same light (and show up on the screen it is active. Is this possible. I would save me installing another pi and screen on my dash just to activate the light Thanks for all your work and for sharing
Hi John. You may want to look at www.npmjs.com/package/onoff . It has example code on how to trigger on a GPIO input and then then use that input to turn an LED on and off on another output. This would be a pure node JS solution and it is event driven so no need to constantly poll the GPIO input. I am sure there is a way to do it in Python too, but right off hand, I don't have an example I can point you too. Good luck.
@@highfidelityinc THanks for the reply and suggestion Steve. Really appreciate it
Nice work! Wonder if this setup can be integrated with the Kodi TV media server. Keep up the good work.
Glad it help. Sorry I haven't tried Kodi yet so I don't know the answer to your question.
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
There are many ways that you can start a program automatically. Sparkfun.com has a great write up on the different ways to start a program automatically at learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/all . My preferred method is via a SystemD process. If you are interested in using SystemD, you might look at the video I posted a few months ago on a Raspberry Pi OTA ATSC DVR. In that video I discuss how to start Kaffeine and MiniDNLA automatically using SystemD.
cuando corroe node -v me manda "illegal instruction " y no puedo continuar
Really good video! thnaks
You're welcome!
Good presentation.
Glad you liked it!
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.
Glad it was helpful!
Can this run in a docker container on a pc?
Hard to say if it will work in a docker container on a pc as I don't have much experience with dockers. But if your package manager has Kaffeine and miniDLNA in their repositories and your docker has direct access to the USB ports, it may work.
@stevesprojects, thanks great video! I have some problems running it on raspberry 2 b, or only working on a 4?
Others have reported the earlier versions of the Pi do not work. So you will probably have to upgrade your Pi. I have tested the project on the Raspberry Pi models 4B, 3B+, 3B, and Zero W and it will work on those models. The first three use an arm7l processor which is still supported. The Zero W however uses an arm 6l processor which is not supported by newer versions of Node JS.
thank for ur video.Can you teach me how to add videos(stream LED) to website like you pls!
If you look at the documentation for this video on my Github page, there is a section called "MotionEyeOS camera software" that discusses how you can duplicate streaming video like I did in the video. If you want to use a camera on the same raspberry as the node js web server, take a look at randomnerdtutorials.com/video-streaming-with-raspberry-pi-camera/ . Then in the index,html file for node JS, change the line with the tag, to point to your pi using port 8000. Good luck
Thank you Steve! You have just saved my 3rd year project
Glad to help!
currently only one pin is working (GPIO 26) I cannot get the others to work. Any advice?
Hard to say. If you are using a HAT, it may be interfering with some of the GPIO pins or you may have another process that is using the same pin. Those types of things have bite me in the past.
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?
No particular reason why I chose GPIO ports 26, 20. 21, and 16 and in that order other than they are all on one end of the Pi's 40 pin header and were easy to locate and connect. Right off hand I don't know a way to have the buttons to slide back to off when the server disconnects. However, one possible way to do it is write a client side JavaScript procedure to ping the server every few seconds. If the server fails to respond after so many pings, use that same JavaScript procedure to turn all the switches off. Another way is to write a client javascript procedure to refresh the page every so many seconds -- the issue though is if the server is offline, your web browser with come back with a message that the page cannot be found rather than keeping the web page open.
I appreciate your response. I was truly wondering about your choice and sequence of the GPIO pins, I do see that the location of the pins make your choice a good one. The first switch does turn off but the other 3 switches don't and that may be because the exit command completes too quick. I have tried to use a script to have the exit command pause so the switches have the time to shut off with no success. Maybe you could figure out something, I would be grateful for the help.
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.
Okay I was curious myself if you could run two node JS servers at the same time. And yes it does work. But instead of trying to combine both webservers into one webserver.js file, create a separate a second node JS server (e.g. webserver.js and webserver2.js) and start them both. Just make sure to use a different port for webserver2.js. I have webserver.js running on port 80 and webserver2.js running on port81. Both are running the same gpio example program except I changed the port number in webserver2.js to port 81. However, this gpio example program does not check if the state of the GPIO pin when changes from an external program (e.g. the other webserver). So when you change the state of the GPIO from webserver.js, it does not reflect that changed in webserver2.js. But both can and do change the state of the GPIO pin. You would have to add some add code if you want to keep the GPIO in sync in both programs -- I haven't tried that yet so you will have to figure this aspect on your own.
Great presentation thank you
Glad it was helpful!
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 ;)
Good catch. I have updated the code to correct the error. I should note that it looks like the error will only occur if you try to access a web page that does not exist. Thanks for finding this error.
Indeed, that's the case. Otherwise a very good and helpfull video! Love it and learned a lot about this in just 1 video!