Arduino, Programming

Arduino Uno and Nokia 5110 LCD

If you want to know how to wire & program a Nokia 5110 LCD using an Arduino Uno, you have come to the right place 🙂

Here are the parts needed:

  1. Arduino Uno (Qty: 1) (http://core-electronics.com.au/arduino-uno-r3.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  2. Nokia 5110 LCD (Qty: 1) (http://core-electronics.com.au/graphic-lcd-84×48-nokia-5110.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  3. Logic Level Converter (Qty: 2) (http://core-electronics.com.au/logic-level-converter-module.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  4. Lots of connecting wires
  5. USB cable for the Arduino Uno (USB A to USB B)

Here is my setup (made with Fritzing):

Uno5110_bb

Here are the software/libraries I used:

  1. Arduino 1.0.4
  2. Adafruit’s base library for the Nokia 5110 (https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library)
  3. Adafruit’s graphics library for the Nokia 5110 (https://github.com/adafruit/Adafruit-GFX-Library)

Here are the instructions to run the sample code:

  1. Extract the Adafruit libraries into “..\arduino-1.0.4\libraries\”.
  2. Your directory structure should look like this:
    \arduino-1.04\
    \arduino-1.04\libraries\
    \arduino-1.04\libraries\Adafruit_GFX\
    \arduino-1.04\libraries\Adafruit_GFX\Adafruit_GFX.cpp
    \arduino-1.04\libraries\Adafruit_GFX\Adafruit_GFX.h
    \arduino-1.04\libraries\Adafruit_GFX\glcdfont.c
    \arduino-1.04\libraries\Adafruit_GFX\license.txt
    \arduino-1.04\libraries\Adafruit_GFX\README.txt
    \arduino-1.04\libraries\Adafruit_PCD8544\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\pcdtest\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\pcdtest\pcdtest.pde
    \arduino-1.04\libraries\Adafruit_PCD8544\Adafruit_PC8544.cpp
    \arduino-1.04\libraries\Adafruit_PCD8544\Adafruit_PC8544.h
    \arduino-1.04\libraries\Adafruit_PCD8544\license.txt
    \arduino-1.04\libraries\Adafruit_PCD8544\README.txt
  3. Start the Arduino IDE
  4. From the File menu, click on Examples, then “Adafruit_PCD8544” and “pcdtest”.
  5. Find the following line:
    Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
  6. Change it to:
    Adafruit_PCD8544 display = Adafruit_PCD8544(13, 11, 7, 6, 5);
  7. Compile and download (or “upload” in the Arduino world).
  8. Done! You should see various graphic examples being displayed.
Arduino, Programming

Use Arduino Uno as an AVR ISP to burn the bootloader onto a SparkFun Pro Micro 5V

I have a SparkFun Pro Micro 5V running an older bootloader. In order to burn a new bootloader you need an ISP (In-System Programmer). You can buy an AVR ISP and use that, or you can use an Arduino Uno as an AVR ISP 🙂

Here are the instructions:

We turn the Uno into an ISP:

  1. Connect your Uno to your computer.
  2. Run the Arduino programming software.
  3. From the File menu, select Examples and click on “ArduinoISP”.
  4. Download this sketch to your Uno.

Now we wire in the ProMicro to the Uno. Don’t connect the ProMicro to your computer! And connect the following pins together:

  1. Uno Pin GND to ProMicro Pin GND
  2. Uno Pin GND to ProMicro Pin GND & GND (located on the other side of the board)
  3. Uno Pin 5V to ProMicro Pin VCC
  4. Uno Pin 13 to ProMicro Pin 15
  5. Uno Pin 12 to ProMicro Pin 14
  6. Uno Pin 11 to ProMicro Pin 16
  7. Uno Pin 10 to ProMicro Pin RST
  8. Remove the wire to VCC and put it back in. (I had some errors where didn’t work until I did a “reset” on the ProMicro)

We burn the bootloader:

  1. Close the Arduino programming software
  2. Download the new bootloader for the ProMicro (It’s the Add-on link located in https://www.sparkfun.com/products/11098?)
  3. Unzip that folder into “C:\…\arduino-1.0.4-windows\arduino-1.0.4\hardware”.
  4. Run the Arduino programming software.
  5. From the Tools menu, select Board and click on “SparkFun Pro Micro 5V/16Mhz”.
  6. From the Tools menu, select Programmer and click on “Arduino as ISP”.
  7. From the Tools menu, click on “Burn bootloader”.
  8. Wait a few minutes. You should see the RX & TX LEDs flashing on your Uno during the burning process.
  9. Done!

If it doesn’t work, the error is displayed in the console. If it works, it won’t show a message in the console but in the area just above it, “Done burning bootloader”.

Raspberry Pi

RPi – Turn of external hard drive when not in use

If you have a Raspberry Pi connected to an external hard drive and you keep it on all the time then you may find that the external hard drive continues to stay spinning, even though you aren’t reading anything from it. I have two problems with that:
1) Waste of energy (negligible but still)
2) Noise

The noise part annoys me the most because I like a little peace and quiet around the home 🙂

Anyway, I’m using a Seagate Expansion External Hard drive (3Tb) and it never stopped spinning…I found a solution! Follow these steps:

1) Run this command

sudo nano /etc/hdparm.conf

This will open the hdparm.conf file for editing.

2) Look for the line “# -B apm setting” and observe the line that follows. My one looked like this:
# apm = x
where x = some value.

3) Remove the # from the start of the line, and change the 127 to 1.

4) Hit Ctrl+X and press Y to save the file.

5) Reboot your RPi

That’s it!

Notes/FYI:
In Linux, the hdparam program is used to get/set hard drive parameter, see http://linux.die.net/man/8/hdparm. You can achieve the above by entering this:

sudo hdparm -B 1 /dev/sda2

where:

/dev/sda2 is the hard drive’s device path

1 means highest power management (254 is lowest power management)

The bad part is that you have to run that command each time you reboot your RPi. However, by editing the /etc/hdparm.conf file, it is automatically applied at boot time and it becomes the default setting for all hard drives.