Forum >Only get data on iOS app if Serial Monitor is open
Bluno General Arduino

Only get data on iOS app if Serial Monitor is open

userHead info 2018-02-09 15:40:21 2132 Views2 Replies
Ive run into an issue that seems to be common but unanswered. I have a sketch that sends data from the bluno nano to an iOS app (BlunoTerminal or the DFRobot BlunoTestDemo app).

The app gets(null) until I open the serial monitor, then I start getting my data. If I power the bluno from a USB-battery pack I get null but worst of all, I cant open a serial monitor in order to get my data because the bluno is not connected to a computer.

Can anyone offer a solution for this?

Here is my sketch with a hard coded data value of 454:
Code: Select all
byte statusLed = 13;
byte sensorInterrupt = 0; // 0 = digital pin 2
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;
void setup(){
Serial.begin(38400);
pinMode(statusLed, OUTPUT);
digitalWrite(statusLed, HIGH); // We have an active-low LED attached
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop(){
if((millis() - oldTime) > 5000) { // Only process counters once per second
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
unsigned int frac;
frac = (flowRate - int(flowRate)) * 10;
sendOverBLE();
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
}
void pulseCounter(){
pulseCount++;
}
void sendOverBLE() {
int mystring;
mystring = int(454);
Serial.println(mystring);//send what has been received
Serial.println(); //print line feed character
}
2018-09-15 23:05:26 I am also having this problem. Did you find a solution? userHeadPic cosmoskebabs
2018-05-14 03:10:14 I've similar problem with android app. Sending data to bluno beetle and works only with Serial Monitor connected. userHeadPic kesser