Posted on 17 Comments

Battery Monitoring for tinkerBOY Controller V3

This tutorial is covers the steps on how to enable battery monitoring for the tinkerBOY Controller v3. Make sure your v3 is plugged in or connected to your Raspberry Pi before setting up the Battery Monitoring service.

Step 1. BATT+ to battery’s positive wire.

Solder a wire from the BATT+ pin on the v3 to the positive wire(red) of the battery.

Step 2. Setup the battery monitoring script.

Login to your Pi via SSH and type the following command:

wget -O - https://www.tinkerboy.xyz/setup.php -q | bash -s bm

It will install the necessary software for the battery monitoring service. It will also upgrade your v3’s firmware if needed.

When it’s done you should get an “OK!” message if it’s successful. Otherwise, let me know when you get an error.

Step 3. Enable the Battery Monitoring service.

Type or copy paste the following commands:

sudo systemctl daemon-reload
sudo systemctl enable battmon.service
sudo systemctl start battmon.service

Issuing these commands will immediately start the Battery Monitoring service.

That’s it. Have a nice day! 🙂

Posted on Leave a comment

Raspberry Pi Headless Wifi Setup

Fritzing

Sometimes you just want to connect your Raspberry Pi to your Wifi immediately when you first install RetroPie or Rasbian just so you can tinker with it soon and setup some stuff.

STEP 1. On a Windows PC insert your newly installed SDCard

With the sdcard plugged in (USB SDCard reader) your Windows 10 computer, fire up File Explorer and go to the boot partition of your sdcard.

Step 2. Setup Network or WiFi Info

Create a file called wpa_supplicant.conf inside the boot partition of the sdcard. Open it with any text editor like notepad and paste the following.

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="WIFI-NAME"
    psk="WIFI-PASSWORD"
}

Replace “WIFI-NAME” and “WIFI-PASSWORD” with your wifi details. Save and exit.

Step 3. Enable SSH

Enable SSH so you can connect to your raspberry pi from any computer. Create a blank file called ssh inside the same boot directory of your sdcard.

Finally, eject the sdcard properly and plug it in to your Raspberry Pi. Turn on your Pi and it should connect to your network automatically.

Posted on 2 Comments

Raspberry Pi 3: Wire It Directly From The Power Supply

In order to avoid power related issues with any of the Raspberry Pi 3 model, it is recommended to just directly power it from your power supply (PowerBoost 1000c, GearBest PowerBoost, etc.).

So here’s how you would power your Pi 3 which is the same for all the models (Model B, Model B+, Model A+). The PP2 pad goes to the 5V+ output of your Power Supply and the PP5 pad goes to the GND output of your Power Supply. Use a wire that’s 24-26awg in size.

Posted on 4 Comments

5V Boost + Battery Charger + Safe Shutdown = tinkerBOY PowerSwitch

I’m currently working on a power board for Game Boy Zero which I will be calling the tinkerBOY PowerSwitch. It’s supposed to be a builtin upgrade for my tinkerBOY Controller v3.0 but I decided to design it separately and integrate a slide switch. This way, it’s not limited to just my v3 but can be used by anyone using any controller board as well as my other controllers like the v1.1, v1.2, v2.0.

The 3 most important features will be 5V boost, battery charger, and a safe shutdown feature. I’m almost done with the design and I will be ordering some PBCs soon so I can test it. So don’t forget to subscribe to my facebook page at https://www.facebook.com/tinkerBOY/ for updates.

Update: tinkerBOY PowerSwitch has been realeased!

Posted on Leave a comment

How To Setup Putty To Automatically Login To Your Raspberry Pi

I’m always looking for ways to save time so here’s how you can setup putty to automatically login to your Raspberry Pi.

Let’s Get Started

  1. Go to the folder where you installed putty.exe, left click on it to select it, right click on it and choose “Create shortcut”. 
  2. Select the newly created shortcut file, right click on it and select “Properties”. In the “Target” text field, add the line  pi@ip -pw raspberry replacing the ip with your Raspberry Pi’s ip address. 
  3. Click OK and you’re done. Now every time you open the shortcut link it will automatically login to your raspberry pi.

That’s it! 🙂

Posted on 11 Comments

tinkerBOY DPI Adapter v1.0: Visual Guide for Raspberry Pi Zero (without header pins)

This method does not use a 40-pin header pins but it’s easier. Place the  Pi Zero on top of the DPI Adapter and align the holes. Use a binder clip to hold them together.

Now, start soldering each of the Pi Zero’s GPIO holes making sure there’s a proper contact to each of the holes on the DPI Adapter.

You can also solder from the bottom just to make sure each holes are soldered properly.

