{"id":343,"date":"2017-05-31T08:59:25","date_gmt":"2017-05-31T07:59:25","guid":{"rendered":"http:\/\/chewett.co.uk\/blog\/?p=343"},"modified":"2017-06-07T21:44:09","modified_gmt":"2017-06-07T20:44:09","slug":"raspberrypivcgencmd-python-library-access-raspberry-pi-vcgencmd-command","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/343\/raspberrypivcgencmd-python-library-access-raspberry-pi-vcgencmd-command\/","title":{"rendered":"RaspberryPiVcgencmd A python library to access Raspberry Pi vcgencmd command"},"content":{"rendered":"<p>To access some of the lower level aspects of the Raspberry Pi&#8217;s config you can use the built in command <code>vcgencmd<\/code>. This is a useful on the command line but to easily access it in a program you need to parse the output.<\/p>\n<p>I am planning to use this command to store data like the temperature of the Raspberry Pi in python. Therefore to easily access the data I decided to make a small python module to do this.<\/p>\n<h2>RaspberryPiVcgencmd Python Module<\/h2>\n<p>This python module is a wrapper around the <code>vcgencmd<\/code> command to allow easy access to\u00a0some of the internal data of the Raspberry Pi.<\/p>\n<p>To include this module in your git based project you can run<\/p>\n<pre>git submodule add https:\/\/github.com\/chewett\/RaspberryPiVcgencmd\r\ngit commit<\/pre>\n<p>Now\u00a0I have run the above command the library is installed as a git submodule. This means I can now use it in my python script.<\/p>\n<p>So that I can use the library in my current script I need to import the submodule. To import this module I can add the below import statement to my script.<\/p>\n<pre>from RaspberryPiVcgencmd.RaspberryPiVcgencmd import RaspberryPiVcgencmd<\/pre>\n<p>This will make the RaspberryPiVcgencmd class available to be used in the current python file. Once I have imported it I can use the library to get the firmware version adding the below to the script.<\/p>\n<pre>vcgencmd = RaspberryPiVcgencmd()\r\nprint vcgencmd.get_version()<\/pre>\n<p>Using the <code>vcgencmd<\/code> object you can now call any of the functions available in the library.<\/p>\n<p>Full details of what vcgencmd can do is available on <a href=\"http:\/\/elinux.org\/RPI_vcgencmd_usage\">elinux<\/a>.<\/p>\n<h2>Current exposed functions<\/h2>\n<p>The majority of the useful output from vcgencmd is exposed in the class with the below functions<\/p>\n<ul>\n<li>get_cpu_temp &#8211; Gets the system temperature of the soc in Celsius or Fahrenheit<\/li>\n<li>get_ram_split &#8211; Gets the memory split between the gpu and cpu<\/li>\n<li>measure_volts &#8211; Measures the voltage of various internal components<\/li>\n<li>measure_clock &#8211; Mesures the clock frequency of various internal components<\/li>\n<li>is_codec_available &#8211; Returns whether the codec specificed video\/audio codec is available on the Raspberry Pi<\/li>\n<li>get_version &#8211; Gets the version of the firmware installed on the Raspberry Pi<\/li>\n<li>set_display_power &#8211; Allows turning off\/on the video output of the Raspberry Pi<\/li>\n<\/ul>\n<p>The RaspberryPiVcgencmd module is available on <a href=\"https:\/\/github.com\/chewett\/RaspberryPiVcgencmd\">github<\/a> and is licensed under the <a href=\"https:\/\/github.com\/chewett\/RaspberryPiVcgencmd\/blob\/master\/LICENSE\">MIT licence<\/a>. If you have any comments, suggestions or improvements you can\u00a0comment below or raise a <a href=\"https:\/\/github.com\/chewett\/RaspberryPiVcgencmd\/issues\">github issue<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To access some of the lower level aspects of the Raspberry Pi&#8217;s config you can use the built in command vcgencmd. This is a useful on the command line but to easily access it in a program you need to parse the output. I am planning to use this command to store data like the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":364,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[122],"tags":[37,101,106],"class_list":["post-343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-cluster","tag-raspberry-pi","tag-raspberry-pi-cluster","tag-vcgencmd"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/05\/vcgencmd.png?fit=628%2C288&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-5x","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2780,"url":"https:\/\/chewett.co.uk\/blog\/2780\/raspberry-pi-cluster-node-18-raspberry-pi-temperature-monitoring\/","url_meta":{"origin":343,"position":0},"title":"Raspberry Pi Cluster Node \u2013 18 Raspberry Pi Temperature Monitoring","author":"Chewett","date":"February 20, 2021","format":false,"excerpt":"This post builds on\u00a0my previous posts in the Raspberry Pi Cluster series\u00a0by starting to log temperature with the RaspberryPiVcgencmd Python module. Installing RaspberryPiVcgencmd RaspberryPiVcgencmd is a small python module aimed to control vcgencmd and allow programmatic access to it. This can be installed with the following command. python3 -m pip\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2766,"url":"https:\/\/chewett.co.uk\/blog\/2766\/updating-the-raspberrypivcgencmd-library-to-python-3\/","url_meta":{"origin":343,"position":1},"title":"Updating the RaspberryPiVcgencmd library to Python 3","author":"Chewett","date":"January 16, 2021","format":false,"excerpt":"This post talks quickly about the updates performed to the RaspberryPiVcgencmd library for porting to Python 3. Porting RaspberryPiVcgencmd to Python 3 Originally this library was written for Python 2 but now that has been retired it was time to update it. The main work that needed to be done\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/01\/rpi_vcgencmd_lib_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/01\/rpi_vcgencmd_lib_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/01\/rpi_vcgencmd_lib_OUTPUT.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/01\/rpi_vcgencmd_lib_OUTPUT.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/01\/rpi_vcgencmd_lib_OUTPUT.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":258,"url":"https:\/\/chewett.co.uk\/blog\/258\/vchi-initialization-failed-raspberry-pi-fixed\/","url_meta":{"origin":343,"position":2},"title":"VCHI initialization failed Raspberry Pi Fixed","author":"Chewett","date":"October 26, 2016","format":false,"excerpt":"If when running vcgencmd on a raspberry pi you get\u00a0VCHI initialization failed then you need to add the video group to your user. The vcgencmd tool requires you have this group role so without it, it will give VCHI initialization failed. To add the user group to your user you\u2026","rel":"","context":"In &quot;Fixes&quot;","block_context":{"text":"Fixes","link":"https:\/\/chewett.co.uk\/blog\/category\/fixes\/"},"img":{"alt_text":"vcgencmd get_mem arm VCHI initialization failed","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2016\/10\/vchi_init_failed.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2016\/10\/vchi_init_failed.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2016\/10\/vchi_init_failed.png?resize=525%2C300 1.5x"},"classes":[]},{"id":521,"url":"https:\/\/chewett.co.uk\/blog\/521\/add-new-user-account-raspbian-raspberry-pi\/","url_meta":{"origin":343,"position":3},"title":"Add a new user account in Raspbian Raspberry Pi","author":"Chewett","date":"August 5, 2017","format":false,"excerpt":"For my cluster project I will add a new user to each Raspberry Pi. This is so the user I use for all other systems will be the \u00a0same on the Raspberry Pi's. This post describes how to add another user to Raspbian OS. Adding a new user to Raspbian\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/add_user_to_raspbian_os.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/add_user_to_raspbian_os.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/add_user_to_raspbian_os.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/add_user_to_raspbian_os.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1839,"url":"https:\/\/chewett.co.uk\/blog\/1839\/raspberry-pi-cluster-node-08-slave-helper-functions\/","url_meta":{"origin":343,"position":4},"title":"Raspberry Pi Cluster Node &#8211; 08 Slave Helper Functions","author":"Chewett","date":"December 19, 2018","format":false,"excerpt":"This post builds on\u00a0my previous posts in the Raspberry Pi Cluster series\u00a0by adding a number of slave helper functions.\u00a0 This update will begin the process of fully automating the slaves. Preparing the Slaves for Automation Before the slaves are ready to be fully automated there are a number of commands\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/12\/rpi_cluster_08_slave_functions.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/12\/rpi_cluster_08_slave_functions.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/12\/rpi_cluster_08_slave_functions.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/12\/rpi_cluster_08_slave_functions.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":409,"url":"https:\/\/chewett.co.uk\/blog\/409\/setting-raspberry-pi-cluster-node\/","url_meta":{"origin":343,"position":5},"title":"Setting up a Raspberry Pi Cluster Node","author":"Chewett","date":"August 19, 2017","format":false,"excerpt":"To set up a Raspberry Pi node I will follow a specific set of steps so that every Pi is set up \u00a0similarly. For the initial deployment I will follow this once and then clone the SD Card multiple times. If at a later date more are added I will\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=343"}],"version-history":[{"count":4,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":366,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/343\/revisions\/366"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/364"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}