What server and language do you use for Raspberry PI

Thread Starter

Parth786

Joined Jun 19, 2017
642
I have started working with Raspberry PI. I wrote a Python program that turns on/off LED on Raspberry PI board. I was working to control GPIO of Raspberry PI using web page. I know that I need web server and more then one programming languages.

I did google search and found out many information about web server and programming language. I have seen that projects have been developed using many servers like apache, Flask, pigpiod daemon..etc. Many languages like python, php, html, java script, c programming, c++ programming.

I have the option and I have to select one web server and specific language. Will you please tell me on which server and programming language I should work? What server and language do you use for Raspberry PI?
 

geekoftheweek

Joined Oct 6, 2013
1,219
I'm planning on something along these lines myself in the future. I've only worked with Apache so I can't compare it to any of the others other than it's probably the most common server on the internet. As far as languages go PERL was pretty easy to pick up and PHP works pretty good too, they both have modules built into Apache to run them, and in the earlier days they were pretty much all there was to handle forms and such on the internet.

The last I worked with java script there wasn't any way to use it to use it to do anything other than modify the page itself... nothing on the server side. C and C++ could be used to build modules to compile into Apache, but other than that I don't think they will be useful.

I don't know how it all works on Windows for sure, but I do know on Linux and such Apache is run as it's own user and limited to what it can do on the server computer (it's a security thing). In other words you're going to need some trickery or very relaxed configuration to be able to read and write your gpio pins. Since I've only worked with Apache I can't say if there are limitations like this with other servers. My particular idea calls for a separate program listening to a socket on localhost that the PERL script will connect to and gather information and make changes.

Good luck!!
 

simozz

Joined Jul 23, 2017
128
You can use the language which better helps you to solve your problems.
If you need a web interface, you can choose lighttpd or nginx as web servers. There are more lightweight web servers as well.
To toggle a LED on Linux you don't need nothing more than basic shell scripting or C.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
I
I don't know how it all works on Windows for sure, but I do know on Linux and such Apache is run as it's own user and limited to what it can do on the server computer (it's a security thing). In other words you're going to need some trickery or very relaxed configuration to be able to read and write your gpio pins. Since I've only worked with Apache I can't say if there are limitations like this with other servers. My particular idea calls for a separate program listening to a socket on localhost that the PERL script will connect to and gather information and make changes.

Good luck!!
I am trying to toggle led web browser using Raspberry Pi 3 I was doing with apache server and php programming. I tried to follow the tutorial link on step by step. but my experiment was not successful I don't know why it wasn't working. there was some permission issue.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
You can use the language which better helps you to solve your problems..
I am an absolute beginner now and I have started reading about it. I had bad luck, My first attempt was unsuccessful

I understood,we need one server that will run or raspberry and we need html to create web page and we need to write program that will execute on server and control gpio of raspberry. This is basic things for any project.

There are many way to do it project but I think below two way's are most used
  • web server + html + php
  • web server + html + java script
Did you make a project that was controlling a any device with the help of your web page I want to know in which way you have worked. Your experience will help me to understand basics. I am trying and my efforts are going on.
 
Last edited:

Thread Starter

Parth786

Joined Jun 19, 2017
642
When I was working with apache and php. I was getting message on screen a "permission denied" I did google and found out that it is not the right way to do it with php

Have you toggled led using web? Do you think that if I follow this link then I will get success because I tried many links video's still I didn't get success but I am ready to one more effort. I have gone throw this web site. There is example for Raspbian wheezy and I have Raspbian jessie

I have found out from the link that I need below tool
  • RPi GPIO , GPIO Python library for Raspbian OS
  • PubNub Python SDK
  • PubNub Javascript SDK
 
Last edited:

be80be

Joined Jul 5, 2008
2,072
Make changes to this file to point to your web server rasbpi.py
Code:
import RPi.GPIO as GPIO
import urllib2
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(26,GPIO.OUT)
true = 1
while(true):
                try:
                        response = urllib2.urlopen('http://You.ser.add.com/buttonStatus.php')
                        status = response.read()
                except urllib2.HTTPError, e:
                                        print e.code

                except urllib2.URLError, e:
                                        print e.args

                print status
                if status=='ON':
                print "setting GPIO 26 "
                GPIO.output(26,True)
                elif status=='OFF':
                                GPIO.output(26,False)
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
I would help you that you got pay to use there code

This shows you for free https://medium.com/@softxide/remote-control-raspberrypi-leds-from-web-browser-ui-84205993b98f
I have seen this link I am not clear I don't understand which server he is using in the given link. I can see he is using python and php program. I am still confuse on selection of server and programming language Can you tell me which server and programming's he is using in his project

I think these four things he is using in his project
  • server -?
  • html
  • python program
  • php program
I find this task very difficult because the lack of my knowledge. I wanted to divide my work in some steps. It will help to find out my mistake easily

Step 1 : My first step is that I want to install server on pi and want to make sure that weather my server is working or not. I checked apache server that was working fine
 
Last edited:

be80be

Joined Jul 5, 2008
2,072
I would love to help you out but the link I posted tells it all. I don't no what I could add.

The pi has everything you need to make it work.

1. Do polling from Raspi to our web server .

2. Set up a server on Raspi and use web UI to hit the server hosted on Raspi .

We will be following first approach.
 

be80be

Joined Jul 5, 2008
2,072
There polling a web page on a server running
The video I posted i ran there page on my server and polled it.
You don't even need a server I just did it for fun.
Your pi can poll theres.

6) Get the programing files from Git repository hosted here , breakdown as follows :

· rasbpi.py — Python file which will be running on RaspPi polling server continuously for checking the status of LED lights. It contains a very straightforward code to control GPIO Pin 26.

· Rest all other file — button.php,buttonStatus.php,buttonStatus.txt and index.html need to be hosted on server. We hosted it here — http://softxide.com/iot/home_auto/ .

7) Open the terminal and start the rasbi.py program using this command — python rasbi.py . Visit you UI page on browser and test it .
 

geekoftheweek

Joined Oct 6, 2013
1,219
I have seen this link I am not clear I don't understand which server he is using in the given link. I can see he is using python and php program. I am still confuse on selection of server and programming language Can you tell me which server and programming's he is using in his project

I think these four things he is using in his project
  • server -?
  • html
  • python program
  • php program
I find this task very difficult because the lack of my knowledge. I wanted to divide my work in some steps. It will help to find out my mistake easily

Step 1 : My first step is that I want to install server on pi and want to make sure that weather my server is working or not. I checked apache server that was working fine
I think you have the general idea. Since Apache is working you have a start.
How about something along these steps:
Step 1: Apache works so far... completed.
Step 2: Concentrate on HTML and how to create forms, buttons, and such. Don't worry so much about what happens when you submit it or press buttons yet... that part comes later.
Step 3: If you want the page to update when you press a button or update at a time interval you'll have to get into Javascript, but if you can handle reloading the page to check for changes manually you'll be better off not complicating it with Javascript for the time being... I'm fairly decent with programming, but found out Javascript can be a nightmare since not all browsers support the same Javascript syntax.
Step 4: Look for Python CGI tutorials. What you'll end up doing is using Python to generate the HTML that is sent your browser to show you the state of your Pi, handle your form elements, and change your gpio and such in the end. PERL, PHP, and Python all work the same way in that they take your inputs from your form, process them, and generate the HTML needed for the next page... kind of like pressing ok at the end of your online purchase and getting the "thank you for your business" or whatever page when you're done. I would just stick to Python since it has the libraries to work with your gpio and has the most support. I haven't looked, but I doubt there's PHP modules for the Pi gpio... I think PERL may have, but Python will have the most information and tutorials relating to the Pi of the languages.

I would love to help you out but the link I posted tells it all. I don't no what I could add.

The pi has everything you need to make it work.
Those links might tell you all, but for someone starting out they leave a lot to be desired. I'm fairly knowledgeable and it took five or so times through it before it started to begin to make sense... not to mention it really won't teach a person anything.
 

geekoftheweek

Joined Oct 6, 2013
1,219
You need to be in the same directory as the whatever.py file is in. I can't get your screenshot to come back up, but that's what it seemed to be telling you.
 

geekoftheweek

Joined Oct 6, 2013
1,219
Look at this screen shot when I was working on apache and php

View attachment 141012
It looks to me you're on a Windows computer getting the web page from your Pi which is at 192.168.1.101. No need to white out your ip address for this. The only people who can access it are the ones connected to your home network... unless you have other reasons.

I have done it. Now I getting this message " setting gpio 26 on" and related to file
Glad to hear and thanks for asking the question in the first place... Time to reread the links again and start figuring out how it works. A good starting point when I get around to starting my project.
 
Top