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.

Project Help and Ideas » MCU UART over long distances

January 29, 2010
by treymd
treymd's Avatar

I live in the sticks, and since I think these little chips are damned near the coolest thing I've ever seen, I must install gadgets all over my 5 acres of land for various tasks. The problem is getting them to send info back into the house or whatever.

I've done a bit of reading on the matter, and it appears that rs-232 maxes out at about 60m, this probably won't do. SPI and I2C are out as well, though I did read a suspect snippet on how someone was using I2C over 1km??? does that sound right?

Anyhow RS-485 and RS-422 seem to be the long distance winners, coming in at a whopping 4000ft. or so.

Do you think the following will work without me having to goof with them much?

http://www.sourcingmap.com/serial-rs232-rs485-data-communication-converter-adapter-p-40257.html

Supposedly you can plug them right into a serial port of a PC, but as far as I've read I think that's 12 volts so I'd need to take care of that, but if these adapters do it all, then there's not much of a reason to bang my head against the wall trying to cook up a dta tranmission scheme.

February 03, 2010
by jastermerrel
jastermerrel's Avatar

Hey I have no ideal how these work or anything about them really. But they would seem to be able to do what you describe...wirelessly. Just something to throw out there.

XBEE-pro claims up to a mile (line-of-site) outdoors.

http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#overview

February 04, 2010
by pbfy0
pbfy0's Avatar

The 2400/4800 bps transmitter/receivers look good. I'll post some code for ID.

February 04, 2010
by pbfy0
pbfy0's Avatar

OK, here's code that should identify various transmitters/receivers in the same area:

#define ID 1

void wireless_write(char c){
    uint8_t rc = 1;
    char checksum;
    while (rc == 1) {
        checksum = ID ^ c;
        uart_write(0b01010101);
        uart_write(0b10101010);
        uart_write(ID);
        uart_write(c);
        uart_write(checksum);
#ifdef RC
    end:
        while(!uart_char_is_waiting());
        if(uart_read == 0b01010101){
            rc = uart_read();
        }else {
            goto end;
        }
#else
        rc = 0;
#endif
    }
}

char wireless_read(){
get:
    char d1, d2, rid, ic, c1;
    d1 = uart_read();
    d2 = uart_read();
    rid = uart_read();
    ic = uart_read();
    c1 = uart_read();
    uart_write(0b01010101);
    if(d2 == 0b10101010 && c1 == (rid ^ ic)){
        uart_write(0);
    }else{
        uart_write(1);
        goto get;
    }
    return ic;
}

int wireless_putchar(char c){
    wireless_write(c);
    return 0;
}

int wireless_getchar(){
    char c = wireless_read();
    return (int) c;
}

void wireless_init(){
    fdevopen(&wireless_putchar, &wireless_getchar);
}

you should change ID to some number, not the same as any other transmitter/receiver set.

February 04, 2010
by pbfy0
pbfy0's Avatar

note that this isn't tested

February 04, 2010
by pbfy0
pbfy0's Avatar

I meant the pairs on sparkfun here

July 18, 2011
by hariharan
hariharan's Avatar

i think u should see the 'buildr' tutorial about xbee. if u see xbee in the sparkfun website, it is under it. You have to create a PAN ( Private Area Network) ID so you can send messages. u have to set it up with a xbee explorer circuit and the XCTU software.

Post a Reply

Please log in to post a reply.

Did you know that you can use a transistor to interface between different voltage levels of digital logic? Learn more...