CHUSBIE552

Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Tuesday, 23 June 2015

Dirty Hack: repairing (Breaking it better) a raspberry A+,B+ or 2 microSD card Socket

This is just a quick and dirty hack that i have had to perform once in a while. Sometimes and I have to say this problem is quite rare the catch that holds the microSD card in the socket fails and it is impossible to get the card to stay in place.

  

I have had this problem passed over my desk a few times I have a little fix/break for this that works.

WARNING: ONLY TRY THIS AFTER EXHAUSTING ALL OTHER POSSIBILITIES OF REPLACEMENT OR REPAIR AS YOU WILL BE DAMAGING THE MIRCO SD CARD SOCKET FOR THIS TO WORK. THERE IS NO GUARANTEE THIS WILL NOT RENDER YOUR RASPBERRY PI MORE BROKEN THAN IT ALREADY WAS :)  I TAKE NO RESPONSIBILITY FOR BROKEN RASPBERRY PIs

So basically we are going to remove the catch and spring that retains and ejects the SD card. Hopefully without damaging the contacts.



Use some good sharp tweezers to lift the the tab of metal housing at the edge of the Raspberry Pi.


  

Once that is lifted then used the tweezers to hook out the the plastic catch and spring.


Then it is just a case of folding the tab back down again and squeezing the housing slightly so that it applies some pressure on the SD Card when it is inserted.


After that it should be a case of sliding in the SD card and powering up if you have done this right the Pi should boot.



I normally add a little tape over then in SD card just to make sure it don't knock it out.

Hope this helps some people out as mentioned at the beginning you are essential breaking the socket to fix it.

Monday, 15 June 2015

Simulating Keyboard Input in Python (Linux)

This is a big question that has very little good answers too it as I found out. Sorry if this is a little dry but this need to be shared.

NOTE: This is orientated towards Linux Python 2.6, the Windows Python solution is different.

How to I get Python to simulate keyboard key presses and releases?  For me this came up while trying to make a custom capacitive touch  controller with a on a Raspberry Pi for use with MAME or Minecraft Pi edition.

For this we going to use a Python Module called Uinput. This module can simulate keyboard, mouse or custom device. It can also migrate happily between programs in the desktop environment as well as the command line.

All of the following need to be completed on the command prompt or in a terminal window so if you are on the desktop go ahead and open your terminal program.

 

Prerequisites

There are a couple of extra development libraries that need  to be installed, before installing the python module otherwise Uinput will refuse to compile and install.

First of all it is always worthwhile making sure your apt repositories are up to date it is a good rule to do this before installing any new software, so to do this you need to
sudo apt-get update 
Then the development libraries that you need to install are libxtst-dev

sudo apt-get install libxtst-dev



Installing the module


Make sure that you have the python pip installer installed this will make it easier to build an install on your Linux system.
sudo apt-get install  python-pip
Then to install the module using the python pip installer.

sudo pip install python-uinput
If all the prerequisites are satisfied this will download compile and install the python module. :)

The module requires Uinput kernel module to be running this can easily be done with
sudo modprobe uinput
This will load the module this time round. I you want it to load every time you reboot your system then it will need to be added to the /etc/modules file. To edit the file from your command line.

sudo nano /etc/modules
Add an extra time to the line to the file with.
uinput
Then.
Ctrl + x
This will save and exit just hit  Y to confirm overwriting the file.

 

Using the module


So now that is all complete its only a case of writing some code.
import uinput
device =  uinput.Device((uinput.KEY_W,uinput.KEY_S))
import time
while 1:
        device.emit(uinput.KEY_W,1)
        time.sleep(0.5)
        device.emit(uinput.KEY_W,0)
        time.sleep(0.5)

This is a  little sketch to setup a two button device I'm just using this as an example but any device can be made with any number of keys so lets have a look at the code.

Lets have a look at what the code is doing.
import uinput 
This imports the required module into your python sketch.
 device =  uinput.Device((uinput.KEY_W,uinput.KEY_S))
This line creates a uinput device with two keys W and S all the letter keys emit as there lower case version unless it is modified with a shift.

import time
imports the time module for handling delays
while 1:
Repeat forever
        device.emit(uinput.KEY_W,1)
Keydown w key
        time.sleep(0.5)
wait 0.5 seconds
        device.emit(uinput.KEY_W,0)
Keyup w key
        time.sleep(0.5)
  
 This module could be used for making custom combos for games in MAME like street fighter or just allow automated control of some command line tasks. I am currently using it to make a custom game controller on with a Raspberry Pi's  GPIO connection.

Hope this helps out a few people as I found it tricky to get up and running in the first place hopefully I have covered that so people don't have the same difficulty.





Sunday, 14 June 2015

Fun with the Silicon Labs BIOMETRIC-EXP-EVB development board

