Skip to main content


Elementi taggati con: python


S-Tui: Un power monitor para Linux

#gnu #linux #pip #programas #python #s-tui #stress-terminal ui #sysadmin
S-Tui: Un power monitor para Linux


Expand Raspberry Pi GPIOs with I2C Port Expander


#gpio erweiterung #hardware & gpio #i2c #mcp23017 #more gpio pins #port expander #port extender #python

If you have several smaller or one larger project, you will soon discover that the GPIO pins of the Raspberry are fastly becoming too little. For all of you, this tutorial will show you how to use an I2C Port Expander to easily multiply the GPIO pins many times over.

In some situations, you may need more GPIO pins than it has outputs and you are at its physical limits. But there is a very useful port expander. On the use of one of these, we will discuss in this post.

Required Hardware Parts & General

For this tutorial you need the following hardware parts:

* MCP23017

* LEDs (best in different colors)

* a button

* Resistors

* Breadboard

* Jumper cable

First of all, the setup of the microchips:


As you can see the differences are minimal, for this tutorial it does not matter which one is used.


A little explanation of the main pins:

* GPA0-7 and GPB0-7 are the GPIO pins

* A0, A1, A2 are connected to + (3.3V) or – (GND) and define the name internally. If several port expanders are connected, each must be clearly identifiable. With the first I²C you would connect all to GND, the next A0 to 3.3V and the other two to GND. At the third a! at 3.3V and the other two at GND etc. So it is possible up to 2³ and to connect an 8 port expander.

* VDD (Pin 9) gets the input voltage (3.3V)

* VSS (pin 10) is connected to GND

* SCL (pin 12) is connected to the GPIO pin 5 of the Pi

* SDA (pin 13) is connected to the GPIO pin 3 of the Pi

Accordingly, I have built a small circuit with 3 LEDs (as series resistors 330Ω).

(We require the button only in Part 2 of the tutorial.)

The first thing to do is to unlock the I2C in the Pi. The easiest way to do this is by means of
sudo raspi-config

It is activated under “Advanced Options”> “I2C”.

For older versions of Raspbian, you also have to edit a file
sudo nano /etc/modules

and appends these two lines to the end:


Save and exit with CTRL + O and CTRL + X.

Now the modules have to be removed from the blacklist file, otherwise, they will not work.
sudo nano /etc/modprobe.d/raspi-blacklist.conf

and put a # in front of the two entries.
#blacklist spi-bcm2708 

#blacklist i2c-bcm2708

Save again with CTRL + O and CTRL + X and exit.

So that we can address the I2C now, we have to install a few more packages.
sudo apt-get install python-smbus i2c-tools

Then shut down the Pi, wait a few seconds and disconnect from the power.
sudo shutdown now


Testing Hardware

After everything is connected and all connections have been checked again, start the Pi and wait until it has started up.

I use a Raspberry Pi Rev.2, so I test it with:
sudo i2cdetect -y 1

If you have a Pi Rev.1, you must enter 0 instead of 1. The output looks like this:
pi@raspberrypi ~ $ sudo i2cdetect -y 1 

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 

00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

70: -- -- -- -- -- -- -- --

The address 0x20 (hexadecimal) contains the I2C. If A2 were e.g. connected to 3.3V (A1 and A0 to GND), it would be addressable at the address 0x24. This is, as mentioned above, important if you have connected several port expanders in order to be able to address them clearly.

To address the LEDs, the ports must either be declared as input or output (Rev1 please adjust the user again).
sudo i2cset -y 1 0x20 0x01 0x00

Here are some examples that explain how the command works:
i2cset -y 1 0x20 0x01 0x00   #all pins of GPB are output 

i2cset -y 1 0x20 0x01 0x04   #GPB2 is input, the rest of GPB output (since 0x04 in binary 00000100) 

i2cset -y 1 0x20 0x00 0x80   #GPA7 is input, the rest of GPA output

First of all the address addressed by i2cdetect is addressed. The second value is in this table (from the datasheet):

