Articles Hierarchy

Articles Home » RPI » RPI operates ARDUINO PID control

RPI operates ARDUINO PID control

8. RPI installation
until now i distribute zip files, and i think to set it up in the RPI can be a pain in the back
i want to learn how to do / offer a installation routine
and i see from a PRO a example about his RPI camera tool ( Silvan Melchior ) what i use as basis for mine.
principle idea is a installation bash file and that get a zip file and does the rest of the job.
that installation routine you must get from my new /share/ directory and make it executable
UPDATE: now see here

add requirements:
installation of arduino IDE
sudo apt-get install arduino
on older systems might need install pyserial
sudo apt-get install python-serial
installation of python matplotlib
sudo apt-get install python-matplotlib
( the first start of the arduino PID operation took more 10 sec after that installation,
but the second start only 4 sec. )
these installations are now in the included

edit and give your google macro key in line 166 of 243
sudo nano /home/pi/arduinoproject/
sudo reboot
now i test it with a new setup RPI and it works.
-1- a new NOOBS DEBIAN setup ( needed the TV for installation )
-2- a new BERRYBOOT, but there i could not download debian.
so i reinstall a berryboot backup of a debian from last year.
update it and do above installation.
- 3- in that BERRYBOOT i could download new debian after 5th attempt and set it up headless
! and google trend is running !
and just reboot and wait for the new line in the google sheet.
seems to be quite robust setup now, even JOSH ( where the idea with
historic trending in a google macro spreadsheet comes from ) now
can not recommend to use google!
and this you get by this installation v0.3

you can go on next page

one of the open points for me is with the REMOTE thinking,
what i have now is a control loop / sensor / PID / valve, implemented in a RPI and arduino
powered by a wall plug adapter of the powered USB HUB, all for about 50EURO.
( i think about all the utilities what are required in a factory like instrument air ... )
for the cloud based historic data logging for controller and the remote operation / tuning, a LAN connection is required.
as RPI can use ethernet or WLAN ( what is even more perfect for REMOTE ) i check again on the configuration.
i would like to have a fixed IP either way, and i found it here.( but not work too well , so new version:
sudo nano /etc/network/interfaces
auto lo

iface lo inet loopback
iface eth0 inet dhcp
iface eth0 inet static

allow-hotplug wlan0
iface wlan0 inet manual
post-up iwconfig wlan0 power off
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
netmask 24

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


The setup is running on WIFI and the headless way i worked anyhow now makes sense.
i have to test later what happens if i connect ethernet and WIFI adapter is still in??
if there are problems check: RPI 4um
This fix IP thing is also required for even more "REMOTE" usage via internet:
-a- a web server in RPI
-b- remote SSH ( should be possible )
-c- use RPI camera additionally
because the router can have forward ports configured only to a fix IP and must use a other port as 80,
i use DLink DSL-2750E.

-a- a web server in RPI
for the web server installation i want try apache again:
sudo apt-get install -y apache2 php5 libapache2-mod-php5
and reboot and try from PC browser: to see the apache well come page.
now the whole router and NO IP part is very difficult for me, i hope i don't give up.
for the port i change:
sudo nano /etc/apache2/sites-enabled/000-default 80 > 4000
sudo nano /etc/apache2/ports.conf 80 > 4000
sudo reboot
now i must call from browser: to get connected.
and in the router i add:
Now the RPI web server should be visible from the outside also, if you have the web IP.

or use some free dynamic DNS services. ( i had that DYNDNS account but that is finished / not free anymore )
testing a FREE one i try freedns and find here how to teach my new RPI webserver to update the DNS.
as described in that manual after registration ( get your subdomain "" ) you need to test it, best is you ask a friend to try in his browser
like i test it with from my own computer ( and in router no port forwarding, but DMZ enabled )
it did work for me, but not for a friend from "outside", very confusing, i have no idea about that stuff.

possibly you can try to call a proxy first and from there call your new RPI free-proxyserver give "" and see your page. Is that proof that it works??
lucky if you have a tablet, switch of WLAN, go ONLINE by mobile network / SIM card and try from there.

Now, we need a update service for the free dns service, means to teach them your actual IP.

to check on your IP:
google search "MY IP" or dnsdynamic or like in the following code dyndns
to check on the IP the DNS service is pointing to, you could ping
or like its done in following code call that page and check the HEADER.
The update at FREEDNS:
you need to login at freedns "for members" [main menu] and get under menu [Dynamic DNS] down that page, find the link for "DIRECT URL". save the LINK, in there is your HASH code. you could call that link ( by browser) from any computer in your LAN anytime and FREEDNS would know your actual IP.
all that can be done by that ( modified for test ) code in the RPI and a cron job to execute it repeatedly.

BUT: if you own a website, and the webspace provider allows a sub domain you could try it there:
with a PHP / HTML index.php you can make with header(".."); a redirect but that will show actual IP and port in the browser
or use a frame to hide that.

now you need a update routine also:

it can show your IP or, with password, set your IP what is used in the frame to link to.
Now that needs to be called by RPI CRON again.
pls download the automated webserver installation, above website and the MYDYNDNS php source
like that

-b- remote SSH have to dig deeper and need a friend for online testing

-c- use RPI camera additionally
when i updated 2014 debian raspbian i noticed the python camera tools are now preinstalled.
There are many ways to use the camera but as i want learn python i will study this
Pure Python camera interface, last year i play with that already pls see here under test PYTHON 2:

because even with more camera support in new raspbian, from desktop it is still not supported, and the preview works on TV but not headless.
just a short example here:
cd /home/pi/
mkdir /home/pi/camera/

nano /home/pi/camera/ use this
nano /home/pi/camera/ use
cd /home/pi/camera/
python /home/pi/camera/
gpicview /run/shm/last.jpg

sudo nano /home/pi/Desktop/resize.desktop use
[Desktop Entry]
Comment=python camera small picture service
Exec=lxterminal -e '/home/pi/camera/'

with the actual setting it only makes files at RAMDISK ( lost with reboot)
and will show the just last made picture, but the gpicview allows to cycle through all of them you made in that session.
there is in terminal a small error about the gpicview call ( from headless? ) a unanswered question also i see at forum
possibly the VNC picture resolution??

at the moment that are just explorations for the "MORE REMOTE" possibilities.
i not made my mind up how to use camera and webserver for the arduino PID project.