December 30, 2012

TFT Touch Shield : Temperature And Timer

Instead of version 2.0 I've received the TFT Touch Shield Version 1.0 from Seeedstudio. This version doesn't have a SD-card and uses lots of pins for the communication. Version 2.0 instead uses the SPI protocol for communication. So, my blog post about SPI isn't necessary.

But this also simplifies the first version of my project:
  • display inside and outside temperatures
  • implement a timer with touch buttons

Temperature Measurement

For the temperature measurement I'm using two DS18S20 temperature sensors from maxim integrated (see also my posting Temperature Sensors DS18B20). The TFT Touch Shield Version 1.0 uses nearly all pins from the Arduino board. Only analog pin A4 and A5 aren't used and those pins can be used as digital input pins. The DS18S20 temperature sensors are using the 1-wire interface and therefore only one pin is needed for the measurement.

The DS18S20 example code uses a delay(1000) which blocks the application and touch buttons of the timer. I've split the temperature measurement into two parts and the second part will be called after one second.

TFT and Touch Library

I've been using the TFT and Touch library which is mentioned in the Seeedstudio forum 2.8" TFT Shield Link : TFT_TouchScreen_for_Arduino_1.0.zip

This library is straight forward:

  • draw text with position, size and color
  • draw rectangles filled or not filled with position, width, height, and color
  • draw lines (not used at the moment)
  • and getting the touch position is also simple: just read the x and y position and it is also possible the get the z position for pressure. Depending on the position you can simulate a button (see timer).
The TFT Touch Shield isn't very fast (maybe Version 2.0 with an other chip is faster). You can see it when the TFT is drawing the items.
Drawing some text doesn't erase the previous text. Therefore the old text has to be overwritten overdrawn. For the temperature display I've been drawing a gray rectangle before the next temperature text is shown which results to a flickering view.
For the timer display I've reduced the flickering. I've been comparing each character from the old value with the new one and if it doesn't differ, I replace the values with a space. Therefore the old value isn't overwritten. Only those characters which differs has to be erased by a black color and drawn new.