So after we have specified the direction (IODIRB) (0 = Output, 1 = Input), we want to let the three LEDs light up (Binary 00000111 = 0x07):
sudo i2cset -y 1 0x20 0x15 0x07

If we were to use the GPA pins, instead of 0x15, it would be 0x14.

For the LEDs to stop lighting, we need to reset the level of the pins to 0:
sudo i2cset -y 1 0x20 0x15 0x00

Raspberry Pi MCP23017 Python Script for Input and Output

So we create a script
sudo nano

with the following content:

Save and exit with CTRL + O and CTRL + X.

To start the script now, we enter
sudo python

As soon as you press the button, the LEDs light up. By pressing CTRL + C you can cancel the script and return to the console.

As you can see, using it is pretty easy and you have created another 16 GPIO pins.

Der Beitrag Expand Raspberry Pi GPIOs with I2C Port Expander erschien zuerst auf Raspberry Pi Tutorials.
Expand Raspberry Pi GPIOs with I2C Port Expander


Hacer GUIs con Python GTK para noobs

#guis #programacion #python #python-gtk #software

Python-GTK Antes de nada tienes que tener instalado python-gtk, si no recuerdo mal se debe instalar de una forma parecida a esta
sudo apt install python-gtk2 -y

Cualquier apliación que quieras hacer con esta librería debería tener una estructura parecida a esta, si no te fías de esta información siempre puedes recurrir a la documentación

import gi 

class MyWindow(Gtk.Window): 

     def __init__(self): 

         Gtk.Window.__init__(self, title="GTKyou2mp3") 

win = MyWindow() 

win.connect("destroy", Gtk.main_quit) 



Vale ya tenemos la estructura o “el molde” de nuestra aplicación, vamos a meterle elementos para que parezca una ventana, como véis en la imagen de abajo, cada botón, que queramos meter en nuestra aplicación necesita ser declarado , como quien dice botón, dice entrada de texto, label, imagen, etc. En este caso es un botón y en ejemplo nos enseñan a “construirlo”. Es posible que no quieras saber nada sobre la POO y te la sude saber que es “self”, pero no te preocupes, tampoco es tan importante en programación dirigida a eventos.
self.button = Gtk.Button(label="Click Here")

Lo importante después de entender este sencillo concepto es “conectar”, conectar eventos a funciones. Dicho de otra forma, cuando el usuario hace “un click” mi programa tiene que saber donde hizo click y que tiene que hacer cuando eso ocurra.
self.button.connect("clicked", self.on_button_clicked)

Vale tío, pero este programa de ejemplos que ponen no sirve para nada, solo va a hacer un print de “Hello World” cuando alguien pulse el botón y para más inri lo hace en la consola. Efectivamente, estos ejemplos son la base para empezar a escribir tus propias mierdas, como GUIs chiquititas que poco a poco se hagan mierdas incluso aún más grandes, del tamaño elefante.

Por ejemplo un día que estaban poniendo música en un canal de discord, con un bot y algunos temas de la música que estaban poniendo me estaban gustando y deseaba descargar algunos de ellos, pero me pareció muy tedioso usar youtube-dl, hay que tener en cuenta que esos bots usan enlaces de youtube para ponerte las canciones, así que me…. Bueno mejor le doy 10 puntos al primero que le de uso y me diga si le sirvió de algo.
#written by under GPLv3 License 


import gi 

import re 

from os import system 

gi.require_version('Gtk', '3.0') 

from gi.repository import Gtk, Gdk 

