Go Down

Topic: No Data reading from Master Bluetooth (Read 28 times) previous topic - next topic

doug_paiz

Good afternoon, 
I am new to Arduino language, and I have a sensor (anemometer) sending wind speed via Bluetooth (slave) to the master Bluetooth. The slave is printing the windspeed on the serial port, but on the master serial port the reading is 0.00
Code: [Select]
//********Slave code************//
#include <SoftwareSerial.h>
#include <Wire.h>


#define anenometer 5
#define tx 2
#define rx 3
SoftwareSerial blue (rx,tx);


byte sensorPin = 5;
double pulses = 0;
double wSpeed = 0;
long updateTimer = 0;
int updateDuration = 3000;


void setup() {
  Serial.begin(9600);
  blue.begin(9600);
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT); 
attachInterrupt(digitalPinToInterrupt(sensorPin), sensorISR, FALLING);
}

void loop() {


  long now = millis();
  if(updateTimer <now) {
    updateTimer = now + updateDuration;
    wSpeed = ((pulses/(updateDuration/1000)) * 0.765) + 0.35;
    pulses = 0; 
    Serial.println("Windspeed is:" );
    Serial.println(wSpeed);
    byte u = wSpeed;
    blue.write(wSpeed);
    delay(100);   
       
  }
 // blue.write(wSpeed);
}

void sensorISR() {
  pulses++;
}

//************************* MASTER CODE*********


#include <SoftwareSerial.h>
#include <Wire.h>

#define tx 2
#define rx 3

SoftwareSerial blue(rx, tx); //RX, TX

void setup()
{
  Serial.begin(9600);
  blue.begin(9600);
  pinMode(tx, OUTPUT);
  pinMode(rx, INPUT);

}

void loop()
{
  if(blue.available())
  {
    double inComingData = blue.read();
    Serial.println(inComingData);
 
  }
delay(150);
}


Is probably something easy, but i can not figure this out- anyone able to assist?

Master out put: 
0.00
0.00
Slave

windspeed is:
0.35

Go Up