Это видео недоступно.
Сожалеем об этом.

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

Комментарии • 133

  • @software-sage
    @software-sage  3 года назад +2

    Setting up SSH with VSCode: ruclips.net/video/BkQ2hL0fkWM/видео.html

  • @toms3159
    @toms3159 2 года назад +3

    I've been looking for something like this for so long! Thanks a lot! Works like a charm.

  • @tedsykora1858
    @tedsykora1858 3 года назад +1

    Very helpful. I have been trying to do similar results using php with mixed results.

  • @theunfinishedbusiness2407
    @theunfinishedbusiness2407 3 года назад +2

    you are amazing , you did a good job explaining the video ... thanks for putting a lot of work on it !

  • @vihaanravishankar3989
    @vihaanravishankar3989 Год назад +1

    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

    • @software-sage
      @software-sage  Год назад

      You need to connect to your device using SSH.

  • @greatjobbuddy
    @greatjobbuddy 3 года назад +1

    Dude. Great job. Thanks for posting this!

  • @y2ksw1
    @y2ksw1 2 года назад

    Thanks, easy, but invaluable help to get started with a web interface.

  • @goldenpacificmedia
    @goldenpacificmedia 2 года назад +1

    nice demo! Congrats and thank you for sharing your work!

  • @iliadzidzishvili7500
    @iliadzidzishvili7500 3 года назад

    წარმატებები დავით, მადლობა ვიდეოსთვის

  • @SaysAnX
    @SaysAnX Год назад

    como envio datos de un microcontraldor a una url de un servidor rest que esta en la nube?

  • @345rvv
    @345rvv 3 года назад +1

    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.

    • @software-sage
      @software-sage  3 года назад

      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.

  • @zeno6991
    @zeno6991 3 года назад +1

    Great video, you just got a new subscriber.

  • @daverei1211
    @daverei1211 2 года назад

    Thank you David. Well done. Subscribed

  • @ChylleSuu
    @ChylleSuu 8 месяцев назад

    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

    • @software-sage
      @software-sage  8 месяцев назад

      Yes if you open it to the internet, you can ssh into it.

  • @javiersalazarcastro9188
    @javiersalazarcastro9188 3 года назад

    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?

  • @mertbacaksz6565
    @mertbacaksz6565 5 месяцев назад

    Thank you, it worked, but I cannot access it from my phone connected to mobile data. How can I do that

    • @software-sage
      @software-sage  5 месяцев назад +1

      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.

  • @mohamedsalaad5611
    @mohamedsalaad5611 4 месяца назад

    thank you so much

  • @reza_amd
    @reza_amd 3 года назад

    wow, thank you. it was very clear and useful. 💎

  • @hollyschlichting4462
    @hollyschlichting4462 3 года назад +1

    Thank you so much, this is great

  • @dalesmith8666
    @dalesmith8666 6 месяцев назад

    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.

    • @philwildman1660
      @philwildman1660 4 месяца назад

      Pigpio is the library
      Is c wrapped in Python, so less Python

  • @Justin-ju8ef
    @Justin-ju8ef 3 года назад

    Works a treat. Thanks.

  • @prithvirajp4066
    @prithvirajp4066 3 года назад +1

    Hey, can i somehow reflect these LED results on my terminal too? in the form of 0/1 maybe.

    • @software-sage
      @software-sage  2 года назад

      Yes that would be easy to implement. Did you figure it out?

  • @reevince9942
    @reevince9942 Год назад

    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?

    • @software-sage
      @software-sage  Год назад

      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.

  • @yotte8846
    @yotte8846 Год назад

    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.

    • @software-sage
      @software-sage  Год назад

      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

  • @troythomas5423
    @troythomas5423 3 года назад +1

    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.

    • @software-sage
      @software-sage  3 года назад

      using the “mkdir” command

    • @troythomas5423
      @troythomas5423 3 года назад

      @@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?

    • @software-sage
      @software-sage  3 года назад

      @@troythomas5423 it might the way you are accessing the files. try using '../' to go up one folder.

    • @troythomas5423
      @troythomas5423 3 года назад

      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.

  • @robbals3173
    @robbals3173 3 года назад

    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?

    • @software-sage
      @software-sage  2 года назад

      Look into the time functions in either JavaScript or Python

  • @meliocurie1809
    @meliocurie1809 2 года назад

    Hey can you do a tutorial on textfields input from website and display the string to an LCD or just print the string.

    • @software-sage
      @software-sage  2 года назад

      Yes I'll put that on my todo list for future videos. Thanks for the input.

  • @ssj4naka
    @ssj4naka Год назад

    How would you accomplish this off grid? Like in a cabin with no ISP/modem/router?

  • @jackclark4968
    @jackclark4968 2 года назад

    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

    • @software-sage
      @software-sage  2 года назад +1

      Yes this will only work on the same network.

  • @samzhao1300
    @samzhao1300 3 года назад +1

    cool job!

  • @ayushbanerjee1187
    @ayushbanerjee1187 Год назад

    When I copy the ip address into a web browser, it says that nothing can be found. Could you please advise?

    • @software-sage
      @software-sage  Год назад

      You have to make sure the web server is running. Check the logs it might be different for you.

    • @ayushbanerjee1187
      @ayushbanerjee1187 Год назад

      @@software-sage The web browser says that the IP address didn't send any data. What do you think the problem could be?

    • @ayushbanerjee1187
      @ayushbanerjee1187 Год назад

      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.

  • @asifimrankhan5606
    @asifimrankhan5606 2 года назад

    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

  • @davidverheyen6635
    @davidverheyen6635 2 года назад

    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?

    • @software-sage
      @software-sage  2 года назад

      Yes do you know about the multi threading library for Python?

    • @davidverheyen6635
      @davidverheyen6635 2 года назад

      @@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.

  • @Louis-zd2lw
    @Louis-zd2lw 3 года назад +2

    What is you ide? With thonny ide I have some errors

    • @software-sage
      @software-sage  3 года назад

      Using Visual Studio Code. Highly recommended

    • @Louis-zd2lw
      @Louis-zd2lw 3 года назад

      @@software-sage but how did you transfer your code to the rpi?

    • @software-sage
      @software-sage  3 года назад

      @@Louis-zd2lw using an SSH connection

    • @Louis-zd2lw
      @Louis-zd2lw 3 года назад

      @@software-sage do you know where I can find a video to setup this?

    • @software-sage
      @software-sage  3 года назад

      @@Louis-zd2lw ruclips.net/video/BkQ2hL0fkWM/видео.html

  • @dsahara7759
    @dsahara7759 3 года назад

    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

    • @software-sage
      @software-sage  3 года назад

      You can change the port number in the python program.

  • @panduwilantara3070
    @panduwilantara3070 Год назад +1

    what tool to make demo web server?

  • @robertjohnsoniii8067
    @robertjohnsoniii8067 6 месяцев назад

    Great vid! Whats that IDE you are using?

  • @infusion123
    @infusion123 Год назад

    Hi what OS are you running on the Pi ? Can I use Ubuntu or Raspbian ? Can I also use a Raspberry Pi Zero W ?

  • @themisk.3843
    @themisk.3843 2 года назад

    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.

  • @elyesachour6333
    @elyesachour6333 3 года назад

    hello,
    is it posssible to make the samething via a ReactJS application?
    thanks for ur help

    • @software-sage
      @software-sage  2 года назад +1

      Yes of course. If you would like I could make a tutorial in the future

  • @Marc-mp6lf
    @Marc-mp6lf 3 года назад

    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

    • @software-sage
      @software-sage  3 года назад

      Yes the computer you are SSH from needs to be on the same network as your raspberry pi. Otherwise this will not work.

    • @software-sage
      @software-sage  3 года назад

      You can see if the raspberry pi is up and running by using the ‘ping 10.0.0.x’ command in the terminal

  • @therplayer1291
    @therplayer1291 Год назад

    hey amazing video, but how do i control multiple leds with this?

    • @software-sage
      @software-sage  Год назад

      I haven’t done it yet but I can tell you it’s not that much harder than this.

  • @robvanmoorst3179
    @robvanmoorst3179 2 года назад

    Hi nice sample, I like to add a background on the HTML part but all methode are failing

    • @robvanmoorst3179
      @robvanmoorst3179 2 года назад

      style="width:960px; margin: 20px auto;">
      Welcome to my webserver
      Current GPU temperature is {}
      Turn LED 18 :


      Turn LED 16 :

    • @software-sage
      @software-sage  2 года назад

      Make sure you are using the correct CSS styling.

    • @robvanmoorst3179
      @robvanmoorst3179 2 года назад

      @@software-sage Thanks, can you guide me?

    • @robvanmoorst3179
      @robvanmoorst3179 2 года назад

      body {
      background-image: url('./test.jpg');
      background-repleat: repeat-n;
      }

      this doesnot work

  • @arduinochannel2592
    @arduinochannel2592 2 года назад

    Good job

  • @julianaastrindaputri2424
    @julianaastrindaputri2424 2 года назад

    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

    • @software-sage
      @software-sage  2 года назад

      How is the project coming along? Yes you can use a basic HTTP Server to contract a RPi remotely.

  • @omgdog764
    @omgdog764 3 года назад

    Can i do these project in Proteuse??

    • @software-sage
      @software-sage  2 года назад

      I have not heard of that... what is that?

  • @gustihkpbjt53
    @gustihkpbjt53 Год назад

    Without apache sir?

  • @gbengaoyede2877
    @gbengaoyede2877 2 года назад

    I can write html directly inside python file?

    • @software-sage
      @software-sage  2 года назад +1

      Yes

    • @gbengaoyede2877
      @gbengaoyede2877 2 года назад

      @@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?

    • @gbengaoyede2877
      @gbengaoyede2877 2 года назад

      @@software-sage pls make a video on how to do this on flask or django

  • @deymonster2u
    @deymonster2u 3 года назад +1

    Why not use Flask?

    • @software-sage
      @software-sage  3 года назад

      You could. This is just the minimal program

    • @siobe0
      @siobe0 3 года назад

      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

  • @thangtrong9457
    @thangtrong9457 2 года назад

    Hello, how can i control more than 1 gpio?

    • @software-sage
      @software-sage  2 года назад +1

      Yes you can

    • @hoangtien6349
      @hoangtien6349 2 года назад

      @@software-sage
      how to display GPIO pin status on browser interface

  • @jamcof
    @jamcof 3 года назад

    Hi! My server starts but it cannot connect to it... what to do?

    • @software-sage
      @software-sage  3 года назад

      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.

  • @cryptoworldgames
    @cryptoworldgames 2 года назад

    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

    • @cryptoworldgames
      @cryptoworldgames 2 года назад

      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.

    • @cryptoworldgames
      @cryptoworldgames 2 года назад

      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

    • @cryptoworldgames
      @cryptoworldgames 2 года назад

      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

    • @software-sage
      @software-sage  2 года назад

      You need to `ssh` into your raspberry pi then use `git` to clone the repository somewhere on your pi.

    • @software-sage
      @software-sage  2 года назад +1

      Please join my Discord (link in description), and message me if you are still having trouble.

  • @lozD83
    @lozD83 2 года назад

    HTTTP

  • @dalesmith8666
    @dalesmith8666 6 месяцев назад

    When I hear the word PYTHON I go away! Why not a real language, like C or C++!?

    • @wildniscamper7276
      @wildniscamper7276 5 месяцев назад

      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...

    • @software-sage
      @software-sage  2 дня назад

      The support for Python is pretty large. Doesn’t matter in my opinion as long as the program works

  • @renatocontreirasdaconceica7555
    @renatocontreirasdaconceica7555 2 года назад

    Just annoying you writing on keyboard oh my days