PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)

More
5 years 10 months ago #4252 by ThibmoRozier
Just wait......
I am working on a rewrite that doesn't require you to download one of 4 versions.
I'll also add proper support for setting log levels. The suggestion is what we'd call "a hack" and absolutely not according to standards. It is never suggested to fully disable logging, at the very least set it to ERROR.

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

More
5 years 10 months ago - 5 years 10 months ago #4253 by pilovis
ThibmoRozier, I don't know what kind of CPM your script is reading.

Stopwatch at the hand, I'm measuring from 5 to 9 CPM inside my room (0,040-0,073 uSv/h for my tube) instead of 18/31 CPM (0,14-0,25 uSv/h) your script is supposing to read now.
Just to be sure I moved my device to Turin since there is an official monitoring station of the local university that is about 1.6 miles away from here, their current reading is 0,070 uSv/h (outside):
http://www.meteo.dfg.unito.it/rad

Also the other stations here in north Italy that send data to Radmon seem to send irreal data (considering conversion factor of their tubes), since the official monitoring stations, about in the same locations, give much less reading values!

Be careful to publish such data without any verification, also CPM reading from different tubes are not always directly comparable, like this site seems to do, each tube has its own Conversion factor and it must be calculated before inserting data, 10 CPM from my tube are not the same of 10 CPM from another another brand tube.
It would be much better to publish uSv/h values instead of CPM values that are not always comparable.

I think I will stop sending data to radmon until I will be sure to send real data.
Last edit: 5 years 10 months ago by pilovis.

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

More
5 years 10 months ago - 5 years 10 months ago #4254 by ThibmoRozier
Thing is that they are using calibrated units, we are using DIY stuff.
You can simply not compare those.

Also, PyRadmon(-Reborn) in serial mode sends what your counter returns as a value.

IMO the MyGeiger returns a very decent value, even though this does depend on how "good" your tube is.

Sneak-peek of the new config for PyRadmon-Reborn v2.0.0:
// Parameter names are not case-sensitive
// Parameter values are case-sensitive
// Log levels: 10 = DEBUG, 20 = INFO, 30 = WARNING, 40 = ERROR, 50 = CRITICAL
log_level=20
// The Radmon username and password
username=not_set
password=not_set
// Protocols: DEMO, MYGEIGER, GMC, NETIO, AUDIO
protocol=DEMO
// Port is usually /dev/ttyUSBx on Linux and COMx on Windows
serial_port=not_set
serial_speed=2400
// In case of audio, set the device ID here.
// ID: {0.0.1.00000000}.{9dec41af-1b86-4c24-8e19-78564c886765} ; Name: Microfoon (Realtek(R) Audio)
// ID: {0.0.1.00000000}.{d983da26-9b68-4ca5-bc7d-e2c07de3cd6e} ; Name: Microfoon (Live! Cam Chat HD VF0790)
audio_device=not_set

I also moved away from pyaudio and switched to soundcard for audio, as it doesn't require intermediate libs, it doesn't block the devices unless necessary and it returns full device names.
The new version will also be one single file for the whole shebang, no longer the odd "pick your type", but dynamic dependency loading. (No soundcard means no audio support, no pyserial means no serial support)
I have also decided to drop support for 2.7 and move on to Python 3.
Last edit: 5 years 10 months ago by ThibmoRozier.
The following user(s) said Thank You: mw0uzo

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

More
5 years 9 months ago - 5 years 9 months ago #4256 by pilovis
I am now sending real and calibrated data.
My readings range from 3 to 9 CPM, tube conversion factor 0.00812, one reading for 6000 ms (measure time = 1 minute).
Honestly I don't know what kind of data others are sending since their readings seem to me too high.

My scripts (all Bash):

prerequisites:
sudo apt-get install bc

This is the script I programmed to have a csv file with data readings.
note: the awk part add unixtime, date and time, the sed part substitutes "spaces" with "commas" and to write the csv file,
unixtime will be used as a primary key in Mysql to avoid importing duplicates

print_rad2csv.sh
#!/bin/bash
/root/geiger_tube/measure 2>&1 | awk '{ print strftime("%s %Y-%m-%d %H:%M:%S"), $0; fflush(); }'  | sed -e 's/\s\+/,/g;w /var/www/rad/readings.csv'

results:

/var/www/rad/readings.csv
1548232110,2019-01-23,09:28:30,0.056840,uSv/h
1548232170,2019-01-23,09:29:30,0.073080,uSv/h
1548232230,2019-01-23,09:30:30,0.073080,uSv/h
1548232290,2019-01-23,09:31:30,0.048720,uSv/h
1548232410,2019-01-23,09:33:30,0.073080,uSv/h

radmon.sh
#!/bin/bash

# L305By tube conversion factor from uSv/h to CPM (CPM = uSv/h * conv)
conv=123.14709
# read last value from csv file generated by my instrument
line="$(/usr/bin/tail -n 1 /var/www/rad/readings.csv | cut --complement -c  1-31 | cut --complement -c  9-14 | sed -e 's/,/ /g')"
# calculations to get CPM from uSv/h
#echo $line
line2="$(echo "$line*$conv" | bc)"
#echo $line2
line3="$(echo $line2 | awk '{print int($1+0.5)}')"
#echo  $line3
# send data to radmon.org
user="pilovis"
password="mypwd"
exec=`wget -O /dev/null "http://radmon.org/radmon.php?function=submit&user=$user&password=$password&value=$line3&unit=CPM"

send to radmon.org the last CPM reading every minute:

crontab -e
*/1 * * * * /bin/sh /root/radmon.sh

Extra:
Import data to MySQL database:

import_csv2sql.sh
#!/bin/bash
/usr/bin/mysql -upilovis -pmypwd --local_infile=1 data -e "LOAD DATA LOCAL INFILE '/var/www/rad/readings.csv' INTO TABLE letture_radiazioni FIELDS TERMINATED BY ',' enclosed by '\

MySQL db structure
CREATE TABLE `letture_radiazioni` (
  `unix_time` bigint(20) NOT NULL,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `value` decimal(10,6) DEFAULT NULL,
  `unit` text,
  PRIMARY KEY (`unix_time`),
  UNIQUE KEY `unix_time` (`unix_time`)

I'm planning to move from one reading for 6000 ms (one minute) to one reading for 30000 ms (30 minutes), to get more consistent data.
Last edit: 5 years 9 months ago by pilovis.
The following user(s) said Thank You: mw0uzo

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

More
5 years 9 months ago #4257 by ThibmoRozier
You might want to make your own topic for this, as this forum section is dedicated to PyRadmon(-Reborn).
It would also be better to use curl, rather then wget. That way you don't have to output to /dev/null

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

More
5 years 7 months ago - 5 years 7 months ago #4385 by jnissen

To completely disable logging (higly suggested for embedded devices like Raspberry), you need to do this modification on the script:

# Set logger default info
logging.basicConfig(filename = "pyradmon_log.log", filemode = "a",
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt = "%d/%m/%Y %H:%M:%S %p")
logger = logging.getLogger("PyRadmon (Without audio)")
#logger.setLevel(logging.DEBUG)
logger.setLevel(logging.NOTSET)


I login to my pi periodically and clean up the logs but this is certainly an option. I must say that since moving to the pi3 with both 2.4GHz and 5GHz wifi my reliability has gone up considerably. No more drop outs and mysterious missing days.

It's just an observation I have made that logging may not be the source of the issues for everyone.
Last edit: 5 years 7 months ago by jnissen.

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

Moderators: Gamma-Man
Time to create page: 0.221 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 43% Memory 22% Swap 70% CPU temp=49.1'C Uptime 71 Days