class MyWindow(Gtk.Window): 

    def __init__(self): 

        #change this to your own path 

        self.converted_path = "~/music/" 

        Gtk.Window.__init__(self, title="GTKyou2mp3") 

        self.set_default_size(800, 0)  = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) 


        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) 

        self.format = "mp3" 

        # adding components 

        self.url_entry = Gtk.Entry() , True, True, 0) 

        self.button1 = Gtk.Button(label="Convert") 

        self.button1.connect("clicked", self.on_button_convert_clicked) , True, True, 0) 

        # box for radio_buttons 

        self.radio_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) 

        self.radio_button1 = Gtk.RadioButton.new_with_label_from_widget(None, "mp3") 

        self.radio_button1.connect("toggled", self.on_selected) 

        self.radio_button2 = Gtk.RadioButton.new_with_label_from_widget(self.radio_button1, "ogg") 


        self.radio_button2.connect("toggled", self.on_selected) 

        self.radio_button_box.add(self.radio_button2) , True, True, 0) 

        actual_clip = self.clipboard.wait_for_text() 

        if actual_clip is not None: 


    def find_url(self, string):  

        url = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!\*\(\), ]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', string) 

        if len(url) > 0:  



            return "" 

    def on_button_convert_clicked(self, widget): 

        url = self.url_entry.get_text() 

        command = "youtube-dl -o '" + self.converted_path  +"%(title)s.%(ext)s' --extract-audio --audio-format " + self.format + " " + url 



    def on_selected(self, widget, data=None): 

        format = widget.get_label() 

        if format == "ogg": 

            self.format = "vorbis" 

        if format == "mp3": 

            self.format = "mp3" 

win = MyWindow() 

win.connect("destroy", Gtk.main_quit) 



Bonito es mejor que feo. Simple es mejor que complejo, complejo mejor que complicado. Python Rocks.

Hallo zusammen, ich bin #NeuHier. Ich interessiere mich für #geoinformatik, #geologe, #geologie, #hund, #hunde, #postgis, #postgresql, #qgis, #python und #triumph.
Und vieles mehr ;)
Have a ot of fun!

I just wrote a small #Python script to create a #sitemap for a #Mastodon account:

Of course also available as a #Docker image:

My sitemap is already #live at:

It's basically the natural reaction to

This will hopefully further support #search engines.. :)

Hey everyone, I’m #newhere and the creator of a very occasional blog about programming and problem solving called REINDEEREFFECT. There's a new article in the works (on recursive descent parsing), and I look forward to announcing its release soon. Meanwhile, there are a few articles already up. Have a look! I hope you find them useful.

I’m interested in #coffee, #programming, #python, and #science. Also, #rum.

Hey everyone, I’m #newhere and the creator of a very occasional blog about programming and problem solving called REINDEEREFFECT. There's a new article in the works (on recursive descent parsing), and I look forward to announcing its release soon. Meanwhile, there are a few articles already up. Have a look! I hope you find them useful.

I’m interested in #coffee, #programming, #python, and #science. Also, #rum.

Hey everyone, I’m #newhere. I’m interested in #climateprotection, #debian, #ecology, #floss, #history, #javascript, #linux, #opensource, #philosophy, #python, #rust, #socialism, #socialjustice, and #sustainability.

In preparation for The Great G+ Migration,,I thought I'd join up here to reacquaint myself with Diaspora before more seriously considering running my own pod. It's been a long time since I last explored it so I expect much has improved since its earliest days.

Hey everyone, I’m #newhere. I’m interested in #climateprotection, #debian, #ecology, #floss, #history, #javascript, #linux, #opensource, #philosophy, #python, #rust, #socialism, #socialjustice, and #sustainability.

In preparation for The Great G+ Migration,,I thought I'd join up here to reacquaint myself with Diaspora before more seriously considering running my own pod. It's been a long time since I last explored it so I expect much has improved since its earliest days.


Podcasts desde la consola de comandos con castero

#casteo #pip #programas #python #ubuntu 18.04
Podcasts desde la consola de comandos con castero

#python #packaging #pipenv

#python #packaging #pipenv

Hey everyone, I’m #newhere. I’m interested in #3dprinting, #algebra, #android, #archlinux, #arduino, #assembly, #autocad, #calculus, #chronicfatigue, #circuittheory, #classicalmusic, #clustercomputing, #computerscience, #cplusplus, #cprogramming, #creative-writing, #cryptography, #css, #digitalart, #electronics, #entrepreneur, #flstudio, #founder, #geometry, #guitar, #harmonica, #html, #intj, #java, #kirigami, #learning, #linux, #mathematics, #mbti, #motivation, #multipotentialite, #origami, #oscilab, #packtpub, #perl, #photograhy, #piano, #poetry, #psychology, #python, #quotes, #raspberrypi, #rennaissanceman, #scanner, #self-improvement, #shortstories, #soundcloud, #survivalcraft, #tech, #tennis, #tmnt, #unity3d, #unreal-engine, and #woodworking.

