0

I am trying to transfer data recorded by one of my Arduino UNO boards (which is recording temperature data using DHT11) to another board that could be UNO or WeMos D1. The problem is that the UNO board is already communicating with another UNO board using Serial communication. The code works fine as long as I do not un-comment the radio section. The moment I un-comment it the serial communication stops. Please help me.

Following is my code:

#include <nRF24L01.h>
#include <printf.h>

#include <RF24.h>
#include <RF24_config.h>
#include<SPI.h>

#include <SoftwareSerial.h>
#include <dht11.h>

dht11 DHT11;
#define DHT11PIN 8

RF24 radio(5, 10); // CE, CSN
const byte address[6] = "00001";
const int gledPin =  6;      // the number of the LED pin
const int rledPin =  7;
String sbh;
char mystr[100];//String data
char recstr[10]; //Initialized variable to store recieved data
int temp;
SoftwareSerial mySerialT(0, 1);//(Rx,Tx)

void setup() {
  Serial.begin(9600);
  mySerialT.begin(9600);
  // Begin the Serial at 9600 Baud

  DHT11.read(DHT11PIN); 
  pinMode(rledPin, OUTPUT);
  pinMode(gledPin, OUTPUT); 
  ///***********************For Radio Connection***********************//
  /*
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  //*/
  //*******************************************************************//
}

void loop() {
  digitalWrite(rledPin, LOW);
  digitalWrite(gledPin, LOW); 
  temp=DHT11.temperature;
  itoa(temp, mystr,10); 
  Serial.write(mystr,2); 
  Serial.print('\n');
  delay(1000);
  int i=0;
  mySerialT.listen();
  if (mySerialT.available()) {
    delay(1000);
    while(mySerialT.available() && i<7) {
      recstr[i++] = mySerialT.read(); 
    }
    recstr[i++]='\0';
  }
  if(i>0){
    sbh=String(recstr);
    if(sbh.equals("STABLE")){
      digitalWrite(rledPin, LOW);
      digitalWrite(gledPin, HIGH); 
      delay(500);
    }
    if(!(sbh.equals("STABLE"))){
      digitalWrite(rledPin, HIGH);
      digitalWrite(gledPin, LOW); 
      delay(500);
    }
  }
  //**************Message to be transferred to Radio***********//
  /* const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
  */
  //*********************************************************//
}

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.