This week I've been having a good look at the the BOIMETRIC-EXP-EVB dev board from Silicon Labs a Fab-less chip manufacturer based in Austin Texas.

The board is designed as an expansion board for their EMF32 Wonder GEKO development system. The board contains a SI1146 Ambient, IR , UV and 2D Gesture sensor, SI7013 Temperature and humidity and a TS3310 step up DC to DC coveter. The dev board also contains a Microchip 24AA024 eeprom that I believe it communicates with other Silicon Labs contains specific info about the board. It also has a green and red LED for good measure. This development board is around $29.00 at the moment so if you fancy toying with a selection of sensors then I recommend it.  

 This week I've been specificity trying out the  SI1146. This chip has the ability to  measure ambient light level, Infra red level and  measure UV index which is a standardised measurement of UV light level normally used in calculating sun burn time. The chip is also can sense 2D gestures using 2 external infra red LEDs its internal LED constant current driver and taking independent reading of refection from each of the LEDs with can then be used to calculate distance on 2 axis (distance from chip and north/south or east/west depending on the LED location)

Wiring up 

Just to note the development board is runs both power and logic at 3v3 so if your are using a 5v platform like and Arduino Uno you will require a I2C compatible logic level shifter for that data lines or there is a risk of damaging the dev board.

All the devices on the board communicates with a two wire serial protocol called I2C. This is a bus based protocol that requires devices on the bus to have individual 7 bit addresses. To use these I2C devices SDA ( serial data ), SCL (serial  clock ) and GND ( ground ) need to be connected.

 There is a little bit of a got-ya with wiring up this board  in the datasheet states that the the Si1146 SDA is connected to pin 16 and SCL is connected to pin 17 this is true for the JP3 header this is the one on the left side of the board, but on the right side the JP4 header it is connected to pin 15.  The INT pin is used for interrupt driven reading of the sensor when it when a sensors readings are ready this pin will change.

For my tests I'm using a Raspberry Pi B+  and coding in python using the SMBus module which runs the Raspberry Pi's I2C bus.

The pin numbers start at the bottom or south of the board and go across the header starting from the bottom row hopefully this picture makes more sense.



so hook up:
Raspi                                              Biometeric board
Pin 1                     3.3v                    Pin 2
Pin 3                     SDA                   Pin 16  
          Pin 5                     SCL                    Pin 17 on JP3 or Pin 15 on JP4
Pin 6                     GND                   Pin 1

Software 

I have spent a few hours getting this to run in Python and at this moment still working on the code to make it into a python module for the Si114x range possibly for a future development. My work so far is available on github Here.

The moment it is just a single program that runs the Si1146 and outputs its data on screen. 

So just type:

git clone https://github.com/rabid-inventor/SI1146-software.git
Then
cd SI1146-software/RaspberryPi/Python/
and to run the python script
sudo python si1146.py

This will output UV index , Proximity sensor and visible light level.

currently having a lot of fun with this sensor and will keep updating especially when I get as far as using the sensor to measure pulse and 2D gestures. At a later stage I will be revisiting the Si7013 temperature humidity sensor an see if I can finally get it running with a Raspberry Pi. 
        




    

Wednesday, 27 May 2015

Pi Supply Gert VGA666 Software Setup and Test


This is how to Set up the Gert VGA666 for Pi Supply I have a previous post on assembling the components if you haven't already done so please check it out here.

Installing and Configuring software 


Be aware that you are changing the where the Pi is going to output it video if you have the option I would recommend setting up over an SSH connection.

Firstly you'll need to download the required software to run the Gert VGA 666. Make sure your Pi has an internet connection.
git clone https://github.com/fenlogic/vga66.git


Then you will need to copy the driver file into /boot/ and rename it.
cd vga666/setup/
sudo cp dt-blob-dpi.bin /boot/
sudo mv /boot/dt-blob-dpi.bin /boot/dt-blob.bin

Now the final step is to add it to your raspberry pi configuration.

So to open the configuration file.
sudo nano /boot/config.txt
The you'll need to add.
 enable_dpi_lcd=1
display_default_lcd=1
This will enable the VGA output. Then you can set the output resolutions by adding
dpi_group=2
dpi_mode=82
 For 1080p @60Hz or.
dpi_group=2
dpi_mode=86
 For 1366 x 768 @60Hz





These are the two screen modes I have tried myself please now the resolution values are the same as setting the resolution for the HDMI output, a full list can be found here.

Problems you may run into 

The first time that I tried this the VGA work for about 10 seconds of boot time the the text turned yellow and then vanished dropping my screen into power saving.


I was using a Rasbian image that had some of the GPIO setup for various tasks so it was 'grabbing' some of the GPIO for other tasks this was fixed with a fresh burn of Raspbian.




In conclusion 

This is great add-on to the Raspberry Pi and the documentation makes for interesting reading as it goes into an explanation of how it generates and analogue signal from the GPIO header, and makes for great learning and soldering practice.

This is in no way the perfect solution for VGA output on the Raspberry as it will have the occasional slight shimmer on the display and it uses huge chuck of you GPIO to drive it. So if your you are looking for a VGA output from your Raspberry Pi I'd recommend a good HDMI to VGA adapter.

So I award this 3 of 5 Sparks it was fun to assemble the documentation could be a little clearer but as a learning exercise it's fantastic.

Sunday, 24 May 2015

Pi Supply Gert VGA666 Assembly

So i have had this rocking around for some time now and I though it was high time that i gave it a test run.

This is the Gert VGA666 from Pi Supply. Designed a by Gert Van Loo of Raspberry Pi fame and ran as a successful kickstarter campaign back in October 2014 ( which is where mine has come from ).

The Gert VGA666 is a clever breakout board for the Raspberry Pi that allows it to use the GPIO header to generate a VGA signal.  This done with only 20 Resistors to mimic an analog signal  the VGA monitor use the obvious downside to this is that you use up a lot of the GPIO pins.

 Assembly       

On the Pi Supply product Page there is a link to a Github Repository that contains the instructions, some of the details on how it works and the required files to make the Pi work with it .


This is the what comes in the Kit:
  • PCB 
  • 20 Resistors 
  • VGA socket 
  • extended GPIO Connector 
  • 2 Stickers and a Business card directing you towards the Pi Supply Website 
 This first thing I recommend doing is layout the parts and use a multimeter to check and label the tapes of resistors with all their values on the blue cased film resistor I find the colours hard to distinguish so i usually go straight for the multimeter as better choice than tying to remember my resistor band colours.


Labeling just helps when you come to the placing the parts. there should be:

  • 2 x 120 ohm
  • 3 x 500 ohm
  • 3 x 1K ohm
  • 3 x 2K ohm 
  • 3 x 4K ohm
  • 3x  8K ohm 
  • 3 x 16K ohm 

I find the colour key in the instruction a little hard to follow so here is a Bill of Materials for the Resistors.
 Label            Resistance (ohms)
R2 -          500
R4 -          1000
R6 -          2000
R8 -          4000
R10 -        8000
R12 -        16000
R14 -        500
R16 -        1000
R18 -        2000
R20 -        4000
R22 -        8000
R24 -        16000
R26 -         500
R28 -        1000
R30 -        2000
R32 -        4000
R34 -        8000
R36 -        16000
R38 -          120
R40 -          120

Then it is just a case of placing all the resistors in their correct locations and fold the leads outward for me I like to place all the resistors first as this lest me see if I have any location wrong before soldering.


The back of the PCB becomes a bit of a 'Rats Nest' of resistor leads but there is plenty of space to solder them form the topside.



After soldering use a sideways cutter to trim all the leads if and if there are any joins looking a little low on solder apply more (best to do this as a better solder joint will give a more stable signal).


 now make sure the PCB is the correct way up for the next bit the instructions say 'The Connectors are at the same side as the surface mount resistors'

Then it is just a case of soldering first the GPIO connectors soldering one corner pin first to make sure that it is flush to the board then solder the rest of the pins you can insert the VGA connector if it makes the PCB a bit more stable to solder for you.

Then solder up the VGA connector.

ALL Assembled!

I will continue the software setup and testing in another post. Click Here

 

Saturday, 17 January 2015

Flotilla The NEW making tinkering platform for the Raspberry Pi by Pimoroni

Kickstarter is all a buzz with excitement as Pimoroni launch their new campaign.



Flotilla is a brand new development platform for the Raspberry Pi with a focus on 'Hassle-free Digital tinkering for everyone'

Flotilla consists of a Dock that different Modules plug into consisting of sensors, controls motors and displays.



The Platform is designed to be used by everyone from a young beginner to hardened maker with programming systems from basic suggested 'Cookbook' projects ,a webpage icon based programming interface called 'Rockpool' to well supported Scratch implementations and python Modules.



At the writing of this post The Campaign was over 1/2 funded within a few hours at over £16500 and 191 Backers :)

This is a fantastic project that, if executed right will make entry into tinkering with electronics so much easier, removing the need to understand wire protocols and endless debugging, and just getting on with being creative.

UPDATE: 
As of around 9.30am 18/01/15 Flotilla reached its campaign goal of £32,768 it has really raced through hitting its goal in just over 24hrs, and at writing this update was most of the way to £40K.

This is an incredible pace and hopefully there will be many stretch goal to keep new backers clocking in, It is made even more incredible because it has only been advertised through twitter and Bloggers like myself Mike Horne and a few others (sorry if I haven't listed you, I can only find this one at the mo ;) ) .

At this point  Kickstarter prediction engine Kicktraq predicts based on current trend could reach just shy for £600,000 by the end of the campaign.

Watch and see :)