I come from Google+, so bring it on!

Really nice to meet everybody and I'm kind of excited to restart the journey.

To infinity, and beyond!!!!

Hey everyone, I’m #newhere. I’m interested in #android, #climatechange, #debian, #doctorwho, #dragon, #linux, #opensource, #opensuse, #programming, #python, #raspberrypi, #science, #siduction, and #tesla.

Well, this has perked my interest. Let's see where it goes. There seems to be a few alternatives to G-Plus, but pluspora seems to be the most active.

Hey everyone, I’m #newhere. I’m interested in #android, #climatechange, #debian, #doctorwho, #dragon, #linux, #opensource, #opensuse, #programming, #python, #raspberrypi, #science, #siduction, and #tesla.

Well, this has perked my interest. Let's see where it goes. There seems to be a few alternatives to G-Plus, but pluspora seems to be the most active.

Hi and welcome! I share your interests in #python, #programming and #freesoftware :)

Hey everyone, I’m #newhere. I’m interested in #anime, #bash, #crystal, #debian, #doctorwho, #freesoftware, #go, #googleplus, #gplusrefugee, #linux, #madpagan11, #mastodon, #newhere, #opensuse, #podcasts, #programming, #python, #raspberrypi, #reddit, #ruby, #rust, #rwby, #savegoogleplus, #shell, #siduction, #solus, #startrek, #twitter, #utau, #vocaloid, and #youtube...among other things.

Many of you might remember me from popular social networks, such as:
YouTube: jpyper <- Go here for playlists of things that interest me.
YouTube: MaDpAGaN11 <- Go here for MaDpAGaN11 Vocaloid group, which I am a member of, and consultant for.

#python #script #plumbum


1tayH/noisy: Simple random DNS, HTTP/S internet traffic noise generator

A simple python script that generates random HTTP/DNS traffic noise in the background while you go about your regular web browsing, to make your web traffic data less valuable for selling and for extra obscurity.


Nuitka is a Python compiler I never heard of. It just achieved 3.7 compatibility. Cool!

> Right now Nuitka is a good replacement for the Python interpreter and compiles every construct that all relevant CPython version, and even irrelevant ones, like 2.6 and 3.2 offer. It translates the Python into a C program that then is linked against libpython to execute in the same way as CPython does, in a very compatible way.

> It is somewhat faster than CPython already, but currently it doesn't make all the optimizations possible, but a 258% factor on pystone is a good start (number is from version 0.3.11).

#python #programming #compiler #softwareengineering


How to use Photoresistors (Brightness / Light Sensor) with a Raspberry Pi


#adc #analogue #gpio #hardware & gpio #light #light sensor #mcp3008 #python #spi #spidev #weather station

To use, for example, a weather station, it is important to know the brightness. With a Raspberry Pi light sensor (photoresistor/brightness sensor), it is very easy to determine a value, which can say, for example, if it is day, twilight or night.

In turn, projects could be implemented to control the (exterior) lights, which turn on automatically after a certain level of darkness. In this tutorial, we connect such a brightness sensor and read the light values accordingly, so that we can respond.

Required Hardware Parts

The photoresistor used is in addition to the actual version on a PCB (circuit board), whereupon et al. resistors are soldered. As a result, it is additionally possible to read out a digital signal which stands for “above/below the threshold value”. Reading this digital signal is very easy and will be covered in some other tutorials (for example here). Both versions can be used with this tutorial, only the one version just has an additional functionality. For projects like distinguishing between light/dark, it is certainly a simple alternative.


A photoresistor soldered to a printed circuit board has a potentiometer so that thresholds can be set.

The following components are necessary for this tutorial:

* Raspberry Pi 3 or similar

* Photoresistor

* Alternative Photoresistor as a Module

