IoT @ Pickup-Boxes
Last updated
Was this helpful?
Last updated
Was this helpful?
First, download and install the latest version of Python for your operating system (currently 3.10.0).
Next, download and install Visual Studio Code, an open-source integrated development environment, for your operating system.
To work with the Tinkerforge devices on your local computer, you need the Brick Daemon to connect to the devices on your USB port. Additionally, to play around with the devices, you can install the Brick Viewer.
When developing in multiple projects with Python, it is a good practice to create a virtual environment for each project. This way you can ensure that you don't have conflicting dependencies between different projects. To create a virtual environment for your project, start a terminal in VS Code and change to the directory where you want the project to be. I put all my code into a directory called c:\code
on my main drive:
Once created, you need to activate the virtual environment as follows:
After this command, the terminal should display this:
To work with Tinkerforge devices from our Python code, we need to install their official library:
You can copy the program code below into a new Python file (e.g., run.py
). Make sure you replace the UID
in line 3 with the correct value for your particular sensor. Run the program by typing python run.py
on the terminal.
If everything works correctly, the terminal should display the current humidity:
For most use cases, it makes sense to read the values continuously. Either in a certain time interval (e.g, every second), or whenever the value changes. The following example uses a so-called callback function callback_humidity
that is registered with the sensor (line 20) and called every 1000 milliseconds (line 23).
The result is a continuous output of the humidity value (every 1 second) until the user interrupts the program with ⌨ Ctrl + X.
You can find this example and the API documentation for all devices on the official Tinkerforge website:
Visual Studio Code allows you to extend the functionality with so-called extensions. For Python development, I recommend the Python extension. You can install the extension directly from VS Code. Click on the extensions tab on the left menu and type “Python” into the search field. takes you to the extensions' website on the VS Code marketplace.