Posts with «wise clock 4» label

Wise Clock 4 with Bluetooth

Another thing that was supposed to be easy, but it wasn't: Arduino communicating with Windows XP through Bluetooth.

Like everybody else, I purchased the cheap and ubiquitous Bluetooth module from dealextreme.
I soldered it myself on the XBee-footprinted PCB (bare BTBee from IteadStudio), for a total price of about $8 (compare that to at least $15 as these Bluetooth XBees go for).

Without knowing much about Bluetooth, I plugged this new "BTBee" module in Wise Clock 4 expecting it to be "discovered" by XP (which has an USB Bluetooth dongle). Discovered it was: the name "linvor" appeared in the list of BT devices, with two serial ports attached to it.

Communication between XP and BT module is performed through the serial ports, I figured. Tried CoolTermWin, HyperTerminal, Putty, on both ports, nothing seemed to work. Time to read the documentation (which always reminds me of that joke). I learned that others had similar problems, and some have solved them by installing new BT drivers. The best advice came from this post. Putty did not work for me, so I stuck with what I had, namely HyperTerminal.

So here is my own step-by-step tutorial on how to make an Arduino communicate with Windows XP via a Bluetooth module.
Note: From the Bluetooth perspective, Wise Clock 4 I used for my testing is similar to Arduino.

1. Upload this simple sketch that "echos" what it reads from Bluetooth and also broadcasts a message periodically. The communication between Arduino and the BT module is serial, with a baud rate of 9600, according to the documentation.

#if ARDUINO < 100
  #include
#else
  #include
#endif


void setup()
{
  Serial.begin(9600);
}


void loop()
{
  while (Serial.available())
  {
    // get char from bluetooth;
    char inChar = (char) Serial.read();
    // output it back, between brackets;
    Serial.print('[');
    Serial.print(inChar);
    Serial.print(']');
  }
  // broadcast message;
  Serial.print("millis() from Arduino: ");
  Serial.println(millis());
  delay(2000);
}

2. Power Arduino, with the BT module connected, and let it run the sketch.

