Home Forum Community Radiation vs Weather Reply To: Radiation vs Weather

#1949
Steve
Participant

Looks good David.

You’re just sightly north of me. I’m #11000061

I’ve just started gathering my uRad data into a MySQL database but display it independently to my weather station data. I’d like to incorporate my radiation data with my weather data but it exceeds my skills at present, but I’m working on it.

I’m going to try and work with your Python script, thanks for sharing it.

My PHP script I’m currently using is:

<?php
    //connect to mysql db
    $con = mysql_connect("localhost","myDatabase","myPassWord") or die('Could not connect: ' . mysql_error());
    //connect to the urad database
    mysql_select_db("myDatabase, $con);

    //read the json file contents
    $jsondata = file_get_contents('http://uradmonitor-61/j');
    
    //convert json object to php associative array
    $data = json_decode($jsondata, true);
    
    //get the data
    $id = $data['data']['id'];
    $type = $data['data']['type'];
    $detector = $data['data']['detector'];
    $cpm = $data['data']['cpm'];
    $temperature = $data['data']['temperature'];
    $uptime = $data['data']['uptime'];
    $timestamp = date('Y-m-d H:i:s', time());
    
    //insert into mysql table
    $sql = "INSERT INTO data(id, type, detector, cpm, temperature, uptime, timestamp)
    VALUES('$id', '$type', '$detector', '$cpm', '$temperature', '$uptime', '$timestamp')";
    if(!mysql_query($sql,$con))
    {
        die('Error : ' . mysql_error());
    }
?>

So far it looks like this-> http://wotid.dyndns.org/solarhtml/radiation.php

Regards,

Steve

  • This reply was modified 11 years ago by Steve. Reason: Security