#=================================================
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
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
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
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()
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.
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
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.
Appache has cgi-bin script. I could not use these on btinternet.
Some simple perl scripts could do simple IOT type webserver.
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
[Plotting DS18S20 Temperature Readings Using SVG]?
Arduino Based Logger And SVG Graph
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.
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.
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?
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
Some ideas. It is not that simple, but the Raspberry Pi and Arduino boards make it much simpler.