ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Raspberry Pi (rPi) tips and Tricks

    IT Discussion
    raspberry pi
    3
    11
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thwrT
      thwr @gjacobse
      last edited by thwr

      @gjacobse said in Raspberry Pi (rPi) tips and Tricks:

      I could see a very nice little dashboard being written with some of this... the first one being the CPU temp

      Found this article on MEDIUM, and dropped it onto the rPi running.

      Monitor CPU Temp

      The script presents the output in list format, and for starters that great, but I'd like something cleaner and with more info... similar to TOP and hTOP.

      Conky if you want something on a local (or remote) display
      Your monitoring product of choice in any other case

      1 Reply Last reply Reply Quote 1
      • thwrT
        thwr
        last edited by thwr

        CPU temperature:

        cat /sys/class/thermal/thermal_zone0/temp
        

        Divide by 1000 for degree celsius

        1 Reply Last reply Reply Quote 1
        • M
          mattbagan
          last edited by

          @gjacobse you inspired me with this post. I created a python script to post my cpu temp from a remote pi to my home automation pi via mqtt.

          gjacobseG 1 Reply Last reply Reply Quote 2
          • gjacobseG
            gjacobse @mattbagan
            last edited by gjacobse

            @mattbagan said in Raspberry Pi (rPi) tips and Tricks:

            @gjacobse you inspired me with this post. I created a python script to post my cpu temp from a remote pi to my home automation pi via mqtt.

            I hope you will share your (sanitized) code. This is what I was thinking of doing on the remote station that is in planning.

            M 1 Reply Last reply Reply Quote 1
            • M
              mattbagan @gjacobse
              last edited by

              @gjacobse I can post what I have but the setup is a little different. I have a frontend already setup from my automation setup.

              gjacobseG 1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse @mattbagan
                last edited by

                @mattbagan said in Raspberry Pi (rPi) tips and Tricks:

                @gjacobse I can post what I have but the setup is a little different. I have a frontend already setup from my automation setup.

                As the automation is something else of interest - show us what you have and tells us how it you did it.

                M 2 Replies Last reply Reply Quote 0
                • M
                  mattbagan @gjacobse
                  last edited by

                  @gjacobse I can create a separate topic of my setup. I've pieced together the needed information to make it work with my setup. Waiting on my hardware to get in so I can add more to my setup.

                  1 Reply Last reply Reply Quote 2
                  • M
                    mattbagan @gjacobse
                    last edited by

                    @gjacobse I like full control so I'll post the way I set mine up. There is other ways to do it but I didn't like some of the limitations. It was a give and take kind of a deal.

                    gjacobseG 1 Reply Last reply Reply Quote 0
                    • gjacobseG
                      gjacobse @mattbagan
                      last edited by

                      @mattbagan said in Raspberry Pi (rPi) tips and Tricks:

                      . It was a give and take kind of a deal.

                      That is IT in a nut shell....

                      1 Reply Last reply Reply Quote 1
                      • M
                        mattbagan
                        last edited by

                        Prerequisites for client

                        sudo apt-get install python3 python3-pip
                        sudo pip3 install paho-mqtt
                        

                        Python script:

                        #!/usr/bin/python3
                        #Imports
                        import time 
                        import os
                        import paho.mqtt.client as mqtt 
                        import paho.mqtt.publish as publish
                        
                        #Variable setups
                        broker = "IP Address MQTT Broker"
                        state_topic = "pi/cputemp" #Topic to publish commands too
                        delay = 1 #Time delay
                        
                        #Fuction to return temp
                        def measure_temp():
                            temp = os.popen("vcgencmd measure_temp").readline()
                            return (temp.replace("temp=",""))
                        
                        #MQTT connection setup
                        client = mqtt.Client()
                        client.username_pw_set("username", "password") #Login for broker
                        client.connect(broker)
                        client.loop_start()
                        
                        #While loop for posting to MQTT
                        while True:
                            print(measure_temp())
                            time.sleep(1)
                            cpu_temp = measure_temp()
                            client.publish("pi/cputemp", str(cpu_temp))
                            time.sleep(delay)
                        
                        1 Reply Last reply Reply Quote 1
                        • 1 / 1
                        • First post
                          Last post