Why not make the programs in Python3?

11 months 8 hours ago #6249 by oz1ewr
It is working, from a browser, but how du i implement it in a Python-schript????

Please Log in or Create an account to join the conversation.

10 months 4 weeks ago - 10 months 4 weeks ago #6251 by whyza
While I am no scripting guru, I use the following bash script to collect serial data from a MightyOhm Geiger counter and submit to radmon.org via a Raspberry Pi4

The MightyOhm Geiger displays serial data in the following format

CPS, 3, CPM, 16, uSv/hr, 0.09, SLOW

Change USERNAME, PASSWORD and serial port AMA1 to suit.


#cleanup any orphaned files
rm /tmp/cpm 2>/dev/null
rm /tmp/cpmavg 2>/dev/null

printf "Initial Counter: %d\n" $count

while true

while [ $count -lt 60 ]

#Extract the 4th field from the serial data to get CPM value
stty -F /dev/ttyAMA1 9600
read -r CPM < /dev/ttyAMA1
upload=$(echo "$CPM" | cut -d, -f 4)
echo "$upload" >> /tmp/cpm
printf "Read serial port CPM: %d\n" $upload
let count++
printf "#Seconds Counter: %d\n" $count

#calculate the 60 second average and submit to radmon
count=0; total=0; for i in $( awk '{ print $1; }' /tmp/cpm );do total=$(echo $total+$i | bc ); ((count++)); done; echo "scale=0; $total / $count" | bc > /tmp/cpmavg
read -r up < /tmp/cpmavg
printf "Attempting Upload of Average: %d\n" $up
exec=`wget -q -O /dev/null "http://radmon.org/radmon.php?function=submit&user=USERNAME&password=PASSWORD&value=$up&unit=CPM"`
rm /tmp/cpm
Last edit: 10 months 4 weeks ago by whyza.

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.134 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 61% Memory 16% Swap 19% CPU temp=61.3'C Uptime 44 Days