NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Temperature sensor

October 18, 2010
by newbie
newbie's Avatar

I have the temperature sensor working but want to get it to display on the computer. I have been trying to get this for some time but do not know how. I know there is a line in the program but how do you go from there??

October 18, 2010
by Ralphxyz
Ralphxyz's Avatar

At the beginning of the code right after main() make sure you have:

  // start up the serial port
  uart_init();
  FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
  stdin = stdout = &uart_stream;

This turns the UART communications on.

Then at the bottom of the tempsensor c code make sure this line is not commented out:

    // write message to serial port
    printf_P(PSTR("%.2f degrees F\r\n"), temp_avg);

This sends the data to your pc.

You need a terminal program running to see the output on a MAC you use Terminal screen.

In Windows you use Hyper Terminal.

I am not sure about Linux.

Ralph

October 24, 2010
by newbie
newbie's Avatar

Hello

I have all the code you suggested in the program. I'am not sure what you mean by window's hyper terminal.

October 24, 2010
by Rick_S
Rick_S's Avatar

newbie,

Hyperterminal was a serial communications program bundled with versions of windows through XP. Vista and beyond do not have hyperterminal.

If you are running Windows Vista or 7, you can get a simple terminal program to display the serial data such as PuTTY. Simply configure it for the correct com port and baud rate and you'll see your data coming thru.

Rick

October 24, 2010
by newbie
newbie's Avatar

Thanks for the responce I found the hyper terminal and configured but get a bunch of junk getting printed on the screen. I have the correct com port tried changing the baud rate did not get any where. this is what I get on the screen:

yx~ú ùúú ûûþ ûùúùûùü ùûùþ û ùþøþ ý ûþ ûù ùû ûùúú ùü ùûùþ ùûüû ûû ûý ýùûùûùûùþ ùû þûþùú ùûùþø þ úù þû ù ûùüý ûø ùþùþ ú ûø ùûùûþ û ýù û þ û þ ûþ ù ûþû ùþûûúûùþøþ ùþþý ûûú ùþ ûûþ ù ûûûùû þý þý ú ùý ý üú þü ú þüû þûý þýþ ü þüúþ üú þý þüúþûýý ûú ùýý ûý úþ ýþ ûììììÄìììÄìììììììÄÄìÄìÄÄììÄìÄÄìì ììÄÄììÄìÄìÄÄÄÄÄììììììÄììììÄÄìììÄììÄÄÄìììÄìÄÄÄÄÄìÄìììÄÄìììììíÄííÄíÄÄìÄíìÄíííííÄÄÄ ííÄÄÄíÄììììÄÄÄíÄÄÄÄÄÄííííííÄíÄííÄÄíÄííÄííÄíííí

Any ideas ??

October 24, 2010
by mongo
mongo's Avatar

Check the error checking and parity bits. Most terminals run 8 n 1 (8 data, no parity, single bit checking)

October 24, 2010
by newbie
newbie's Avatar

hello The settings are what you said my baud rate is 2400. Is there something in the hyper terminal that I have to program or is this the correct baud rate. I tried other rates and got no communications.

October 24, 2010
by Rick_S
Rick_S's Avatar

Change the baud rate to 115200.

Rick

October 24, 2010
by newbie
newbie's Avatar

Thanks That worked . I should have tried more baud rates. Why did it give me what it did at the slower rate?

October 24, 2010
by Rick_S
Rick_S's Avatar

Because the data was faster than what the PC was reading so it was getting bits from different bytes making wierd charachters.

Glad you got it going!

Rick

Post a Reply

Please log in to post a reply.

Did you know that multiple microcontrollers can communicate with each other? Learn more...