* MCP3008

* 10kΩ resistor

* Breadboard

* Jumper Cable

If you’re interested in how photoresistors (LDRs) work in general, you can read more about them here. In general, it can be said that the resistance changes are depending on the brightness.

Connect Raspberry Pi Light Sensor


On the left side of the MCP3008 are the 8 analogue readable channels.

However, before we can connect and read the phototransistor, we need to connect an analog-to-digital converter. In addition, you can find here a quite detailed article about the MCP3008, which we also use in this tutorial. In order not to inflate this article unnecessarily, I will not go into detail on the MCP3008. The exact connection between ADC and Raspberry Pi can also be found in another article.

It is important that the brightness sensor also has a connection (via a 10kΩ resistor) to the ground connection, otherwise, the value cannot be clearly read out. If there is no voltage at all coming through the LDR, then it is at 0 (due to the connection to GND). If the voltage is flowing, a part goes back through the 10kΩ resistor, but this part is very low because the resistance is large. As with other resistors, it does not matter on which side the positive voltage is applied to the photoresistor.

Schematically, the structure looks like this:


If you later see fairly high levels even with low light, you can add extra resistance between the positive voltage and the pin of the light sensor.

If you are using a soldered photoresistor, you only need 3.3V (Pin 1) from the Raspberry Pi to VCC and GND and GND (Pin 6) from the Pi. Pin A0 is connected directly to the analog-to-digital converter. Thus, no 10k pull-up resistor is needed. The advantage is that you can set the series resistor by a potentiometer (rotational resistance) individually – depending on the maximum brightness.

Read Brightness Sensor on the Raspberry Pi

In the other tutorial for the MCP3008, we have created a class, which we will also use here. Make sure that SpiDev is installed as described. As a reminder, you will find the content of the class here again:

If this class exists in the current directory, you can simply open the Python console via sudo python (or alternatively create a script) and enter:
from MCP3008 import MCP3008

adc = MCP3008()

print( channel = 0 ) ) # if necessary perform several times

With me, complete darkness (fingers held on it) gave a value of approximately 600, which means that approximately 1.95V voltage came from the original 3.3V to the MCP3008. At brightness I had permanently a value of 1023.

The maximum resistance varies slightly depending on the light resistance. If the brightness is very high (daylight) we recommend a series resistor or another pull-resistor (previously 10k).


Der Beitrag How to use Photoresistors (Brightness / Light Sensor) with a Raspberry Pi erschien zuerst auf Raspberry Pi Tutorials.
How to use Photoresistors (Brightness / Light Sensor) with a Raspberry Pi


Guido van Rossum dimite como “jefe” de Python

#guido van rossum #open source #programación #python
Guido van Rossum dimite como “jefe” de Python


PyCharm: #Python IDE for Professional Developers by JetBrains

Python IDE
for Professional Developers


Guido van Rossum dimite como líder de Python

#gnu/linux #programación #python

Es el fin de una era. Guido van Rossum, dimite como Benevolent Dictator for Life del lenguaje de programación Python. Un cargo tan informal como habitual en muchos proyectos de software libre y que el bueno de Guido ha venido desempeñando desde que creó el
Guido van Rossum dimite como líder de Python

#python on a microcontroller without an OS.
MicroPython is a full Python compiler and runtime that runs on the bare-metal.
#arduino #diy


Installing OpenCV on the Raspberry Pi


#bathymetric charts #calibration #computer vision #face detection #opencv 3.0.0 #projects #python #software #stereo vision #text detection

Anyone who has dealt with image processing in relation to the Raspberry Pi will sooner or later come across the OpenCV library. It provides many very useful features such as face recognition, the creation of depth maps (stereo vision, optical flow), text recognition or even for machine learning. In addition, OpenCV (Open Source Computer Vision) can be integrated into both its C ++ files and its Python scripts.

Especially in terms of feature recognition in images taken by the Raspberry Pi, OpenCV is very helpful.

This advanced tutorial shows how to install OpenCV on the Raspberry Pi and how to integrate it into Python.

For the time being, I would like to recommend everyone a Raspberry Pi Model B to use, because this is a lot more powerful than its predecessor. Even on a Raspberry Pi B + compiling takes about 6 times as long, with a Pi 2 in total “only” takes about an hour.

First of all, we update the package lists:
sudo apt - get update && sudo apt - get upgrade && sudo rpi - update
A reboot is necessary if it has been updated.
sudo reboot
Then you can install all the important tools and libraries needed for OpenCV (installation takes a few minutes).
sudo apt - get install build - essential git cmake pkg - config libjpeg8 - dev libtiff4 - dev libjasper - dev libpng12 - dev libavcodec - dev libavformat - dev libswscale - dev libv4l - dev libgtk2 . 0 - dev libatlas - base - dev gfortran
If everything worked, we could clone OpenCV from git. This step also takes a few minutes.
git clone https : / / github .com / Itseez / opencv .git && cd opencv && git checkout 3.0.0
Whether version 3.0 or 2.4 of OpenCV is taken is up to you. Depending on the application, one of the versions may be better suited.

Afterwards, OpenCV can be compiled. You can either use Python 2.7 or Python 3+. There are some differences between the versions, especially as some libraries are not (yet) executable with Python 3+. However, this mainly affects smaller libraries, as common libraries (NumPy, SciPy, etc.) usually provide the respective files for both versions.

In this tutorial, I use Python 2.7. If you already have Python installed and want to know which version is installed, you can simply enter python into the console and get the exact version at the beginning (the command for Python 3+ is python3). If you do not have a Python installed, you can install it by following the steps below:
sudo apt - get install python2 . 7 - dev
We also need the package management tool pip, which installs NumPy right away:
cd ~ && wget https : / / bootstrap .pypa .io / get - pip .py && sudo python get - pip .py
Now we can simply install via pip NumPy. NumPy is a library that makes it very easy to perform array operations in Python.
pip install numpy
But now to compile OpenCV. For this purpose, a build folder must be created in which the compiled files land:
cd ~ / opencv && mkdir build && cd build cmake - D CMAKE_BUILD_TYPE = RELEASE


Now you can finally compile. This step takes (depending on Raspberry Pi model) quite a long time (on my Pi 2 about an hour). To use all four cores to compile on the Raspberry Pi 2, type in the following:
make - j4
If the compilation has worked without problems, we can install OpenCV:
sudo make install && sudo ldconfig

To check if everything worked, you can open the Python console and import the library:
import cv2


Now you can use all OpenCV functions in your projects. A look at the OpenCV documentation is certainly helpful.


Der Beitrag Installing OpenCV on the Raspberry Pi erschien zuerst auf Raspberry Pi Tutorials.
Installing OpenCV on the Raspberry Pi


Raspberry Pi: Control Relay switch via GPIO


#230v #c++ #hardware & gpio #high voltage #python #reed switch #relay #switch

Often you want to control modules with a higher voltage with the Raspberry Pi. For this purpose, relays can be used on the Raspberry Pi: The relay “switch” is utilized by means of a low-voltage pulse. Since the Pi only tolerates a maximum of 5V (the GPIOs even only 3.3V) without relays, there is the risk that the Pi could burn out. However, if you have two separate circuits this can not happen.

In this tutorial, I will show how to control a relay with the Raspberry Pi and what has to be considered.

Required Hardware Parts

* 5V relay module

* Female – Female jumper cable

* an external circuit (e.g., batteries) and an application (eg, motors)

The relays are available as 2, 4, 8 and even 16 modules, depending on what you need. To avoid wasting too many GPIOs on the Pi it pays off to purchase a GPIO port expander with more than 4 channels.


The structure is very simple since all pins are labelled. Left (GND) comes to pin 6 of the Pi (GND), the right pin (VCC) comes to 3V3 (pin 1) of the Pis. Depending on how many of the relays you want to control, you need to connect a corresponding number of GPIOs to the IN pins. It is recommended to set a small resistor between the Pi and the relay, but it is not absolutely necessary with 3V3.