3. Make the BT module (on the Arduino) visible to XP, by adding it to the list of Bluetooth devices. For this, click on the "Bluetooth Devices" icon in the tray (bottom right corner of the XP's desktop). You will see this box.
















Next, you will see the BT device added to the list, under the name "linvor".















Then select the last option, "Don't use a passkey". Although it makes little sense at this point (since you know that the passkey is 1234, according to the documentation), it is very important to not use a passkey here.















The last step of the wizard shows the two ports that have been added. Write down the "Outgoing COM port", since this is the one we will be using for communication (step 4).















4. Open HyperTerminal to establish the 2-way communication between XP and Arduino, via Bluetooth.
Select, from the list, the COM port specified as "outgoing" for the BT device.


















Next, you will be shown this pop-up.






After you click on it, you are prompted to enter the passkey, the one you (reluctantly) skipped in the process of setting up the BT device. Type "1234", as specified in the BT module documentation.















After hitting "Next", you are shown this last confirmation box.















In the same time, the HyperTerminal starts displaying the message coming from Arduino.














Note that, when the COM port was opened in Auto mode, no parameters (bad rate etc) being specified.
Interestingly, after the communication is established, the baud rate is reported as 2400 (for some unexplained reason).
You can also type characters in the HyperTerminal and they will be echoed back (between brackets) by Arduino.

Optionally, if you want to see what you typed (before the echoing from Arduino takes place), you can enable local echo, by selecting "Properties", then "ASCII Setup".




































Once the communication between XP (HyperTerminal) and Arduino is established via Bluetooth, the "Status" LED (if you have it soldered) is on continuously. When the BT module is not communicating, the "Status" LED is blinking at a frequency of about 2Hz.

The next time a HyperTerminal session is opened, XP remembers the BT device and the communication params (ports, passkey) and does not ask to set it up again. (I guess that's why it is called "pairing", although this word does not appear anywhere in the process.)


Time to write some serious applications using Bluetooth:)

Wise Clock 4 with Bluetooth

Another thing that was supposed to be easy, but it wasn't: Arduino communicating with Windows XP through Bluetooth.

Like everybody, I purchased the cheap and ubiquitous Bluetooth module from dealextreme.
I soldered it myself on the XBee-footprinted PCB (bare BTBee from IteadStudio), for a total price of about $8 (compare that to at least $15 as these Bluetooth XBees go for).

Without knowing much about Bluetooth, I plugged this new "BTBee" module in Wise Clock 4 expecting it to be "discovered" by XP (which has an USB Bluetooth dongle). Discovered it was: the name "linvor" appeared in the list of BT devices, with two serial ports attached to it.

Communication between XP and BT module is performed through the serial ports, I figured. Tried CoolTermWin, HyperTerminal, Putty, on both ports, nothing seemed to work. Time to read the documentation (which always reminds me of that joke). I learned that others had similar problems, and some have solved them by installing new BT drivers. The best advice came from this post. Putty did not work for me, so I stuck with what I had, namely HyperTerminal.

So here is my own step-by-step tutorial on how to make an Arduino communicate with Windows XP via a Bluetooth module.
Note: From the Bluetooth perspective, Wise Clock 4 I used for my testing is similar to Arduino.

1. Upload this simple sketch that "echos" what it reads from Bluetooth and also broadcasts a message periodically. The communication between Arduino and the BT module is serial, with a baud rate of 9600, according to the documentation.

#if ARDUINO < 100
  #include
#else
  #include
#endif


void setup()
{
  Serial.begin(9600);
}


void loop()
{
  while (Serial.available())
  {
    // get char from bluetooth;
    char inChar = (char) Serial.read();
    // output it back, between brackets;
    Serial.print('[');
    Serial.print(inChar);
    Serial.print(']');
  }
  // broadcast message;
  Serial.print("millis() from Arduino: ");
  Serial.println(millis());
  delay(2000);
}

2. Power Arduino, with the BT module connected, and let it run the sketch.

3. Make the BT module (on the Arduino) visible to XP, by adding it to the list of Bluetooth devices. For this, click on the "Bluetooth Devices" icon in the tray (bottom right corner of the XP's desktop). You will see this box.
















Next, you will see the BT device added to the list, under the name "linvor".















Then select the last option, "Don't use a passkey". Although it makes little sense at this point (since you know that the passkey is 1234, according to the documentation), it is very important to not use a passkey here.















The last step of the wizard shows the two ports that have been added. Write down the "Outgoing COM port", since this is the one we will be using for communication (step 4).















4. Open HyperTerminal to establish the 2-way communication between XP and Arduino, via Bluetooth.
Select, from the list, the COM port specified as "outgoing" for the BT device.


















Next, you will be shown this pop-up.






After you click on it, you are prompted to enter the passkey, the one you (reluctantly) skipped in the process of setting up the BT device. Type "1234", as specified in the BT module documentation.















After hitting "Next", you are shown this last confirmation box.















In the same time, the HyperTerminal starts displaying the message coming from Arduino.














Note that, when the COM port was opened in Auto mode, no parameters (baud rate etc) being specified.
Interestingly, after the communication is established, the baud rate is reported as 2400 for some unexplained reason.
You can also type characters in HyperTerminal and they will be echoed back, between brackets, by Arduino.

Optionally, if you want to see what you typed (before the echoing from Arduino takes place), you can enable local echo, by selecting "Properties", then "ASCII Setup".





































Once the communication between XP (HyperTerminal) and Arduino is established via Bluetooth, the "Status" LED (if you have it soldered) is on continuously. When the BT module is not communicating, the "Status" LED is blinking at a frequency of about 2Hz.

The next time a HyperTerminal session is opened, XP remembers the BT device and the communication params (ports, passkey) and does not ask to set it up again. (I guess that's why it is called "pairing", although this word does not appear anywhere in the process.)


Time to write some serious applications using Bluetooth:)


Wise Clock 4 with ATmega1284

I thought that replacing the ATmega644P with its bigger brother ATmega1284P in Wise Clock 4 would be trivial. How wrong I was.

The first step was to burn the bootloader. After a bit of research, here is what I found out:
  • USBtinyISP from adafruit cannot program chips with more than 64K of flash (see this thread);
  • if you don't want to start from scratch (that is, compile the source code and figuring the fuses) there are at least 3 sources: ryanmsutton, maniacbug and calunium;
  • USBtinyISP half-works: it writes to the flash, but reading back for verification purpose fails because of a bug in the firmware; I ignored the verification error;
  • although burning the bootloader (any of the three mentioned above) seemed successful, uploading any sketch afterwards always failed;
  • the setup from ryanmsutton did not work for me (I guess the fuses are wrong; then the core files also point to the arduino folder, instead of the sanguino, as it should be);
  • with the bootloader from calunium (atmega1284p_16MHz.hex) I was able to upload sketches; these are the settings in boards.txt I used:

atmega1284.name=Sanguino W/ ATmega1284p 16mhz
atmega1284.upload.protocol=stk500v1
atmega1284.upload.maximum_size=129024
atmega1284.upload.speed=57600
atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0x98
atmega1284.bootloader.extended_fuses=0xFD
atmega1284.bootloader.path=atmega
atmega1284.bootloader.file=atmega1284p_16MHz.hex
atmega1284.bootloader.unlock_bits=0x3F
atmega1284.bootloader.lock_bits=0x0F
atmega1284.build.mcu=atmega1284p
atmega1284.build.f_cpu=16000000L
atmega1284.build.core=sanguino

Note the upload protocol (stk500v1), note the fuses and note the core folder (last line).

To compile the code for Sanguino with ATmega1284P, some macros must be updated as well, by adding
defined(__AVR_ATmega1284P__)  to any defined(__ATmega644P__)

like this:

#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__) // sanguino

In the end, the program space is about 126K (compared to 62K in ATmega644P) and the available RAM is 16K (compared to only 4K in Atmega644P). Not a bad upgrade for only a few bucks more.


Note: ATmega1284 is not defined in avrdude.conf shipped with Arduino 22 or 23 (folder \arduino-22\hardware\tools\avr), but it is defined in Arduino 1.0.



Wise Clock 4 with ATmega1284

I thought that replacing the ATmega644P with it's bigger brother ATmega1284P in Wise Clock 4 would be trivial. How wrong I was.

The first step was to burn the bootloader. After a bit of research, here is what I found out:
  • USBtinyISP from adafruit cannot program chips with more than 64K of flash (see this thread);
  • if you don't want to start from scratch (that is, compile the source code and figuring the fuses) there are at least 3 sources: ryanmsutton, maniacbug and calunium;
  • USBtinyISP half-works: it writes to the flash, but reading back for verification purpose fails because of a bug in the firmware; I ignored the verification error;
  • although burning the bootloader (any of the three mentioned above) seemed successful, uploading any sketch afterwards always failed;
  • the setup from ryanmsutton did not work for me (I guess the fuses are wrong; then the core files also point to the arduino folder, instead of the sanguino, as it should be);
  • with the bootloader from calunium (atmega1284p_16MHz.hex) I was able to upload sketches; these are the settings in boards.txt I used:

atmega1284.name=Sanguino W/ ATmega1284p 16mhz
atmega1284.upload.protocol=stk500v1
atmega1284.upload.maximum_size=129024
atmega1284.upload.speed=57600
atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0x98
atmega1284.bootloader.extended_fuses=0xFD
atmega1284.bootloader.path=atmega
atmega1284.bootloader.file=atmega1284p_16MHz.hex
atmega1284.bootloader.unlock_bits=0x3F
atmega1284.bootloader.lock_bits=0x0F
atmega1284.build.mcu=atmega1284p
atmega1284.build.f_cpu=16000000L
atmega1284.build.core=sanguino

Note the upload protocol (stk500v1), note the fuses and note the core folder (last line).

To compile the code for Sanguino with ATmega1284P, some macros must be updated as well, by adding
defined(__AVR_ATmega1284P__)  to any defined(__ATmega644P__)

like this:

#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__) // sanguino

In the end, the program space is about 126K (compared to 62K in ATmega644P) and the available RAM is 16K (compared to only 4K in Atmega644P). Not a bad upgrade for only a few bucks more.


Note: ATmega1284 is not defined in avrdude.conf shipped with Arduino 22 or 23 (folder \arduino-22\hardware\tools\avr), but it is defined in Arduino 1.0.


Troubleshooting guide for Wise Clock 3/4

This should really be a chapter of the assembling instructions for Wise Clock 3/4. Until I integrate everything into a single document, it is just another post that begged to be written (long ago, as a matter of fact).


1. Right after power up, the clock should make a beeping sound. If that does not happen, here are possible causes:
  • missing input 5V power; the optional power LED may be useful in this case, turned on when the power is present;
  • reset pin may be shorted to ground (the processor won't execute any code);
  • processor may not be powered: check that pin 10 has 5V and pin 11 is connected to ground;
  • faulty or missing the 16MHz clock for the processor; check crystal connections to the pins; if everything looks good electrically, try to upload a sketch; it that still doesn't work, test by replacing the processor or replacing the crystal;
  • buzzer may be disconnected; check connections between processor's pins and buzzer, shorts to the ground, terminal soldering.


2. The display does not light up at all (assuming the display is not defective):
  • faults in the connections to the display (right-hand header): look for shorts between neighbor pins in the display header; look for shorts between any signal pins in the display connector and ground;
  • output header (left-hand) display header may have shorts between neighbor pins or pins shorted to the ground.


3. Getting SD card error in "Quote" mode:
  • faulty SD card; check the SD card itself by reading it in a PC; must be formatted FAT16 (therefore 2GB or smaller);
  • the required text files may be missing; check for their presence in the root directory;
  • SD card may not be powered; check 3V3 power on the third pin from the left (second pin from the left is connected to the ground);
  • check voltage divider resistors R5, R6, R7 (under the processor) and make sure they are 4K7.


4. A button press does not trigger the expected action:
  • button may be defective; check if the specific button shorts the processor pin to the ground when pressed.


5. Communication error when trying to upload a sketch:
  • make sure you plugged the FTDI cable/breakout the correct way/orientation, with the Ground/Black terminal to the right;
  • check the Rx/Tx connections to the processor (pins 14 and 15); make sure that they are not cut or shorted to the ground.


Troubleshooting guide for Wise Clock 3/4

This should really be a chapter of the assembling instructions for Wise Clock 3/4. Until I integrate everything into a single document, it is just another post that begged to be written (long ago, as a matter of fact).


1. Right after power up, the clock should make a beeping sound. If that does not happen, here are possible causes:
  • missing input 5V power; the optional power LED may be useful in this case, turned on when the power is present;
  • reset pin may be shorted to ground (the processor won't execute any code);
  • processor may not be powered: check that pin 10 has 5V and pin 11 is connected to ground;
  • faulty or missing the 16MHz clock for the processor; check crystal connections to the pins; if everything looks good electrically, try to upload a sketch; it that still doesn't work, test by replacing the processor or replacing the crystal;
  • buzzer may be disconnected; check connections between processor's pins and buzzer, shorts to the ground, terminal soldering.


2. The display does not light up at all (assuming the display is not defective):
  • faults in the connections to the display (right-hand header): look for shorts between neighbor pins in the display header; look for shorts between any signal pins in the display connector and ground;
  • output header (left-hand) display header may have shorts between neighbor pins or pins shorted to the ground.


3. Getting SD card error in "Quote" mode:
  • faulty SD card; check the SD card itself by reading it in a PC; must be formatted FAT16 (therefore 2GB or smaller);
  • the required text files may be missing; check for their presence in the root directory;
  • SD card may not be powered; check 3V3 power on the third pin from the left (second pin from the left is connected to the ground);
  • check voltage divider resistors R5, R6, R7 (under the processor) and make sure they are 4K7.


4. A button press does not trigger the expected action:
  • button may be defective; check if the specific button shorts the processor pin to the ground when pressed.


5. Communication error when trying to upload a sketch:
  • make sure you plugged the FTDI cable/breakout the correct way/orientation, with the Ground/Black terminal to the right;
  • check the Rx/Tx connections to the processor (pins 14 and 15); make sure that they are not cut or shorted to the ground.

Wise Clock 4 - "Time Lived" menu option

At the request of AlexT, I implemented a new feature in Wise Clock 4, which allows the display of time lived (since birth) in different formats (years/months/days/hours/minutes/seconds, days only, hours only, minutes only).


















The above photo shows the year/month/day on the top row and the hours/minutes/seconds on the bottom row.


Lifetime in Wise Clock 4 from florinc on Vimeo.

The birth date and time are read from the file message.txt on the SD card.

I was inclined to use the Time library, but I found it a little bulky for my needs and also unsuitable for dates before 1970. Then, I copied and modified the function makeTime() to convert a datetime to seconds, and I wrote my own diffTime() function to calculate the difference (in years, months, days etc) between two dates.

Alternating between display modes is done by pressing the SET (middle) button.

This code will be included in the next release of Wise Clock 4 software.

Wise Clock 4 - "Time Lived" menu option

At the request of AlexT, I implemented a new feature in Wise Clock 4, which allows the display of time lived (since birth) in different formats (years/months/days/hours/minutes/seconds, days only, hours only, minutes only).


















The above photo shows the year/month/day on the top row and the hours/minutes/seconds on the bottom row.


Lifetime in Wise Clock 4 from florinc on Vimeo.

The birth date and time are read from the file message.txt on the SD card.

I was inclined to use the Time library, but I found it a little bulky for my needs and also unsuitable for dates before 1970. Then, I copied and modified the function makeTime() to convert a datetime to seconds, and I wrote my own diffTime() function to calculate the difference (in years, months, days etc) between two dates.

Alternating between display modes is done by pressing the SET (middle) button.

This code will be included in the next release of Wise Clock 4 software.


Scrolling message sign display with Wise Clock 3/4 - part 2

This post, written some time ago, demonstrated how to make a message sign using two 3216 displays connected to Wise Clock 3. The font used in the demo is 8*8 (actually just 7*7), quite small for the 16 LED height of the display.

The code for a larger (11x14) font is already included in the Wise Clock 3/4 software (file fontLarge.h), just not used and used when the "Big Font" menu option is selected (file AppBig.cpp). I resurrected this forgotten font and the functions that use it and this is how it works:



I modified the original sketch (posted in this thread of the Arduino forum) to include the following lines at the top of the file:

char* msgLine = "           Hello world - demo for large font scrolling on dual 3216 display.";
int crtPos = 0;
int crtColor = GREEN;

and the loop() function:

void loop ()
{
  displayLargeScrollingLine();

  if (crtPos >= strlen(msgLine))
      crtPos = 0;
}

The source code for the demo in the video can be found here.


Related posts:

Scrolling message sign display with Wise Clock 3/4 - part 2

This post, written some time ago, demonstrated how to make a message sign using two 3216 displays connected to Wise Clock 3. The font used in the demo is 8*8 (actually just 7*7), quite small for the 16 LED height of the display.

The code for a larger (11x14) font is already included in the Wise Clock 3/4 software (file fontLarge.h), just not used and used when the "Big Font" menu option is selected (file AppBig.cpp). I resurrected this forgotten font and the functions that use it and this is how it works:



I modified the original sketch (posted in this thread of the Arduino forum) to include the following lines at the top of the file:

char* msgLine = "           Hello world - demo for large font scrolling on dual 3216 display.";
int crtPos = 0;
int crtColor = GREEN;

and the loop() function:

void loop ()
{
  displayLargeScrollingLine();

  if (crtPos >= strlen(msgLine))
      crtPos = 0;
}

The source code for the demo in the video can be found here.


Related posts: