-1

I would like to make a website using the MEAN stack to control a raspberry pi 2. How do send commands to a Raspberry PI via a web interface?

DanT29
  • 3,069
  • 4
  • 24
  • 32
  • This question is way too broad as it stands. We can't even begin to answer because there are so many pieces you are asking about and so few specifics to define requirements. It isn't even clear what the layout is of your system or what specifically you are asking for help with. Please review [How do I ask a good question](http://stackoverflow.com/help/how-to-ask) from the stackoverflow help center. It sounds like a cool project, but your question is way off base for stack overflow. You need to be asking about a specific programming problem, not a whole architecture. – jfriend00 Mar 10 '17 at 20:32
  • @jfriend00 I have edited the question to make it a bit more specific thank you for your input. I hope this narrows it down quite a bit. – DanT29 Mar 10 '17 at 20:45

1 Answers1

1

How do send commands to a Raspberry PI via a web interface?

  1. Put the Raspberry Pi on your network.
  2. Put an http server on your Raspberry Pi.
  3. Create the desired web pages in whatever http server environment you choose.
  4. Connect your web browser to the server on the Raspberry Pi to display desired web pages.
  5. Send commands to the Raspberry Pi from the web pages, either with form POSTs, Javascript Ajax calls or Javascript webSocket messages.

I have a Raspberry Pi that I use as a home automation controller. I've built a web server on it using node.js and Express. I have settings pages that communicate with the web server using form POSTs. I have buttons on the web page that communicate with the server using Ajax calls. I have real-time updates that the server sends back to the web page via a socket.io connection to update status display in the web page (in my case, real-time temperature readings). Which to use for any given action depends upon the details of the specific operation.

jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • Thank you! I will look into the steps you've outlined. Aside from setting up your own server on the RPi how would you be able to send commands to it via an external server/cloud? I guess this is related to the internet of things. – DanT29 Mar 11 '17 at 01:42
  • 1
    To send commands to anything, it needs a server listening for incoming connections. Then, you can connect to it and send it commands. That server can be an http server, a webSocket server, a socket.io server, a plain TCP server or many other kinds of servers. Then, the connecting client just needs to be speaking the same protocol as the server. If you have an http server as my answer described, then you can send http requests to it with commands. – jfriend00 Mar 11 '17 at 01:45
  • @DanT29 - Did this answer your question? – jfriend00 Mar 24 '17 at 04:15
  • Yes it did! I have much better idea of what to do and look into now. Thank you. @jfriend00 – DanT29 Mar 25 '17 at 21:50
  • 1
    @DanT29 - Then, you can indicate that to the community here by clicking the green checkmark to the left of the answer. That will also earn you some reputation points here on stack overflow for following the proper procedure. – jfriend00 Mar 25 '17 at 22:29
  • Done! @jfriend00 – DanT29 Mar 26 '17 at 17:28