Это видео недоступно.
Сожалеем об этом.
Tutorial: Control Raspberry Pi GPIO via HTTP Web Server
HTML-код
- Опубликовано: 17 авг 2024
- GitHub Repository with code and instructions:
github.com/dav...
🔗 Connect with us:
▶ Need development services? Head over to software-sage.com
▶ Check out our reviews: Software Sage LLC on Google: maps.app.goo.g...
▶ Join our Discord Server: / discord
▶ Connect with me on LinkedIn: / davidrazmadze
▶ Visit my Personal Website: davidrazmadze.com
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 - Intro
0:12 - Overview
1:33 - Things you will need
1:56 - Connect LED to RPi
3:53 - LED program
4:49 - Demonstration
5:08 - Setup HTTP Server
6:39 - Conclusion
Setting up SSH with VSCode: ruclips.net/video/BkQ2hL0fkWM/видео.html
I've been looking for something like this for so long! Thanks a lot! Works like a charm.
Glad it helped!
Very helpful. I have been trying to do similar results using php with mixed results.
Awesome!
you are amazing , you did a good job explaining the video ... thanks for putting a lot of work on it !
Glad it was helpful!
I don't understand where to put that code in. Like is there an editor or something and how do I interface that with the terminal
You need to connect to your device using SSH.
Dude. Great job. Thanks for posting this!
Glad you enjoyed it!
Thanks, easy, but invaluable help to get started with a web interface.
nice demo! Congrats and thank you for sharing your work!
Thanks!
წარმატებები დავით, მადლობა ვიდეოსთვის
არაფრის
como envio datos de un microcontraldor a una url de un servidor rest que esta en la nube?
Very good. I would preffer instead use half video explaining how to connect a led, explain what is the hss conection, how execute it, after explain soooo detailed the led conection, suddenly put a screen editor with code already there, ..... I lost. From where you execute that ?? the raspberry has raspbian ?? what program ??? I am more electronic and had made projects with components and microcontrollers, is for that that the led conection seems so... detailed to me, and I would prefer info about the other things mentioned.
1. ssh connection - a way to connect to raspberry pi through a terminal interface. you can execute commands remotely without having to be physically at the monitor.
2. as long as you are using a Linux Distribution, then it should be executing commands
3. I am using VSCode for the editing the file
If this does not make sense, let me know and I will make a video.
Great video, you just got a new subscriber.
Welcome aboard!
Thank you David. Well done. Subscribed
Thanks for the sub!
Hello sir, is it possible to use this remotely. Using different wifi address and device to access my webserver? I encountered an error my gpio output is not working
Yes if you open it to the internet, you can ssh into it.
Great example. Thanks. how the information from a sensor can be displayed in real time, for example an SR04 so that it keeps updating that information and one does not have to be refreshing or reloading the page. Is there a simple and fast way? Another query, following with the example of an SR04 sensor, which is the simplest way to save the distances received in mysql or another simple database. Where should I add the code in your example of this demo?
Have you come up with a solution?
Thank you, it worked, but I cannot access it from my phone connected to mobile data. How can I do that
That’s because this only works on a local network. That means you need to be on the same WiFi network for it to work from your phone.
If you want to be able to control it from anywhere you would need to open the website to the internet by either port forwarding and making your home router public to the internet. I do not recommend doing this unless you know what you are doing since this opens it up to anyone in the world.
You could setup a vpn connection to your home network by using wire guard and installing wire guard on your phone so that way it looks like you are on your home network. This way is more secure but still open to advanced attacks if there are bugs in the vpn service.
thank you so much
wow, thank you. it was very clear and useful. 💎
You’re welcome
Thank you so much, this is great
You're very welcome!
How do we do this in C or C++. I have ZERO skills nor any interest in PYTHON. To old to learn something new. Started in the 80;s assembler then into C, C++ and others. Just can't get my head around Python.
Pigpio is the library
Is c wrapped in Python, so less Python
Works a treat. Thanks.
You're welcome!
Hey, can i somehow reflect these LED results on my terminal too? in the form of 0/1 maybe.
Yes that would be easy to implement. Did you figure it out?
Good day David, I would like to know with your interface if you turn led on and login with different device does the different device show that the led is currently ON/OFF?
I haven’t tried it myself since it’s been a few years but I’m sure you can get the current status of the LED and display it correctly regardless on which internet device you log in from.
Hey amazing video thanks a lot is it also possible to control dc motors of a car through it i am making a project on opencv so when i detect an object through my laptop the car should move forward to that object.
Yeah you should be able to but I would look into other wireless connections that may have a faster response time. If you don’t care about lag then this might be a good method but I’m not sure. I am no expert in robotics
Thank you very much for this video, it has been very helpful. I was wondering how would you add folders for images and css files? I know nothing about python.
using the “mkdir” command
@@software-sage Thank you for the quick reply. Let me add some more information. So in the web dir with the http_webserver file I have folders called 'images' and 'css'. With in [the def do_get(self): html = '''] html section of the code I have '' and other tags pointing to images. Neither folder is found regardless of the path I put to the folders. I was wondering is there something I must put in the python code to have the folders be recognized or do I need to do this a different way?
@@troythomas5423 it might the way you are accessing the files. try using '../' to go up one folder.
I realize this is out of scope for the video so even if you could point me in the right direction that would be great. Thx.
Hi David, first of all, great presentation!!! Thx for this working/useable project. Now, I now you're busy...but could you help (or point me in the good direction) to get a function in your code to start one of these leds at a certain time?
Look into the time functions in either JavaScript or Python
Hey can you do a tutorial on textfields input from website and display the string to an LCD or just print the string.
Yes I'll put that on my todo list for future videos. Thanks for the input.
How would you accomplish this off grid? Like in a cabin with no ISP/modem/router?
Not sure about that
Does this only work for rpi and computer on same LAN? how would I go about controlling pi remotely over internet on different network, newbie question
Yes this will only work on the same network.
cool job!
Thank you
When I copy the ip address into a web browser, it says that nothing can be found. Could you please advise?
You have to make sure the web server is running. Check the logs it might be different for you.
@@software-sage The web browser says that the IP address didn't send any data. What do you think the problem could be?
I actually figured out what was going on. I was missing two lines of code in the do_get function. Thank you for your help.
Can I control the GPIO pins of Rpi from a hosted website instead of a local server? Also instead of controlling the LED, can I control a DC motor speed from that website? Thanks
Yes you could
Thanks, this could be useful. I use a pi connected with an arduino via serial. As it is now there is a php website on the pi that accepts commands from an android app and sends them serial to the arduino. Also if the arduino detects something it sends serial a command to the pi that reads that with python to send an email. I want to put the php part in the python script. What would be the best way to combine your kind of website with a bidirectional serial in a python script without them blocking each other? Multithreading?
Yes do you know about the multi threading library for Python?
@@software-sage Yes I've heard of it. You also think that is needed to not let them block each other? I can only find seperate instructions of python website or python serial. Not combined. But then I'll experiment with that. Thanks.
What is you ide? With thonny ide I have some errors
Using Visual Studio Code. Highly recommended
@@software-sage but how did you transfer your code to the rpi?
@@Louis-zd2lw using an SSH connection
@@software-sage do you know where I can find a video to setup this?
@@Louis-zd2lw ruclips.net/video/BkQ2hL0fkWM/видео.html
I did it in the same way you have shown but, I am getting the error as the server address is already in use. Can you please help me
You can change the port number in the python program.
what tool to make demo web server?
VSCode for the IDE is enough
Great vid! Whats that IDE you are using?
Vscode
Hi what OS are you running on the Pi ? Can I use Ubuntu or Raspbian ? Can I also use a Raspberry Pi Zero W ?
Yes you can
hey mate i run your program at first and was running fine. after two days i am running it, the server showing that starts normally but when i try to reach the site via the ip address it's not loading at all.
Did your problem get fixed?
@@software-sage yeah, everything fine now
Awesome
hello,
is it posssible to make the samething via a ReactJS application?
thanks for ur help
Yes of course. If you would like I could make a tutorial in the future
Will i need to connect my device to same wifi/network where raspberry pi is for this to work? Or i can open the http even without connection
Yes the computer you are SSH from needs to be on the same network as your raspberry pi. Otherwise this will not work.
You can see if the raspberry pi is up and running by using the ‘ping 10.0.0.x’ command in the terminal
hey amazing video, but how do i control multiple leds with this?
I haven’t done it yet but I can tell you it’s not that much harder than this.
Hi nice sample, I like to add a background on the HTML part but all methode are failing
style="width:960px; margin: 20px auto;">
Welcome to my webserver
Current GPU temperature is {}
Turn LED 18 :
Turn LED 16 :
Make sure you are using the correct CSS styling.
@@software-sage Thanks, can you guide me?
body {
background-image: url('./test.jpg');
background-repleat: repeat-n;
}
this doesnot work
Good job
Thanks
Good afternoon sir, let me ask sir
I have a project regarding the rapsberry pi as well, which is to make a webserver that can later be controlled remotely which can control the system created via an ipv6 local network, the sensors used are pir and ldr using gpio raspbery pi 3 model b. sensor programming used python thonny.
1. Tried webiopi but failed
2. is it necessary to use an additional network card?
3. My python program on raspberry pi can later be controlled like the steps in your tutorial?
thank you
How is the project coming along? Yes you can use a basic HTTP Server to contract a RPi remotely.
Can i do these project in Proteuse??
I have not heard of that... what is that?
Without apache sir?
No need
I can write html directly inside python file?
Yes
@@software-sage wow, u are like the first and only person i see here to do this, most people create html file and render it to python, can i do this on django too?
@@software-sage pls make a video on how to do this on flask or django
Why not use Flask?
You could. This is just the minimal program
Can you please show how to do this with Flask? Problem I'm having with Flask is that I cannot access my Flask server from all devices on my local network. At the very least if you could point me in the right direction of what to read up on, couldn't find much help from the documentation
Hello, how can i control more than 1 gpio?
Yes you can
@@software-sage
how to display GPIO pin status on browser interface
Hi! My server starts but it cannot connect to it... what to do?
Here are some things you can try:
1. Check your raspberry pi IP address
2. Make sure your computer is on the same network as the raspberry pi
3. See if you changed the port number for the web server - should be 8000
4. Use 'nmap' port scanner to see if the port is open on the raspberry pi
Let me know if that ends up working for you.
you totally skipped the part of telling me how to get the files in your github into the raspberry pi on windows using ssh at 5:21
ok i had to search google and i was able to see a test webserver from same wifi ip address but when i went on raspberry's browser and asked google the ip address, it gave an ip address which was forcing me to login to my modem (not my wifi router) so it was not able to get to my raspberry pi through the external ip address. maybe my modem is blocking it.
i can access the sample index file, but how can i access the http_webserver.py? i even tried to do the ./http_webserver.py and it says permission denied. i also did sudo chown pi: http_webserver.py and sudo chown pi: http_webserver to give permissions and it didnt work
also i didnt see where i'm supposed to send the http_webserver.py file using ssh into raspberry pi. when i'm in root i do ls and i see it in the list, its white, white showing that its there but i can only get to the generic index.html and i tried going to local ip/http_webserver.py and that didnt work either
You need to `ssh` into your raspberry pi then use `git` to clone the repository somewhere on your pi.
Please join my Discord (link in description), and message me if you are still having trouble.
HTTTP
*HTTP
When I hear the word PYTHON I go away! Why not a real language, like C or C++!?
i know c c++ and python and to say a real language is misleading to me.. i know what you mean.. its a bit like the arduino ide.. but to complete a project like that with just c is very hard and what interface would you use to have inputs and outputs? with an mct and a grafic touch display with a nice modern looking gui is hard by itself.. lcd button menu is fine but...
The support for Python is pretty large. Doesn’t matter in my opinion as long as the program works
Just annoying you writing on keyboard oh my days
Ok