Results 1 to 8 of 8

Thread: TEMPer USB to MySQL with graphs?

  1. #1
    Join Date
    Feb 2008
    Beans
    794
    Distro
    Ubuntu

    TEMPer USB to MySQL with graphs?

    Hi guys!

    Just picked up a TEMPer1f USB temp sensor
    What's the best way to get the data from the sensor into nice looking graphs?

    I've got the PCSensor software from https://github.com/petechap/usb-thermometer and it outputs to the command line fine.
    I've set up a cron job to send the temperature info to a log file every 5 mins.

    Now I'm terrible at programming and don't know where to start getting the info from the sensor into mySQL let alone into a graph.

    any help or pointers on where to look gratefully received.
    Laters...
    Sol
    "Have you found the secrets of the universe? Asked Zebade "I'm sure I left them here somewhere" User numbers: Ubuntu 23772 Linux 477911

  2. #2
    Join Date
    Feb 2008
    Beans
    794
    Distro
    Ubuntu

    TEMPer USB to MySQL with graphs?

    **duplicate post **
    Last edited by solitaire; November 10th, 2014 at 07:13 PM. Reason: duplicate post
    Laters...
    Sol
    "Have you found the secrets of the universe? Asked Zebade "I'm sure I left them here somewhere" User numbers: Ubuntu 23772 Linux 477911

  3. #3
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: TEMPer USB to MySQL with graphs?

    Threads merged.
    Please do not post duplicate threads. Those who may be able to help need to know what others have already posted to prevent duplication of effort. We all are volunteers.
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  4. #4
    Join Date
    Oct 2014
    Beans
    43

    Re: TEMPer USB to MySQL with graphs?

    How does the data come down?

    Can you modify the sensor program you've got there to output not only to the Command line but also to something else?

    Why do you want to use MySql? Is it important you use it or was it just the first database that sprung to mind?

  5. #5
    Join Date
    Feb 2008
    Beans
    794
    Distro
    Ubuntu

    Re: TEMPer USB to MySQL with graphs?

    The command line program just prints the following:

    Code:
    bill@zotac:~$ pcsensor
    2014/11/10 21:36:26 Temperature 64.85F 18.25C
    I could possibly tinker with the program to change the output. But i'm not good at programming and so it would be mainly cosmetic changes to the output, rather than anything more difficult.

    As for logging MySQL was the first thing that came to mind as the machine is already running the mySQL for Wordpress.
    I think it's a bit neater than having to phrase text log files if I want to push the data into something to create graphs.
    Laters...
    Sol
    "Have you found the secrets of the universe? Asked Zebade "I'm sure I left them here somewhere" User numbers: Ubuntu 23772 Linux 477911

  6. #6
    Join Date
    Oct 2014
    Beans
    43

    Re: TEMPer USB to MySQL with graphs?

    if (mrtg) {
    if (formato==2) {
    printf("%.2f\n", (9.0 / 5.0 * tempc + 32.0));
    printf("%.2f\n", (9.0 / 5.0 * tempc + 32.0));
    } else {
    printf("%.2f\n", tempc);
    printf("%.2f\n", tempc);
    }
    printf("%02d:%02d\n",
    local->tm_hour,
    local->tm_min);
    printf("pcsensor\n");
    } else {
    printf("%04d/%02d/%02d %02d:%02d:%02d ",
    local->tm_year +1900,
    local->tm_mon + 1,
    local->tm_mday,
    local->tm_hour,
    local->tm_min,
    local->tm_sec);
    if (formato==2) {
    printf("Temperature %.2fF\n", (9.0 / 5.0 * tempc + 32.0));
    } else if (formato==1) {
    printf("Temperature %.2fC\n", tempc);
    } else {
    printf("Temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0), tempc);
    }
    fflush(stdout);
    }
    That's the part you're looking to modify in main()

    If you open the pcsensor.c file in your favorite text editor/IDE (Make a backup before you do mind) and shunt the outputs that you see there into a basic SQL insert query.

    It'll look something like this:

    INSERT INTO "MYTABLE" VALUES(NULL, (9.0 / 5.0 * tempc + 32.0))
    If MySql is already running on your computer then that would be the most appropriate product to use.
    Of course you'll need to start the database and write all the tables and stuff first, but SQL isn't to difficult to pick up.

    If you need help learning it (From scratch) go here:
    http://www.w3schools.com/sql/default.asp

    For MySql specific stuff, look here:
    http://dev.mysql.com/doc/

    That should enter the data into a sql database

  7. #7
    Join Date
    Feb 2008
    Beans
    794
    Distro
    Ubuntu

    Re: TEMPer USB to MySQL with graphs?

    Thanks for your help.

    I'll take a look, I'm so-so with setting up a basic databases in MySQL so it will not be a huge problem for me.
    Laters...
    Sol
    "Have you found the secrets of the universe? Asked Zebade "I'm sure I left them here somewhere" User numbers: Ubuntu 23772 Linux 477911

  8. #8
    Join Date
    Oct 2014
    Beans
    43

    Re: TEMPer USB to MySQL with graphs?

    Cool, you need any other help, don't hesitate to ask

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •