[Home]Raspberry Pi2

HomePage | RecentChanges | Preferences

No diff available--this is the first major revision. (no other diffs)

 #=================================================

sudo nano /etc/rc.local

 #!/bin/sh -e
 # owned by root
 # chmod 755 /etc/rc.local
 #!/usr/bin/ env python
 #
 # You could start a webserver using:-
 # python -m http.server 8080  &

 # log last boot time for debug purposes
 date > /home/pi/rclocal.txt

 # log env to file for debug purposes
 /usr/bin/env  >> /home/pi/rclocal.txt
 # check where busybox is
 whereis busybox >> /home/pi/rclocal.txt
 # 
 # Start busybox 
 #
 sudo /usr/bin/busybox httpd -p 0.0.0.0:8080 -h /home/pi/www

 #
 # Port 80 , index.html is the default page
 #
 sudo /usr/bin/busybox httpd -p 0.0.0.0:80 -h /home/pi/www

A way to start a web server using system.d

 python dhr.py

 sudo nano /lib/systemd/system/dhr.service

 sudo systemctl start dhr.service

 sudo systemctl stop dhr.service

 sudo systemctl enable dhr.service

 sudo systemctl disable dhr.service

 sudo nano /lib/systemd/system/dhr.service

 [Unit]
 Description=dhrPythonScript?.
 After=network.target

 [Service]
 ExecStart?=/usr/bin/python3 /home/pi/dhr.py
 Restart=always
 User=pi

 [Install]
 WantedBy?=multi-user.target

Python Web server

This will start a webserver. this can be very useful for getting files off the Raspberry Pi.

 python -m http.server 8080 --directory /home/pi

dhr.py - python web server

 sudo nano /home/ip/dhr.py

 import http.server
 import socketserver

 PORT = 8080
 DIRECTORY = "/home/pi"

 class Handler( http.server.SimpleHTTPRequestHandler? ):
	def __init__(self, *args, **kwargs):
 		super().__init__(*args, directory=DIRECTORY, **kwargs)

 # Handler = http.server.SimpleHTTPRequestHandler?

 with socketserver.TCPServer(("", PORT), Handler ) as httpd:
    print("serving at port", PORT)
    httpd.serve_forever()

Using a cron job

Somewhere you need a process that polls the sensors on a timer tick and stores the measurements.

This should happen when the user is not logged in with their laptop or smart phone.

You could use a CRON job on a RPi to poll the NETIOM board to read the state of the pins.

An Arduino could also be used and log the data to an SD Card.

Arduino Based Logger And SVG Graph

The Netiom could remotely read and set outputs but did not seem to support a regular timer tick.

At the time I was using Microchip PIC's in assembler.

https://www.dougrice.co.uk/www/rt004/sr3/Logger.html - A not very successful attempt to measure the performance of a solar powered light.

History - Raspberry Pi Whezzy

This works:-

 python3 -m http.server 8080 --directory /home/pi

sudo python3 -m http.server 80 --directory /home/pi

I cannot find busybox on my old Whezzy SD cards.

The Raspberry Pi User guide by Ben Upton and Gareth Halfacre talked about LAMP

This installed Appache, MySQL? and PHP

You can also write PERL scripts, and Matt Wright guestbook script was a base for my Guestbook script

https://www.scriptarchive.com/readme/guestbook.html

Win98 and Tiny Web

I used to have a box that ran Win98

You used floppy disks to get files on and off.

Running TinyWeb? was the simplest way to download a big file from the box.

https://www.ritlabs.com/en/products/tinyweb/

zip up the files and write a minimal web page to allow backup.zip to be downloaded.

I used mawk and could write an awk script to write a web page based of the output from DIR

It had IE4 which could be used to get a file from TinyWeb? running on my laptop.

IoT? and simple TCP/IP scripts

Appache has cgi-bin script. I could not use these on btinternet.

Some simple perl scripts could do simple IOT type webserver.

ESP01 has some notes on IoT?

This PERL script can be started and acts as a very simple webserver that responds with a page.

https://www.dougrice.co.uk/www/dev/tcpip/tcpip_perl/server_iot.pl

some Raspberry Pi enabled ideas

[Plotting DS18S20 Temperature Readings Using SVG]?

Function Calls