If you set 5V instead of 3.3V to VCC, you should definitely put one resistor each (~ 1kΩ) between the GPIOs and the IN pins.

On the other side are at each relay 3 connections (see picture below): Depending on whether the IN pin is a LOW (0V) or HIGH (3.3V or 5V) is applied either the switch between the centre and right, or Open centre and left. If you connect all 3 pins, you can use the relay as a kind of switch, leaving it free on the left or right has the effect of an on/off switch. Where VCC or ground are connected (middle or right/left) does not matter.


Either center-left or center-right is connected/”opened”.

If you want to connect devices with high voltages, you should either know exactly what you are doing or ask an electrician! 230V is life-threatening. Pay extra attention to the specifications of the relay and take, if possible, no dodgy parts from China (which doesn’t matter in the low-power range but at higher voltages you should spend a bit more and take proven products). I assume no liability for damages!

Raspberry Pi Relay Control

Also, the control is not very difficult, since only GPIOs have to be switched. You can use C++ (wiringPi) or Python for it. I am using Python and have used GPIO 17 (pin 11).
sudo python

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM) # GPIO Numbers instead of board numbers


GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) # GPIO Assign mode

GPIO.output(RELAIS_1_GPIO, GPIO.LOW) # out


If 0V is present at the relay pin, the corresponding LED lights up, at a HIGH level the LED goes out. So if you want the relay to open at a HIGH level, you need to connect the middle and left pins to the circuit. The LED is off there. If the relay is to open, if the LED is also on, middle and right OUT pins are connected.

That’s it. I would like to know, in which applications have you found the use for the Raspberry Pi relays?


Der Beitrag Raspberry Pi: Control Relay switch via GPIO erschien zuerst auf Raspberry Pi Tutorials.
Raspberry Pi: Control Relay switch via GPIO

j'ai déjà montré ici des tentatives de représentations graphiques et/ou de placement automatique de plantes, en se basant sur les données de compagnonage (telle plante bénéficie de la proximité de telle autre plante, ou pas.. cf. par exemple ici)

Je continue de temps en temps ces histoires de graphes, j'ai notamment un billet de blog qui attend d'être fini depuis plus d'un an, joie de la procrastination.

En attendant, je m'aperçois que j'aurais plus besoin d'un outil concret, plus simple et utilisable: un truc qui me dit si telle plante et telle plante s'entendent bien, un truc qui me donne simplement la liste des plantes copines et pas copines pour une plante donnée.

J'ai développé une bibliothèque python et des scripts (un pour l'instant) qui devraient être utilisable depuis la ligne de commande, ici:

C'est un peu le bordel linguisitique, les noms de plantes sont en français, les commentaires et aide en français.

dites moi si ça marche chez vous et/ou si vous avez besoin d'explications supplémentaires, je me suis fait chier avec le packaging python mais il semble que j'ai fini par converger (du coup installation en une ligne avec un sudo pip install git+, ce qui nécessite pip et git).

#french #jardin #graphe #permaculture #simulation #gephi #compagnonage #plantes #python

Is there any way to reimplement python 2.6 print_function in python 2.4?

Specifically, how can I remove the keyword 'print' (while still use it in the implementing module)? I only need a limited set of its features and thus can implement it myself.

And yes, I know how long ago python 2.4 stopped being officially supported. Enough people care about it in a meaningful way and this is what matters.

I asked on IRC and the response was that it is only possible with quite some black magic. Any hints on the types of sorcery required?


#python #dev #test #ttd



Debian developer Matthieu Caneill announced today the new URL for Debsources. For those who do not know it: With Debsources you can search in the complete source code of Debian. This is very nice, when you like to learn, how your operating system or applications work, if you like to learn a new computing language, if you like to find an attack vector for your latest hack or you like to prevent the latter. It is like the late Google codesearch, but free as in freedom. Try out and have fun!
Dear developers,

We're happy to announce that Debsources, the Web application that
allows to browse and search the entire source code of all Debian
releases, is now hosted on the official Debian infrastructure and
available at

You may already know this service as previously hosted at . We took the move to Debian hardware as the
opportunity to officially announce it here.

Service description

Debsources is a web service that exposes the content of Debian source
packages on the Web, both via an HTML user interface and a JSON API
[0]. To that end, an updater runs regularly (currently 4 times a day)
to unpack and index new packages from all the available Debian
suites. It also runs various plugins, for example to count lines of
code and measure the size of packages; this information is exposed in
the interface.


Since all extracted information is stored in a PostgreSQL database,
various data warehouse features are available, such as the list of
file duplicates for every file, or package name search.

More than source code

Worth noting are two "sub-apps" that run on the same infrastructure:

* patches [1]: for packages using 3.0 (quilt) package format, the list
of patches is extracted and exposed, along with some metadata.

* copyright [2]: the copyright files of packages are exposed through
this interface, and displayed in a convenient way if they are
machine readable.


Learn more

Debsources has been described extensively and used to conduct various
studies on the Debian source code. To learn more check out the paper:

Matthieu Caneill, Daniel M. Germán, Stefano Zacchiroli. The Debsources
Dataset: Two Decades of Free and Open Source Software. In Empirical
Software Engineering, Volume 22, pp. 1405-1437, June, 2017

An open access preprint of the paper and additional information about
Debsources are available on the Debsources documentation page [3].



Many credits go to everyone who submitted patches and feedback over
the years, thank you! In particular, Stefano Zacchiroli started the
project and wrote the updater infrastructure, and Orestis Ioannou
developed the patches/ and copyright/ apps.

This new instance of the service is hosted by DSA - without whom would not exist. Many thanks to the whole team for
their guidance in the d.n -> d.o migration, and in particular to
Julien Cristau and Peter Palfrader.

The previous instance of Debsources had been hosted by IRILL [4]for
more than 4 years, who has also spearheaded the initial development of
the service - thanks for the non-interrupted service!


As always, we're more than happy to hear your feedback; you can
contact us at . (See the footer
of the Debsources web page for bug report and contribution

For the Debsources team,

#debian #freesoftware #sourcecode #search #development #debsources #python #agpl3


XMPP based tickets and merge requests with SàT

Interesting idea: A distributed bug tracking system based on XMPP. It even has MRs (merge requests) for git and mercurial. The developer,, claim the following advantages:
  • it's decentralized and federated, no need to have X accounts to use X tickets handlers. You can also import tickets from third party projects (e.g. plugins for your project) into your website.
  • it's standard: we can handle or fetch tickets in third party servers easily, without proprietary API.
  • it's very flexible: any field can be used, and the mechanism can be used for any list (bug tracker, TODO list, shopping list, etc.)
  • being based on SàT, it's usable on any platform
  • it can be used with gateways, allowing to use transparently tickets from other services (think about Gitlab or Github for instance)
There is also a short demo video. Nice!

(Someone must package sat_pubsub for Debian!)

#xmpp #bugtracker #git #mercurial #freesoftware #salutatoi #python #tickets #decentralisation


Rilasciato Django 2.0

#django #python


searx v0.13.0 is out!

The great developers of the wonderful privacy-respecting, hackable metasearch engine, give us a new release, which features:
  • New theme: simple
  • New engines
    • Google videos (video)
    • Bing videos (video)
    • Arxiv (science)
    • OpenAIRE (science)
    • Pubmed (science)
    • Genius (music/lyrics)
  • Display engine errors
  • Faster startup
  • Lots of engine fixes (google images, dictzone, duckduckgo, duckduckgo images, torrentz, faroo, digg, tokyotoshokan,, google news, gitlab, gigablast,,,, base, json engine, currency convert, google)
  • Shorter saved preferences URL
  • Fix engine duplications in results
  • Py3 compatibility fixes
  • Translation updates
Btw., the server seems to get slower and slower, because too many people use it. Please consider to use other entities of searx and - if you care for your privacy - use different servers alternating. There is a simple hack to automatically change the searx entity to use with every search, see here, here, and here.

#searx #privacy #python #decentralization #freesoftware #agpl3


searx - Privacy-respecting metasearch engine