The library also comes with a font. Each character is drawn by a 8x8 pixels. The text can have different sizes, but as bigger the size the more you can see the pixels (there's no anti-aliasing). Only ASCII characters from 0x20 (32dec) to 0x7e (126dec) are supported. This means umlauts aren't supported. 

Timer

For the timer I've been using a plus and minus sign to adjust the time by increases or decreases. Clicking on the time the timer starts to count down. To get the position and the button is very simple (as mentioned above). I've defined an area around the buttons and if the touch position is inside this area, the value changes or the timer starts. For the plus / minus button there's also a visual feedback by changing the color of the button in blue.

Source Code

... is available on github: https://github.com/choas/arduino-choas/tree/master/TftTouchTemperature

Next Version


This is my first simple version for a temperature display and timer. For the next version a temperature diagram would be nice to see the temperature changes during day and night. To switch between normal view and diagram view an image would be also nice.

I think version 2.0 of the TFT Touch Shield with a SD card simplifies this by reading an image and storing / reading the temperature data ...


December 28, 2012

SPI and Arduino

The TFT Touch Shield V2.0 (from Seeedstudio) uses the Serial Peripheral Interface SPI protocol. For Arduino a SPI library is available to communicate with SPI devices. Arduino is the master device.

Jeremy Blum explains the SPI interface in the Tutorial 8 for Arduino: SPI Interfaces:

Wikipedia has also something about the Serial Peripheral Interface Bus.

December 27, 2012

Temperature Sensors DS18B20

For my upcoming TFT Touch Shield project I've setup two DS18B20 temperature sensors. These sensors using the 1-wire interface which means that I just need one Arduino pin for those two sensors.

The first temperature sensor (sensor above in the image) is connected with VDD, DQ (Data In/Out) and GND. Between VDD and DQ there's a 4.7 kOhm resistor. The second one (sensor below in the image) is only connected by DQ and GND. This one is in parasite mode which takes the power from the DQ and therefore doesn't need an external power supply. The temperature sensor is a DS18B20+PAR which already connects internally Pin 1 (GND) and Pin 3 (VDD).


This is the Arduino Serial Monitor output using the OneWire example code:


    R=28 2A 4C 3C 4 0 0 6B Device is a DS18B20 family device.
    P=1 53 1 4B 46 7F FF D 10 E9  CRC=E9
    21.18
    R=28 C6 96 90 4 0 0 67 Device is a DS18B20 family device.
    P=1 51 1 4B 46 7F FF F 10 FE  CRC=FE
    21.06

Every DS18B20 temperature sensor has a unique ID. 28 C6 96 90 4 0 0 67 is use by the DS18B20+ and 28 2A 4C 3C 4 0 0 6B is the ID for the DS18B20+ PAR sensor.


I've been using the parasite temperature sensor as outdoor sensor. Therefore I only need two wires for GND and DQ. And this is the temperature curve when I made the temperature sensor with a glue gun water resistant:
Thanks to maxim integrated for the samples. I think I would never tested the DS18B20+PAR.

December 22, 2012

In The Meantime : IOIO XMas Tree

While I'm waiting for the TFT Touch Shield (a December give-away from Seeedstudio) to start the next project, I've build a programmable XMas Tree with an Android phone and a IOIO board.

This is the XMas Tree in action (photo by +Aygul Zagidullina at the Nerdmare Before Christmas event):

IOIO (pronounced: yo-yo) is a product which lets you connect electronic circuits to an Android device and control them from an Android application. [1]

I've connected pin 3, 4, 5, and 10, 11, 12, 13 with seven 120 Ohm resistors and blue LEDs. For a detailed description of the pins take a look at Getting To Know The Board :

... and for the tree I've used a cardboard:

The IOIO Xmas Tree is programmed with an Android phone. For each light there's a toggle button, to turn the light on and off. The time which it takes to change the state is also recorded.


Programming the IOIO board is simple (if you're choosing useful pins middle in the night). In the setup method you define which pin is a digital output:

leds[i] = ioio_.openDigitalOutput(pins[i], true);

... and inside of the loop method you just write true or false to set 5V or 0V to the pin and therefore turn the light on or off:

leds[i].write(false);

Source code of the Android project is available on Github/choas/IOIOXMasTree.

December 10, 2012

Next Project : TFT Touch Shield

I'll receive the TFT Touch Shield V2.0, another monthly give-away from Seeed Studio.
The idea is to measure the outside and inside temperature and show these values on the TFT display. The TFT Touch Shield also have a SD card module integrated. So I could read an image from the SD card and use it as background image.

 ... and for the touch part a configuration menu allows to configure:
  • temperature display
    show inside, outside, none or both temperatures, a temperature graph (stored temperatures from the SD card)
  • background image
    choose between an image, a random image, temperature dependent image, none, or just a color
  • timer
    select the minutes and start the timer 
  • display
    always on or turn off after x minutes (therefore a capacitive sensor will turn the display on)

For the temperature measurement I'm not sure, if I'm using
  • a SPI one from TI, because the TFT Touch Shield communicates via SPI protocol
  • a DS18S20 with a 1-Wire bus from Dallas/Maxim (mentioned by Enrico Sadlowski in the German Android Google+  Community)
  • or a simple temperature resistor
... but I've got some time before the TFT Touch Shield arrives.

December 1, 2012

EL Shield Project - Idea And Code

This is the idea of the project as an image ... everything is available from Seeed Studio:

The EL Wires are very easily connected to the EL Shield. The same with the EL Inverter which converts 5V DC to 110V AC for the EL Wires.Only the PIRs need some soldering for this project. I've also added three LEDs to show the PIR and running status.


The two PIRs detect
  • the direction in which the object moves (from left->right or right->left)
  • and the speed



When the left PIR detects something before the right PIR detects it, then the object is moving from left to right. The time (in milliseconds) between these recognition points is the object moving speed. Depending on this speed (milliSecondsPerMeter) the start time of light 1 can be calculated and also the end time of light 4, and the time for light 2 and 3.

The Code

I've extended the PIR example code on arduino.cc to handle two PIRs and the running session. The code for the EL Shield is as simple as the Arduino Blink example, you only have to set the pinMode and use digitalWrite to turn the EL Wire on or off.

In idle mode all four lights are turned on. In the running session all light are turned off and the first light starts, then turns off and the second turns on, and so one. At the end all lights are turned on again. To get into the running session both PIRs have to recognized the moving object.

I've uploaded the implementation on github : el_shield.ino

... and this is the first result:

This is a nice project, which Seeed Studio made available with the EL Shield give away. The code needs some adjustment, e.g. on the left side there's a tree (don't worry I will not chop it off) and the object recognition is later than on the right side.

PS: more images and videos of this project are here available.

The Problems

The first idea was to setup up everything in the front garden, but I've got following problems:
  • wet
  • cold
  • short wires

wet and cold

It's November / December and normally it rains or snows at this time in Germany and it is getting cold.
The EL Inverter converts 5V DC to 110V AC, so I have to protect everything against this high voltage, e.g. a kid wants to climb on the tree.
The EL Wires have a Operating Temperature from -10 °C to +60° C and a Humidity RH < 90% ... we've got sometimes -20 °C.

short wires

The EL Shield comes with four wires to connect the EL Shield with the EL Wires. These wires are too short to connect all four EL Wires in the front garden ... or maybe the front garden is too big :)

Solution

I've assembled it inside the house and taped (I <3 taping) the EL Wires on the window:

About the Project

My idea is to use two PIR (Passive Infrared Sensor) Sensors, a EL Shield and four EL Wires. I'll put a PIR on the left and right side of the garden. If someone walks by, the nearest sensor will recognize this and the first EL Wire (next to the person) will start lightning. As the person moves on the second sensor will recognize this and therefore the lighting objects can follow the person.

Started Crystal Lab Blog

This blog is about electronic, crystal lightning, Arduino and more. So, if you're looking for some Breaking Bad stuff, you're wrong :) ... but maybe I'll write something about Crystal Castles.

I've started this blog, cause I want to write down the doing about the EL Shield project. I've got this EL Shield from Seeed Studio, which was a November give-away: