Sunspot Home

more notes for backup and a bad memory - - -

Getting Jessie to behave

background -
I have a Pi 2 and failed to get it to run cgi scripts while running the manufacturer's software for a Kedei 3.5" screen
(a Pi B worked fine but now my v1 screen has been changed to a v2 by Kedei and of course support for the v1 has been dropped)

So - forget the 3.5" screen - let's run the latest Rasbian (Jessie) on my Pi2 and use
a very neat 1024x768 VGA monitor from a table top sale (£2) with a cheap Chinese hdmi - vga adapter-
(The text is much clearer than on an hdmi TV)

I want to explore the "Internet of Things" using my home and garden.
That means I now need (again) to track down all the new hidden security defaults to let me run i2c etc on my LAN using cgi scripting from a web page.

Notes for next time
These actions were performed to "do it my way" - (as explored in OpenWrt routers over the years)

I want to use Cyberduck (ftp) and TextWrangler on my iMac to edit the scripts
Set PermitRootLogin yes in /etc/ssh/sshd_config
now Cyberduck works because it needs to use root

Do a full update and upgrade
apt-get update && sudo apt-get upgrade -y

Create a ramdisk at boot time - to save sensor data in dynamic RAM and avoid burning out the SD card memory
setup /etc/init.d/
see here

Set a fixed wired ethernet address
setup /etc/network/interfaces
see here

Fighting Apache2
I need to enable CGI scripting in bash so as to control IOT devices on my LAN via i2c etc from a web page

Install Apache to create a web server
apt-get install apache2 -y

Test cgi

in :-

put :-
echo -e "Content-type: text/html\n\n"
echo "<h1>Hello World from CGI</h1>"

then create a link to cgi-bin in the www/html folder :-
ln -s /usr/lib/cgi.bin /var/www/html/cgi-bin

But, of course, the latest apache will not let you see the cgi page by default
After much Googling frustration I found this magic
a2enmod cgi
service apache2 restart

(Try this first next time - must I do it again after each update/upgrade????)

"a2enmod is a script that enables the specified module within the apache2 configuration.
It does this by creating symlinks within /etc/apache2/mods-enabled."

And then I could see the cgi web page at

I had also done these earlier - not sure now if they are still needed - does a2enmod cover that?
usermod -a -G sudo www-data
so that
/etc/group contains
And I had also done
chown root.root /usr/lib/cgi-bin

I thought I had found all the hidden gotchas . . .
but my i2c LM75 c code program would not run from a web page - only from a Mac ssh terminal as root.

chmod 4755 /usr/sbin/i2c_lm75
thanks to here

Wheezy never had all these problems - I see why it was given the name Jessie

I also want to allow a link on a web page to shutdown or reboot the Pi (a2enmod did not cover this - tested)
so I used visudo to edit /etc/sudoers/ and added -
www-data ALL=NOPASSWD:/sbin/reboot
www-data ALL=NOPASSWD:/sbin/poweroff

(so only reboot and poweroff can be requested by the browser user and the root password is not required)

so why did this not work?
www-data ALL=NOPASSWD:/usr/sbin/i2c_lm75

The Pi is not a bank mainframe and Apache2 seems a bit over the top for would be IOT power users!

Slowing down the i2c bus
I have very long i2c lines (with line drivers) and need to go below the default 100,000 Hz
I found this to be difficult to change on older Pis but for this setup I just
added these at the end of

ssshhhh. . . . . my solar panel i2c web page seems to be working at last . . . . . .

please email me if you do a better job

Sunspot Home