Arduino clock and OLED display part 2

See this post here for a Joystick controlled Weather Clock with OLED display.

Although using the Adafruit libraries with the OLED was easy it uses a large amount of dynamic memory, about 90%. The code takes up just over 50% of the available memory, so there would not be much room for more code to run.

I found another library, U8GLIB that seemed to be less memory hungry, but perhaps a little slower. With this project speed is not a problem and the added advantage of this library is that it supports a wide range of display devices.

Getting the code to work with this library caused me a few headaches, but I eventually got it to go. The size of the code is almost identical to that used by the Adafruit version, but the dynamic memory usage was reduced to 48%. This would allow more code to be added later.

This library is not as simple to use as the Adafruit one, but is flexible and supports so many display devices and is well worth considering. Take a look at the website at https://code.google.com/p/u8glib/ and download the code. There is a comprehensive wiki available.

The code for this project can be downloaded from my Github page at https://github.com/rydepier/Arduino-OLED-Clock/tree/master.

This version uses a smoother font (profont15) and allows the analog clock to be moved on the screen by changing to variables, clockCentreX and clockCentreY. I looked at two ways of printing numeric variables as u8g.drawstring will only display strings. You can use u8t.print, but you must first fix the print position with u8g.PrintPos(x,y). A second method, which although it looks more complicated in fact uses less program memory and that is first to convert to a const char* as follows

const char* thisTemp = (const char*) thisTemp1.c_str()

Then display using

u8g.drawStr(100,10, thisTemp)

The print position being the first two numbers 100,10.

Arduino clock using an OLED display

See this post here for a Joystick controlled Weather Clock with OLED display.

I have just discovered the amazing OLED display. At just 0.96 inches in size the display is bright, crisp and clear.

Part 2 . of this blog shows how to use the U8gLib library instead of the Adafruit library.

This project uses a DS1307 RTC module to provide the time, a TMP 136 temperature sensor to show local temperature and the results are displayed on a 128×64 pixel display. Time is shown in ‘digital’ and analog format. The date is displayed along with air temperature.

The code for this project can be found on my github page at https://github.com/rydepier/Arduino-OLED-Clock/tree/master. You will also need the Adafruit OLED library found at https://github.com/adafruit/Adafruit_SSD1306. This page has a link to the Adafruit GFX library that you will need as well.

All this code leaves very little room on an Arduino Uno but enough for the clock code. Wiring details for the various units are given in the comments in the code. The RTC and OLED are I2C devices and have just four connections, 5volts, ground, SDA and SLC. SDA connects to Analog pin 4 (on a UNO) and SLC connects to Analog pin 5. The TMP136 has three connections, ground, output and Vcc. This code sets the ARef to 3.3 volts and Vcc on the TMP 136 is connected to 3.3 volts as well.

The display is built up in the buffer, then displayed with the command display.display

Continue reading “Arduino clock using an OLED display”

Raspberry Pi Camera part 2

Having got the camera to work correctly I found a site that started life as an app for an iPad then became web based and usable on any OS. The site is

http://pitography.github.io/BerryCamExpress/

The following is taken from that site and I recommend you visit it for the full version. A quick guide is here.

First of all make sure that you have the latest version of raspbian running on your Raspberry Pi:

sudo apt-get upgrade
sudo apt-get update

Install the Node packages for Raspberry Pi. These will be downloaded into the /home/pi folder:

wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz
cd /usr/local
sudo tar -xvzf ~/node-v0.10.2-linux-arm-pi.tar.gz –strip=1

Once this is completed, check the version installed:

node -v

You should see v0.10.2 or the version that you have installed. This concludes that NodeJS is now installed. Check that the Node Package Manager is installed:

npm -v

which should reveal the version number 1.2.15 or the version that you have installed.

We need to pull all the code that runs BerryCam Express down into your user directory (or the location of your choosing). To clone within the /home/pi directory:

git clone https://github.com/pitography/BerryCamExpress.git

This command installs a package, and any packages that it depends on. Although this take quite some time given the amount of processing power initially required, it makes it easy to fetch all the required components and libraries.

We re-issue the command:

cd BerryCamExpress
npm install

After a few minutes, the package will install additional dependencies that allow it to run.

Start the server

Now that we have all the necessary components in place, we can start the BerryCam Express server which allows devices to connect to your Pi and take photographs with the camera.

To start the camera server:

cd BerryCamExpress
cd dist
node berrycam-server.js

Browse to the pi on any device with a web browser on port 3000 – so if your pi was on IP address 192.168.0.5 then you would type

192.168.0.5:3000
The interface should appear on the screen. Press the camera button to take a test photograph.

Many thanks to the guys at BerryCam for a great project.