Docker Access to Raspberry Pi GPIO Pins

On a Linux host, there are three possible ways to get access to the GPIO pins from within a Docker container. 1. Running Docker with the “–privileged” option Starting a container like this will give the container full access to the host’s devices, including GPIO: $ docker run –privileged -d whatever Check the Docker documentation … Read more

How do I use setsockopt(SO_REUSEADDR)?

Set the option after the socket has been successfully initialized. So, after: sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error(“ERROR opening socket”); You can add (with standard C99 compound literal support): if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int)) < 0) error(“setsockopt(SO_REUSEADDR) failed”); Or: const int enable = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) … Read more

How to change screen resolution of Raspberry Pi [closed]

Just run the following simple command on Raspberry Pi 3 running Raspbian Jessie. run terminal and type sudo raspi-config Go to: >Advanced Option > Resolution > just set your resolution compatible fit with your screen. then reboot If you didn’t found the menu on configuration, please update your raspberry pi software configuration tool (raspi-config). That’s … Read more

Flask – Calling python function on button OnClick event

You can simply do this with help of AJAX… Here is a example which calls a python function which prints hello without redirecting or refreshing the page. In app.py put below code segment. #rendering the HTML page which has the button @app.route(‘/json’) def json(): return render_template(‘json.html’) #background process happening without any refreshing @app.route(‘/background_process_test’) def background_process_test(): … Read more

How to install the Raspberry Pi cross compiler on my Linux host machine?

I’m gonna try to write this as a tutorial for you so it becomes easy to follow. NOTE: This tutorial only works for older raspbian images. For the newer Raspbian based on Debian Buster see the following how-to in this thread: https://stackoverflow.com/a/58559140/869402 Pre-requirements Before you start you need to make sure the following is installed: … Read more

Python AttributeError: ‘module’ object has no attribute ‘Serial’ [duplicate]

I’m adding this solution for people who make the same mistake as I did. In most cases: rename your project file ‘serial.py’ and delete serial.pyc if exists, then you can do simple ‘import serial’ without attribute error. Problem occurs when you import ‘something’ when your python file name is ‘something.py’.