{"id":1234,"date":"2016-04-26T17:06:50","date_gmt":"2016-04-26T17:06:50","guid":{"rendered":"http:\/\/www.horter.de\/blog\/?p=1234"},"modified":"2023-01-14T18:34:00","modified_gmt":"2023-01-14T18:34:00","slug":"i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi","status":"publish","type":"post","link":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/","title":{"rendered":"I2C-Analog-Input-Modul mit Python und TkInter"},"content":{"rendered":"<h3>Analogwerte\u00a0vom I2HAE-Modul\u00a0einlesen<\/h3>\n<p>Das Programmbeispiel liest auf Tastendruck die Analogwerte von der Eingangskarte ein,\u00a0schreibt den Wert in ein Label und gibt ihn in einer Balkengrafik aus.<\/p>\n<div id=\"attachment_1235\" style=\"width: 232px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/pythontkinter_analogin\/\" rel=\"attachment wp-att-1235\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1235\" class=\"size-full wp-image-1235\" src=\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\" alt=\"I2C-Analog-Input Modul einlesen\" width=\"222\" height=\"136\" \/><\/a><p id=\"caption-attachment-1235\" class=\"wp-caption-text\">I2C-Analog-Input Modul einlesen<\/p><\/div>\n<p>&nbsp;<\/p>\n<h3>Programmcode<\/h3>\n<pre><span style=\"color: #800000; font-weight: bold;\">import<\/span> tkinter\r\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> <span style=\"color: #44aadd;\">*<\/span>\r\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> ttk\r\n<span style=\"color: #800000; font-weight: bold;\">import<\/span> smbus\r\n\r\nbus <span style=\"color: #808030;\">=<\/span> smbus<span style=\"color: #808030;\">.<\/span>SMBus<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nmainWin <span style=\"color: #808030;\">=<\/span> Tk<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\nmainWin<span style=\"color: #808030;\">.<\/span>title<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">'Analoge Eingabe'<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n\r\n<span style=\"color: #800000; font-weight: bold;\">def<\/span> wert<span style=\"color: #808030;\">(<\/span>label<span style=\"color: #808030;\">,<\/span>kanal<span style=\"color: #808030;\">,<\/span>pb<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>                               <span style=\"color: #696969;\">#Variablen f\u00fcr Label,Kanal,Progressbar<\/span>\r\n    <span style=\"color: #800000; font-weight: bold;\">def<\/span> read<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n        var <span style=\"color: #808030;\">=<\/span> bus<span style=\"color: #808030;\">.<\/span>read_i2c_block_data<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x08<\/span><span style=\"color: #808030;\">,<\/span>kanal<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">11<\/span><span style=\"color: #808030;\">)<\/span>    <span style=\"color: #696969;\">#Werte von Board in 11 stelliges Array schreiben<\/span>\r\n        val <span style=\"color: #808030;\">=<\/span> var<span style=\"color: #808030;\">[<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">]<\/span><span style=\"color: #44aadd;\">*<\/span><span style=\"color: #008c00;\">256<\/span><span style=\"color: #44aadd;\">+<\/span>var<span style=\"color: #808030;\">[<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">]<\/span>                         <span style=\"color: #696969;\">#Berechnung der korrekten Zahlenwerte aus dem Array<\/span>\r\n        label<span style=\"color: #808030;\">.<\/span>config<span style=\"color: #808030;\">(<\/span>text<span style=\"color: #808030;\">=<\/span><span style=\"color: #400000;\">str<\/span><span style=\"color: #808030;\">(<\/span>val<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span>                     <span style=\"color: #696969;\">#Umwandeln der Integer Zahl in eine String Ziffer + Ausgabe in Label<\/span>\r\n        label<span style=\"color: #808030;\">.<\/span>after<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">20<\/span><span style=\"color: #808030;\">,<\/span> read<span style=\"color: #808030;\">)<\/span>                           <span style=\"color: #696969;\">#read() wird nach 20 ms erneut ausgef\u00fchrt<\/span>\r\n        pb<span style=\"color: #808030;\">.<\/span>config<span style=\"color: #808030;\">(<\/span>value<span style=\"color: #808030;\">=<\/span>val<span style=\"color: #808030;\">)<\/span>                            <span style=\"color: #696969;\">#Value der Progressbar wird angepasst<\/span>\r\n    read<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#Label f\u00fcr Kanalbestimmung (unwichtig)<\/span>\r\nbai1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Kanal 1: '<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai1<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai2 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Kanal 2: '<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai2<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai3 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Kanal 3: '<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai3<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai4 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Kanal 4: '<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai4<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai5 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Kanal 5: '<\/span><span style=\"color: #808030;\">)<\/span>\r\nbai5<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#Label f\u00fcr Digitale Darstellung<\/span>\r\nlabelai1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai1<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai2 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai2<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai3 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai3<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai4 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai4<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai5 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> width<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nlabelai5<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#Progressbar f\u00fcr Analoge Darstellung <\/span>\r\npb1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Progressbar<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> orient<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'horizontal'<\/span><span style=\"color: #808030;\">,<\/span> maximum<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">990<\/span><span style=\"color: #808030;\">,<\/span> length<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">100<\/span><span style=\"color: #808030;\">,<\/span> mode<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'determinate'<\/span><span style=\"color: #808030;\">)<\/span>\r\npb1<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\npb2 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Progressbar<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> orient<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'horizontal'<\/span><span style=\"color: #808030;\">,<\/span> maximum<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">990<\/span><span style=\"color: #808030;\">,<\/span> length<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">100<\/span><span style=\"color: #808030;\">,<\/span> mode<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'determinate'<\/span><span style=\"color: #808030;\">)<\/span>\r\npb2<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\npb3 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Progressbar<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> orient<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'horizontal'<\/span><span style=\"color: #808030;\">,<\/span> maximum<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">990<\/span><span style=\"color: #808030;\">,<\/span> length<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">100<\/span><span style=\"color: #808030;\">,<\/span> mode<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'determinate'<\/span><span style=\"color: #808030;\">)<\/span>\r\npb3<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\npb4 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Progressbar<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> orient<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'horizontal'<\/span><span style=\"color: #808030;\">,<\/span> maximum<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">990<\/span><span style=\"color: #808030;\">,<\/span> length<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">100<\/span><span style=\"color: #808030;\">,<\/span> mode<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'determinate'<\/span><span style=\"color: #808030;\">)<\/span>\r\npb4<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\npb5 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Progressbar<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> orient<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'horizontal'<\/span><span style=\"color: #808030;\">,<\/span> maximum<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">990<\/span><span style=\"color: #808030;\">,<\/span> length<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">100<\/span><span style=\"color: #808030;\">,<\/span> mode<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'determinate'<\/span><span style=\"color: #808030;\">)<\/span>\r\npb5<span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">,<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#Die wert-Funktion wird mit den 3 Parametern best\u00fcckt<\/span>\r\nwert<span style=\"color: #808030;\">(<\/span>labelai1<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">0x00<\/span><span style=\"color: #808030;\">,<\/span>pb1<span style=\"color: #808030;\">)<\/span>   \r\nwert<span style=\"color: #808030;\">(<\/span>labelai2<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">0x01<\/span><span style=\"color: #808030;\">,<\/span>pb2<span style=\"color: #808030;\">)<\/span>\r\nwert<span style=\"color: #808030;\">(<\/span>labelai3<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">0x02<\/span><span style=\"color: #808030;\">,<\/span>pb3<span style=\"color: #808030;\">)<\/span>\r\nwert<span style=\"color: #808030;\">(<\/span>labelai4<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">0x03<\/span><span style=\"color: #808030;\">,<\/span>pb4<span style=\"color: #808030;\">)<\/span>\r\nwert<span style=\"color: #808030;\">(<\/span>labelai5<span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">0x04<\/span><span style=\"color: #808030;\">,<\/span>pb5<span style=\"color: #808030;\">)<\/span>\r\n\r\n\r\nmainWin<span style=\"color: #808030;\">.<\/span>mainloop<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Analogwerte\u00a0vom I2HAE-Modul\u00a0einlesen Das Programmbeispiel liest auf Tastendruck die Analogwerte von der Eingangskarte ein,\u00a0schreibt den Wert in ein Label und gibt ihn in einer Balkengrafik aus. &nbsp; Programmcode import tkinter from tkinter import * from tkinter import ttk import smbus bus&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\">mehr lesen<\/a><\/p>\n","protected":false},"author":3,"featured_media":1235,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[254],"tags":[83,79,146,7,77,35,161],"class_list":["post-1234","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-analogwert","tag-ausgabe","tag-hausautomation","tag-i2c","tag-i2c-input","tag-i2c-modem","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog\" \/>\n<meta property=\"og:description\" content=\"Analogwerte\u00a0vom I2HAE-Modul\u00a0einlesen Das Programmbeispiel liest auf Tastendruck die Analogwerte von der Eingangskarte ein,\u00a0schreibt den Wert in ein Label und gibt ihn in einer Balkengrafik aus. &nbsp; Programmcode import tkinter from tkinter import * from tkinter import ttk import smbus bus... mehr lesen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\" \/>\n<meta property=\"og:site_name\" content=\"Horter &amp; Kalb Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-26T17:06:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-14T18:34:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"222\" \/>\n\t<meta property=\"og:image:height\" content=\"136\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"JH\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"JH\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\"},\"author\":{\"name\":\"JH\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2\"},\"headline\":\"I2C-Analog-Input-Modul mit Python und TkInter\",\"datePublished\":\"2016-04-26T17:06:50+00:00\",\"dateModified\":\"2023-01-14T18:34:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\"},\"wordCount\":49,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\",\"keywords\":[\"Analogwert\",\"Ausgabe\",\"Hausautomation\",\"I2C\",\"I2C Input\",\"I2C-Modem\",\"Python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\",\"url\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\",\"name\":\"I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\",\"datePublished\":\"2016-04-26T17:06:50+00:00\",\"dateModified\":\"2023-01-14T18:34:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg\",\"width\":222,\"height\":136,\"caption\":\"I2C-Analog-Input Modul einlesen\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Start\",\"item\":\"https:\/\/www.horter.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"I2C-Analog-Input-Modul mit Python und TkInter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.horter.de\/blog\/#website\",\"url\":\"https:\/\/www.horter.de\/blog\/\",\"name\":\"Horter & Kalb Blog\",\"description\":\"SPS, I2C und mehr\",\"publisher\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.horter.de\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\",\"name\":\"Horter & Kalb Blog\",\"url\":\"https:\/\/www.horter.de\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png\",\"width\":400,\"height\":400,\"caption\":\"Horter & Kalb Blog\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2\",\"name\":\"JH\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg\",\"caption\":\"JH\"},\"url\":\"https:\/\/www.horter.de\/blog\/author\/j-horter\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/","og_locale":"de_DE","og_type":"article","og_title":"I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog","og_description":"Analogwerte\u00a0vom I2HAE-Modul\u00a0einlesen Das Programmbeispiel liest auf Tastendruck die Analogwerte von der Eingangskarte ein,\u00a0schreibt den Wert in ein Label und gibt ihn in einer Balkengrafik aus. &nbsp; Programmcode import tkinter from tkinter import * from tkinter import ttk import smbus bus... mehr lesen","og_url":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/","og_site_name":"Horter &amp; Kalb Blog","article_published_time":"2016-04-26T17:06:50+00:00","article_modified_time":"2023-01-14T18:34:00+00:00","og_image":[{"width":222,"height":136,"url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg","type":"image\/jpeg"}],"author":"JH","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"JH","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#article","isPartOf":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/"},"author":{"name":"JH","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2"},"headline":"I2C-Analog-Input-Modul mit Python und TkInter","datePublished":"2016-04-26T17:06:50+00:00","dateModified":"2023-01-14T18:34:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/"},"wordCount":49,"commentCount":2,"publisher":{"@id":"https:\/\/www.horter.de\/blog\/#organization"},"image":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage"},"thumbnailUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg","keywords":["Analogwert","Ausgabe","Hausautomation","I2C","I2C Input","I2C-Modem","Python"],"articleSection":["Python"],"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/","url":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/","name":"I2C-Analog-Input-Modul mit Python und TkInter - Horter &amp; Kalb Blog","isPartOf":{"@id":"https:\/\/www.horter.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage"},"image":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage"},"thumbnailUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg","datePublished":"2016-04-26T17:06:50+00:00","dateModified":"2023-01-14T18:34:00+00:00","breadcrumb":{"@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#primaryimage","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_AnalogIn.jpg","width":222,"height":136,"caption":"I2C-Analog-Input Modul einlesen"},{"@type":"BreadcrumbList","@id":"https:\/\/www.horter.de\/blog\/i2c-analog-input-modul-mit-python-und-tkinter-am-raspberry-pi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Start","item":"https:\/\/www.horter.de\/blog\/"},{"@type":"ListItem","position":2,"name":"I2C-Analog-Input-Modul mit Python und TkInter"}]},{"@type":"WebSite","@id":"https:\/\/www.horter.de\/blog\/#website","url":"https:\/\/www.horter.de\/blog\/","name":"Horter & Kalb Blog","description":"SPS, I2C und mehr","publisher":{"@id":"https:\/\/www.horter.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.horter.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/www.horter.de\/blog\/#organization","name":"Horter & Kalb Blog","url":"https:\/\/www.horter.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png","width":400,"height":400,"caption":"Horter & Kalb Blog"},"image":{"@id":"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2","name":"JH","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg","caption":"JH"},"url":"https:\/\/www.horter.de\/blog\/author\/j-horter\/"}]}},"_links":{"self":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/comments?post=1234"}],"version-history":[{"count":8,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1234\/revisions"}],"predecessor-version":[{"id":1268,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1234\/revisions\/1268"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/media\/1235"}],"wp:attachment":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/media?parent=1234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/categories?post=1234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/tags?post=1234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}