Multiple transmitters with one receiver?

507 views
Skip to first unread message

Larry LeBron

unread,
Nov 4, 2012, 1:12:14 PM11/4/12
to virtu...@googlegroups.com
Hi,

I'm relatively new to using RF and virtual wire, but I have got simple one-way communication up and running.

I'm wondering if there is any way to use one receiver to read messages from multiple transmitters. I know this is possible with more complex RF circuitry that allows for channels/ids. Is there any way to replicate this sort of functionality through software?

For example, if I have one central receiver and four transmitters(A, B, C and D), how can I keep the incoming data organized and associated with its source?

Thanks for any help!

- Larry

Mike McCauley

unread,
Nov 4, 2012, 4:31:17 PM11/4/12
to virtu...@googlegroups.com, Larry LeBron
Hello,

Yes, that is doable. But you probably need to have each transmitter
identified. Best way is to have an integer transmitter number or station
number as the first octet of each message.

Dont forget its possible for 2 transmitters to transmit at the same time,
which would prevent either message getting through. So you may need to make
provision for timeouts retransmissions etc.

See my RF22 library for some ideas?


Cheers.
--
Mike McCauley mi...@open.com.au
Open System Consultants Pty. Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.open.com.au
Phone +61 7 5598-7474 Fax +61 7 5598-7070

Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.

Adrian Cioata

unread,
Aug 22, 2017, 8:50:13 AM8/22/17
to virtualwire, larry...@gmail.com
Hello!

I am interested also into Larry's problem. I've been searching for hours on the internet for example of codes for the transmitter/receiver to give IDs for the transmitters or so. Nothing found! I am surprised since this is some essential stuff.
I want to put temp/humid sensors in every room in my house, and a central receiver with LCD  in living room to display the sensor information from the other rooms.

So, please if you could be more precise, give me an example of how the code should be.

Now I have this sketch... and it works great with one Transmiter and one receiver:

Transmiter:

#include <OneWire.h>
#include <LiquidCrystal.h>
#include <DallasTemperature.h>
#include <VirtualWire.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int led =13;
float tempC = 0;
char msg[6];
void setup() {
  sensors.begin();
  lcd.begin(16,2);
  lcd.clear();
  pinMode(3, OUTPUT);
  analogWrite(3, 0);
  Serial.begin(9600);
  vw_set_tx_pin(12);          // Sets pin D12 as the TX pin
    vw_setup(2000);          // Bits per sec
}
void loop() {
  sensors.requestTemperatures();
  tempC = sensors.getTempCByIndex(0);
  delay(1000);
    dtostrf(tempC, 6,2,msg);           //converts the float into a char
    digitalWrite(13, HIGH); // LED ON to show transmitting
    vw_send((uint8_t *)msg, strlen(msg)); //transmits the data
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, LOW); // LED OFF stop transmitting
    delay(200);
   
  Serial.println(tempC);
  lcd.setCursor(0,0);
  lcd.print("Temperature is:");
  lcd.setCursor(0,1);
  lcd.print("    ");
  lcd.print(tempC);
  lcd.print(" °C");
 lcd.clear();
     
 
}


and for RECEIVER:


#include <OneWire.h>
#include <LiquidCrystal.h>
#include <DallasTemperature.h>
#include <VirtualWire.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int i;
void setup() {
  sensors.begin();
  lcd.begin(16,2);
  lcd.clear();
  pinMode(3, OUTPUT);
  analogWrite(3, 0);
  Serial.begin(9600);
  vw_set_rx_pin(13);       //Sets pin D13 as the RX Pin
    vw_setup(2000);       // Bits per sec
    vw_rx_start();           // Start the receiver PLL running
}
void loop() {
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
   if( vw_get_message(buf, &buflen) )
      {
        lcd.setCursor(0, 0);
        lcd.print("Temp is:");   
        lcd.setCursor(3,1); 
       
       for (i = 0; i < buflen; i++)
         {
           lcd.write(buf[i]);
                   
         }
           lcd.print((char)223);
           lcd.print("C");
      }
 
}


so basically for the transmitter are these 4 lines:

dtostrf(tempC, 6,2,msg);           //converts the float into a char 
    vw_send((uint8_t *)msg, strlen(msg)); //transmits the data
    vw_wait_tx(); // Wait until the whole message is gone
    delay(200);

and for receiver:

uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
   if( vw_get_message(buf, &buflen) )
      {
        lcd.setCursor(0, 0);
        lcd.print("Temp is:");   
        lcd.setCursor(3,1); 
       
       for (i = 0; i < buflen; i++)
         {
           lcd.write(buf[i]);
                   
         }
           lcd.print((char)223);
           lcd.print("C");
      }


How can I modify these to be sure that it does not mixup with other transmiters.

Thank you.
Adrian.

Mike McCauley

unread,
Aug 22, 2017, 7:07:45 PM8/22/17
to virtu...@googlegroups.com
Hello. 
VirtualWire is obsolete and replaced by Radiohead which supports node isa and much more

Cheers

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "virtualwire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualwire...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages