We have been busy over the last 6 months creating something special! We have always liked the idea of LED cubes, however there was no easy way to drive these LED cubes with a Raspberry Pi.... until now.
VoxCube is an 8x8x8 RGB LED Cube which has been specifically designed for the Raspberry Pi, however it is also compatible with other microcontrollers. E.g. Arduino
Cubes can also be chained together, the image below is four VoxCubes being controller via a Raspberry Pi.
Head over to the Kickstarterpage for more details.
Here is a great post by mincepi which shows how to enable VGA output on a Pi Zero for less than $5
The vga666 by Gert is already a low cost VGA output option for the Pi. But we can do better with the Zero! We'll use 16 bit output instead of 18 bit: this frees up the SPI and I2C ports with little loss in quality. The resistors can be soldered between the Zero and the adapter, making the PCB smaller and eliminating a connector. I've determined that 5% resistors are good enough: no need for higher cost 1% units. By not using the middle row of pins in the HD15 connector, we can straddle-mount it on the PCB edge. Finally, the connector can be male, so the Zero will connect to the monitor ChromeCast style: no VGA cable needed. (This connector could even be scrounged from an old VGA monitor cable for free!) If you order the boards from OSHPark, it will cost $4.95 for three copies. Enough resistors and connectors to build three will cost $5.92 from Digi-Key. That works out to $10.87 to build three, or $3.62 each!
We have confirmed that BerryIMU is 100% compatible with the Pi Zero. BerryIMU can sit right on top of Pi Zero header pins while still maintaining a very low profile.
To make some of your text more readable, you can use ANSI escape codes to change the colour of the text output in your python program. A good use case for this is to to highlight errors.
The escape codes are entered right into the print statement.
print("\033[1;32;40m Bright Green \n")
The above ANSI escape code will set the text colour to bright green. The format is; \033[ Escape code, this is always the same 1 = Style, 1 for normal. 32 = Text colour, 32 for bright green. 40m = Background colour, 40 is for black.
This table shows some of the available formats;
Text color
Code
Text style
Code
Background color
Code
Black
30
No effect
0
Black
40
Red
31
Bold
1
Red
41
Green
32
Underline
2
Green
42
Yellow
33
Negative1
3
Yellow
43
Blue
34
Negative2
5
Blue
44
Purple
35
Purple
45
Cyan
36
Cyan
46
White
37
White
47
Here is the code used to create the coloured text in the title image;
print("\033[0;37;40m Normal text\n")
print("\033[2;37;40m Underlined text\033[0;37;40m \n")
print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
print("\033[5;37;40m Negative Colour\033[0;37;40m\n")
print("\033[1;37;40m \033[2;37:40m TextColour BlackBackground TextColour GreyBackground WhiteText ColouredBackground\033[0;37;40m\n")
print("\033[1;30;40m Dark Gray \033[0m 1;30;40m \033[0;30;47m Black \033[0m 0;30;47m \033[0;37;41m Black \033[0m 0;37;41m")
print("\033[1;31;40m Bright Red \033[0m 1;31;40m \033[0;31;47m Red \033[0m 0;31;47m \033[0;37;42m Black \033[0m 0;37;42m")
print("\033[1;32;40m Bright Green \033[0m 1;32;40m \033[0;32;47m Green \033[0m 0;32;47m \033[0;37;43m Black \033[0m 0;37;43m")
print("\033[1;33;40m Yellow \033[0m 1;33;40m \033[0;33;47m Brown \033[0m 0;33;47m \033[0;37;44m Black \033[0m 0;37;44m")
print("\033[1;34;40m Bright Blue \033[0m 1;34;40m \033[0;34;47m Blue \033[0m 0;34;47m \033[0;37;45m Black \033[0m 0;37;45m")
print("\033[1;35;40m Bright Magenta \033[0m 1;35;40m \033[0;35;47m Magenta \033[0m 0;35;47m \033[0;37;46m Black \033[0m 0;37;46m")
print("\033[1;36;40m Bright Cyan \033[0m 1;36;40m \033[0;36;47m Cyan \033[0m 0;36;47m \033[0;37;47m Black \033[0m 0;37;47m")
print("\033[1;37;40m White \033[0m 1;37;40m \033[0;37;40m Light Grey \033[0m 0;37;40m \033[0;37;48m Black \033[0m 0;37;48m")
\n")
When troubleshooting issues on a Raspberry Pi sometimes it is helpful to go back and look at the boot log, especially if you are running a headless (no monitor) Raspberry Pi.
Install bootlogd
pi@raspberrypi ~ $ sudo apt-get install bootlogd
You will be asked to restart services, select 'Yes'. And then reboot your Raspberry Pi
View Boot Log
From now on, if you wish to view the bootlog, you can use the command below to format it correctly;
pi@raspberrypi ~ $ sed 's/\^\[/\o33/g;s/\[1G\[/\[27G\[/' /var/log/boot
You will get the output as shown in the image at the top of this post.
Part 1 covered how to get the heading from the magnetometer, however this is only reliable when the magnetometer is on a flat surface. If the magnetometer is tilted, the heading will skew and not be correct.
The chart below shows a compass being held at 200 degrees and being tilted in various directions. The blue line is the raw heading, the orange line is the heading after applying tilt compensation. As you can see, without tilt compensation the heading will change if the compass is tilted.
This guide covers how to use an Inertial Measurement Unit (IMU) with a Raspberry Pi to create an inclinometer, just like the type you will find in a 4WD.
A prerequisite for this guide is to have a gyro and accelerometer from an IMU already up and running on your Raspberry Pi. A guide to interfacing an IMU with a Raspberry Pi can be found here.
We will be covering some basic SDL which will be used to produce our graphics.
The IMU used in this guide is the BerryIMU. However, other IMUs or accelerometers and gyroscopes can be used..
This guide covers how to use an Inertial Measurement Unit (IMU) with a Raspberry Pi . This is an updated guide and improves on the old one found here.
I will explain how to get readings from the IMU and convert these raw readings into usable angles. I will also show how to read some of the information in the datasheets for these devices.
This guide focuses on the BerryIMU. However, the theory and principals below can be applied to any digital IMU, just some minor modifications need to be made.
Git repository here The code can be pulled down to your Raspberry Pi with;
When using the IMU to calculate angles, readings from both the gyro and accelerometer are needed which are then combined. This is because using either on their own will result in inaccurate readings. And a special note about yaw.
Gyros - A gyro measures the rate of rotation, which has to be tracked over time to calculate the current angle. This tracking causes the gyro to drift. However, gyros are good at measuring quick sharp movements. Accelerometers - Accelerometers are used to sense both static (e.g. gravity) and dynamic (e.g. sudden starts/stops) acceleration. They don’t need to be tracked like a gyro and can measure the current angle at any given time. Accelerometers however are very noisy and are only useful for tracking angles over a long period of time.
Accelerometers cannot measure yaw. To explain it simply, yaw is when the accelerometer is on a flat level surface and it is rotated clockwise or anticlockwise. As the Z-Axis readings will not change, we cannot measure yaw. A gyro and a magnetometer can help you measure yaw. This will be covered in a future guide.
The IMU used for this guide is a BerryIMUv3 which uses a LSM6DSL, that consists of a 3-axis gyroscope plus a 3-axis accelerometer and a LIS3MDL which is a 3-axis magnetometer.
LSM6DSL - Accelerometer and gyroscope datasheet can be found here.
LIS3MDL - Magnetometer datasheet can be found here
This IMU communicates via the I2C interface.
The image below shows how to connect the BerryIMU to a Raspberry Pi
This will be a multipart series on how to use a digital compass(magnetometer) with your Raspberry Pi.
The magnetometer used in these tutorials is a LSM9DS0 which is on a BerryIMU. We will also point out where some of the information can be found in the Datasheet for the LSM9DS0. This will help you understand how the LSM9DS0 works.
The math and logic in this series can also be used with other magnetometers or IMUs.
We will also go over how to do some basic communication on the i2c bus. As well as using SDL to display the compass heading as traditional compass as shown in the video above.
Git repository here The code can be pulled down to your Raspberry Pi with;
A traditional Magnetic compass (as opposed to a gyroscopic compass) consists of a small, lightweight magnet balanced on a nearly frictionless pivot point. The magnet is generally called a needle. The Earth’s Magnetic field will cause the needle to point to the North Pole.
To be more accurate, the needle points to the Magnetic North. The angle difference between true North and the Magnetic North is called declination. Declination is different in different locations. This angle varies depending on position on the Earth's surface, and changes over time.
The strength of the earth's magnetic field is about 0.5 to 0.6 gauss .