Raspberry Pi IoT Projects for Fun and Profit
In this post, I will explain how to run an IoT project from the command line, without graphical interface, using Ubuntu Core in a Raspberry Pi 3.
Now, let’s blink a LED. To install some libraries (including Machine Learning ones) you will need to install the latest version of setuptools, install pip and Rpi.GPIO, which is the library that allows you to send data through Raspberry pins. Also, you will need to set up some permissions.
Below I present the Raspberry Pi 3 pin mapping, with respective numbers assigned:
You can also generate this mapping in the command line:
Connect your LED the following way, using a resistor:
Create the LED.py notebook:
Then, CTRL+C i CTRL+SHIFT+V the following code:
Type ESC : wq
The Raspberry will send an energy pulse to pin 8 each one second, turning on the LED:
Another option is to attach a buzzer KY-012, that will emit a sound every time GPIO output is set to High.
The LED and CPU Temperature are the simplest projects one can develop using a Raspberry Pi. Now let’s install Keras and Tensorflow in a Raspberry running Ubuntu Core, a non trivial task at the time this project was developed. As Ubuntu Core is a minimalist OS, it does not have wget, unzip and many libraries’ dependencies.
Now let’s install Python libraries:
Reboot. Run commands to install libraries and their dependencies:
Now we will install Tensorflow for ARM systems.
These steps below will take one hour or longer.
Now all Machine Learning libraries are installed at $ sudo python3
(Note that Tensorflow lately has released an easier way to install its library in ARM systems via pip)
Now you can attach a camera, use OpenCV for object detection, face recognition, attach a Movidius stick, collect temperature, or even develop a self driving car project with built in kits. Here are some simple ideas:
1 - Connect a Temperature sensor and after a defined threshold, generate light (via LED) and play a sound (buzzer).
2 - Connect a sound detector (cylinder below on the left, red circuit) and every time a sound above a certain level (adjusted in the potentiometer, blue box behind wires) is detected, turn on a laser light (center) and a LED (right).
3 - Connect an infrared receiver (black tube on red circuit right below) so that you can deploy code automatically by switching on your air conditioning remote control, at the same time sensors emit light and sound when the process is successful.
This automation idea is an adaptation of what was seen here, published by Amazon Web Services: https://www.linkedin.com/feed/update/urn:li:activity:6437325206838140929
4 - Develop a simpler version of the project mentioned above, by connecting a push button sensor directly to the Raspberry Pi:
A general overview of the ongoing project and these ideas can be seen at my GitHub repository: https://github.com/RubensZimbres/Repo-2018/tree/master/Raspberry%20Pi3%20IoT-Project
Bio: Rubens Zimbres is a Data Scientist, PhD in Business Administration with emphasis in Artificial Intelligence and Cellular Automata. Currently works in Telecommunications, developing Machine Learning, Deep Learning models and IoT solutions for the financial sector and agriculture.
- Deep Learning on the Edge
- Role of IoT in Education
- Introduction to Trainspotting: Computer Vision, Caltrain, and Predictive Analytics