ESP01

Esp8226

Arduino Based Logger And SVG Graph

Netiom Products - Using MicroChip?'s TCP/IP stack

http://www.emacsys.com/index.html is a later version.

A long time ago, in 2012, before the Raspberry Pi I brought one of these:-

http://www.phaedrusltd.com/index.html -

http://www.phaedrusltd.com/acatalog/Netiom_Produtcs.html

 Netiom Web enabled boards. 
 Standard Netiom
 Ref: Netiom-std
 Netiom is a stand-alone network aware Input / Output module which can be controlled over most networks including the Internet. It can be accessed from the Internet over a standard ADSL or other always 
 on connection making remote monitoring and control a cost effective option.

You could upload a web page of your own design and read the state of switches and analogue inputs.

I uploaded this file so I could include it into my web pages and read the values.

https://www.dougrice.co.uk/www/dev/js2_new.cgi

 ioF( "%31,analogue,%01,%02,%03,%04,"); %99

 ioF( "%31,digital1,%05,%06,%07,%08,"); %99

 ioF( "%31,digital2,%27,%28,%29,%30,"); %99

 ioF( "%31,counts,%11,%12,%13,%14,"); %99

 ioF( "%31,digital3,%41,%42,%43,%44,%47,%48,%49,%50,%51,%52,%53,%54,%55,%56,"); %99

 ioF( "%31,serial,%00,%12,%13,%14"); %99

https://www.dougrice.co.uk/www/dev/netiom.svg included the file and try and plot them:-

 < script  language = "JavaScript?" type = "text/javascript" src = "_http://192.168.1.22/js2.cgi" >  < / script >

I do not think it was possible to get it to poll the inputs and store in a file until the unit was polled.

Using a Raspberry Pi, this can now be done.

Using a cron job to POLL the Netiom

Somewhere you need a process that polls the NETION sensors on a timer tick and stores the measurements.

This should happen when the user is not logged in with their laptop or smart phone.

You could use a CRON job on a RPi to poll the NETIOM board to read the state of the pins.

wget can be used to get a web page.

curses can also be used.

Connecting to another router PLUSNET-S1234

When you use the Imager program to write a MicroSD?, you can set up the Router's WiFi? login credentials.

I need to add another router.

The raspi-config reported an error on the "Trixie" build. This may work.

Obtain the credetials of the SSID and password possibly from you mobile phone or the card on the router.

 sudo nmcli device wifi connect PLUSNET-S1234

 nmcli dev wifi connect PLUSNET-S1234 password 1234567890 ifname wlan0

 sudo nmcli connection add type wifi con-name "SecondWiFi?" ifname wlan0 ssid "YourSecondSSID?" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "YourSecondPassword?"

Use this if you want to delete a connection.

 sudo nmcli connection delete SecondWiFi? 

Cheat Sheet

https://opensource.com/article/19/11/awk-to-python

  Using a batch file called do.bat 

I use do.bat to put commands I run often.

 rem
 rem do.bat
 rem

 cd 
 pause 

Open some windows command ,

CD to working directory

copy files from Rapsberry Pi

 scp <source> <dest>

 scp pi@rpiw:capture.csv .

 scp pi@rpiw:capture.csv capture_.csv

  remote log into Raspberry Pi Zero W 

 ssh pi@rpiw

  list files using tree 
 tree
 tree - help

  list files in the folder 
 ls
 ls /dev

 ls -l 
 ls -l /dev

 ls -l /dev/tty*

  concaionate contents of files 
 cat readme.txt
 cat nohup.out

  concatonate Serial Port - XY-M01 temp sensor 
 echo "AUTO" > /dev/ttyACM0 

 date >> serialLog.txt
 cat /dev/ttyACM0 >> serialLog.txt
 echo "AUTO" > /dev/ttyACM0 

  concatonate contents of files 
 more cat readme.txt
 cat nohup.out
 cat cat serialLog.txt

 more cats file page by page 
 more -h
 more cat serialLog.txt

 edit a file 
 nano -h
 nano filename
 nano -l filename

Conclusion

Some ideas. It is not that simple, but the Raspberry Pi and Arduino boards make it much simpler.


HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited 2026-08-16 9:29 pm by dougrice.plus.com (diff)
Search:
home page