Go Down

Topic: Arduino used like repeater to VW TX (Read 201 times) previous topic - next topic

sidsm

Hi,
I want to make meteo station in my garden and I have a problem with distance. I had thought I can use another arduino in my house like repeater(this is the place, where meteo station can transmit) to send data to arduino in my room.
Do you think it´s possible to recieve data and then transmitt what you just recieved ? I would not ask if I found something related, but not.
This is a code I tried, but seems to not work...



#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
float Celsius = 0;

#include <Wire.h>


#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);


#include <VirtualWire.h>
const int receive_pin = 2;
char temperatureChar[10];
char humidityChar[10];


struct package
{
  float temperature = 0.0;
  float humidity = 0.0;
};


typedef struct package Package;
Package data;

const int transmit_pin = 4;


void setup() {
  vw_set_rx_pin(receive_pin);
  vw_setup(2000);   
  vw_rx_start();

  vw_set_tx_pin(transmit_pin);
   
 
  lcd.begin();
  lcd.backlight();
  lcd.print("AHOJ");
  delay(2000);
}

void loop() {
    uint8_t buf[sizeof(data)];
    uint8_t buflen = sizeof(data);

    if (vw_have_message()) 
      {
        vw_get_message(buf, &buflen);
        memcpy(&data,&buf,buflen);
   
       
       
       
       
        String temperatureString = String(data.temperature,1);
        temperatureString.toCharArray(temperatureChar,10);
       
   
        String humidityString = String(data.humidity,1);
        humidityString.toCharArray(humidityChar,10);
       
        /tx
        vw_send((uint8_t *)&data, sizeof(data));
        vw_wait_tx();
       
       
       
      }
 
 
 
 
  sensors.requestTemperatures();

  Celsius = sensors.getTempCByIndex(0);
  String temp = " Doma:";
  String tempPrint = temp + Celsius + " Stupnu";
                     
 
  lcd.clear();
  lcd.print("   Venkovni data:");
  lcd.setCursor(0, 1);
  lcd.print("Teplota: ");
  lcd.print(data.temperature);
  lcd.setCursor(0, 2);
  lcd.print("Vlhkost: ");
  lcd.print(data.humidity);
  lcd.setCursor(0, 3);
  lcd.print(tempPrint);
  delay(1000);
 
 



 

}

ieee488

The suggestion for greater distance is to use nRF24L01 modules.

cattledog

#2
May 20, 2017, 01:24 am Last Edit: May 20, 2017, 01:25 am by cattledog
Quote
Do you think it´s possible to recieve data and then transmitt what you just recieved ?
What modules do you currently have?
If they are the low cost ook/ask modules, it may be possible, but the transmit and receive need to be well separated in time, or else the AGC circuit on the receiver is overwhelmed by the transmitter on the same board and will not receive well from the more distant transmitter.

sidsm

I am currently using classical 433MHz transmitter and reciever.
When i tried it, the "repeater" recieved signal, but didn´t transmitted away. I think it´s, like you said, caused by bad timing and I don´t know much about wireless communication. If you helped me with the code, I would be very happy.

cattledog

#4
May 21, 2017, 05:08 am Last Edit: May 21, 2017, 05:08 am by cattledog
Quote
I don´t know much about wireless communication.
Given this statement, and the confusion in the code you presented, I think you are trying do do something too complicated for your experience level. Get some radios that will transmit your distance, or if you need repeaters, buy some units that are designed as transceivers for networks.

Go Up