The final step is to solder the Pi Zero’s USB data pins (D+ and D-) to the 2 holes on the DPI Adapter. These holes will connect the Pi Zero’s data pins to the D+ and D- pads on the adapter for connecting any USB device. (Note: The D+ and D- pads on the DPI board V1.0 are mislabeled. The upper pad should be D- and the lower pad should be D+. Thanks to Paul for reporting.)

UPDATE: The D+ and D- data pins are now correctly labeled on v1.1 and moved to front left of the board just above the 5v and GND pin holes.

The 5VIN and GND pin holes below the tinkerBOY DPI Adapter are your 5v and GND inputs.

Posted on 9 Comments

tinkerBOY DPI Adapter v1.0: Visual Guide for Raspberry Pi Zero

Start by placing the header pins in to the pin holes designed for the Pi Zero:

And mount the Pi Zero this way:

It’s recommended to put a kapton tape or anything in between the adapter and pi zero to avoid shorts before soldering the header pins to the Pi.

The next step is to cut the pins and plastic below the header pins and solder them to the DPI Adapter.

The final step is to solder the Pi Zero’s USB data pins (D+ and D-) to the 2 holes on the DPI Adapter. These holes will connect the Pi Zero’s data pins to the D+ and D- pads on the adapter for connecting any USB device. (Note: The D+ and D- pads on the DPI board are mislabeled. The upper pad should be D- and the lower pad should be D+. Thanks to Paul for reporting.)

The 5VIN and GND pin holes below the tinkerBOY DPI Adapter are your 5v and GND inputs.

Posted on 24 Comments

tinkerBOY DPI Adapter: Gettting Started Guide

Method 1: Download my pre-built RetroPie image.

Method 2: Manual

Edit the config.txt and copy/paste the following lines:

dtoverlay=dpi18_666
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
enable_dpi_lcd=1
display_default_lcd=1
dpi_group=2
dpi_mode=87
framebuffer_width=320
framebuffer_height=240
dpi_output_format=24598
hdmi_timings=320 1 20 30 38 240 1 4 3 15 0 0 0 60 0 9600000 1

Save the file.

The tinkerBOY DPI Adapter v1.0 uses a custom overlay for the DPI interface. Download this file, unzip and place the dpi18_666.dtbo file inside the overlays folder in the boot partition of the sdcard where the config.txt is also located.

That’s it for the settings.

Guides for v1.0/v1.1:

NOTE: DO NOT turn the power on without connecting the LCD (LQ035NC111).

Posted on 13 Comments

How To Add Brightness Control For The 3.5″ GearBest Screen

This guide might also work on any screen that we use for building our Game Boy Zero as long it uses the CL6201 LED driver IC with the “7001” label on it.

I will be using a Raspberry Pi Zero for this tutorial but any Arduino/Atmel chips with PWM pins can also be programmed to do the job. I have actually tested it with an attiny13a and it works just fine.

Hardware

Before we start, follow the Wiring Guide for the 3.5″ GearBest Screen with 5V Mod. Then start by soldering a wire from the CL6201’s EN pin 4 to the Pi Zero’s GPIO19 pin. The CL6201 Datasheet says that the EN pin can be used to adjust the brightness by connecting it with a PWM square wave signal between 100Hz and 100KHz. That means with the Raspberry Pi’s capability to produce PWM signal we can control the brightness with it.

For the control buttons let’s use two tactile buttons for increasing and decreasing the brightness. Wire the buttons like this:

Software

You can write a program in Python or C to do the PWM routine but let’s keep it simple by using a progam called pigpio and write a simple python to just call it. Login to your Raspberry Pi and install the program by following the instruction at abyz.me.uk/rpi/pigpio/download.html.

Testing

We are now ready to test the program. Type the command sudo pigpiod to load the pigpio daemon. Now we can test it with the following command format:

pigs p GPIO DUTYCYCLE(0-255)

GPIO is the gpio pin we want to use which is GPIO19 and DUTYCYCLE is what controls the brightness.

Example:

pigs p 19 50

The above code should dim the screen. Try experimenting with other DUTYCYCLE values from 0-255.

Now for the actual buttons to control the brightness I wrote a simple python to call the pigpio program. Copy the code below and paste to a new file with .py extension. You can just name it as brightness_controller.py if you want.

import RPi.GPIO as GPIO

import subprocess
import time

dutycycle = 255
GPIO.setmode(GPIO.BCM)
BTTN_DIM = 15
BTTN_BRIGHT = 16
PWM_PIN = 19
 
GPIO.setwarnings(False) 

GPIO.setup(BTTN_DIM, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(BTTN_BRIGHT, GPIO.IN, pull_up_down=GPIO.PUD_UP)
cmd = "pigs p 19 " + str(dutycycle)
subprocess.call(cmd, shell=True)

def btn_func(a):
   global dutycycle
   global cmd
	
   if a == 1:
      dutycycle = dutycycle + 25
   else:
      dutycycle = dutycycle - 25
   
   cmd = "pigs p 19 " + str(dutycycle)   
   subprocess.call(cmd, shell=True)
    

GPIO.add_event_detect(BTTN_DIM, GPIO.FALLING, callback=lambda x: btn_func(0), bouncetime=300)
GPIO.add_event_detect(BTTN_BRIGHT, GPIO.FALLING, callback=lambda x: btn_func(1), bouncetime=300)

while 1:
   time.sleep(10)

Run it by typing the command  python brightness_controller.py. Press each of the buttons and it should increase or decrease the brightness on the screen.

Here’s a demo:

That’s it! Let me know in the comment below if this works for you.

Posted on 10 Comments

Wiring Guide for the 3.5″ GearBest Screen with 5V Mod

I get a lot of wiring inquiries about the 3.5″ GearBest Screen so I decided to make one.

Most of these 3.5″ screens are intended for 12v power supply. The 12V input goes to a chip called XL1509 and converts that to 5V. Like any DC to DC converter there’s always going to be wasted power as a result of the conversion. This is the reason why I highly recommend that you do the 5v mod eventhough the screen works if you feed it with 5v without the need for any modification.

To make the connections more reliable let’s remove the Female JST connector..

..just be careful not to lift the contact pads which I’ve mistakenly done here. Luckily the board has two video connections which are AV1 and AV2. I will be using the AV1.

Cut the cable that came with it and solder the wires directly to the board. In order to do the 5V mod, you just solder the RED wire directly to the XL1509’s Pin 2 or to the SS24’s cathode pin which is easier to solder to. The other end of the RED wire goes to your 5v power supply of course (PowerBoost 5v output). Since the Raspberry Pi only requires just one video connection, solder the YELLOW wire to the Pi’s TV connection. Join the WHITE and BLACK wire and solder them directly to the GND pad on the screen board. The WHITE(GNDTV) wire goes to the GND beside the TV pin on the Pi while the BLACK wire goes to your normal powerboost’s GND output.

Yep, That’s it!

Posted on 1 Comment

Raspberry Pi: Downmixing From Stereo to Mono Sound Output

First, let’s choose which device to use. Enter the command cat /proc/asound/modules to list all available sound devices whether it’s a PWM audio or USB sound device.

The command you just entered should output something like:

0 snd_bcm2835 << this is the PWM audio I configured on GPIO18 & GPIO13.
1 snd_usb_audio << this is my USB sound device.

Enter the command sudo nano /etc/asound.conf and paste the following code:

# convert stereo to mono LEFT output

pcm.monocard{
  slave.pcm "hw:N"
  slave.channels 2
  type route
  ttable {
    # Copy both input channels to output channel 0 (Left).
    0.0 1
    1.0 1
    # Send nothing to output channel 1 (Right).
    0.1 0
    1.1 0
  }
}

pcm.!default monocard

Change the N on the line slave.pcm "hw:N" to  the number that corresponds to the audio device you want to use. I will be using my USB audio device so mine should read slave.pcm "hw:1".

The above code uses both left and right audio input to output to LEFT channel. If you want the output to the RIGHT then you can just edit the line 8 – 14 to:

# Copy both input channels to output channel 1 (Right).
0.1 1
1.1 1
# Send nothing to output channel 0 (Left).
0.0 0
1.0 0

Restart ALSA by sudo /etc/init.d/alsa-utils restart or you can reboot your Raspberry Pi using sudo reboot.

Posted on 5 Comments

Raspberry Pi: Test Sound Output

If you’re wondering how to test the left and right audio channel of your Raspberry Pi whether using an external USB sound device or the builtin audio you’ve come to the right place.

Connect to your Raspberry Pi via SSH or open the Terminal application. The simplest way to test the sound is to use the speaker-test command. Enter the following to test sound from your default configured audio device.

speaker-test -c2 -twav -l7

You should hear an alternating sound coming from your left and right speakers.

If you’re using a USB sound device you first need to check its device id/number.

Enter:

cat /proc/asound/modules

Output:

0 snd_bcm2835
1 snd_usb_audio

Then use speaker-test -c2 -twav -l7 -D plughw:N,0 replacing N with the number before snd_usb_audio. Like this:

speaker-test -c2 -twav -l7 -D plughw:1,0

Output should the same as the picture above and alternating sound from left and right audio from your speakers.

Using omxplayer to test mp3 or wav sound file

omxplayer example.mp3

The above command will auto-detect or use any default configured audio device. Otherwise, if you want to test your USB Sound device enter the following command with 1 as the device number:

omxplayer example.mp3 -o alsa:hw:1,0