2017년 5월 7일 일요일

How can i print multiple sensor data on app in separately


I have made one App in mit app inventor 2. In which i have used 5 sensor and bluetooth module. I am sending multiple sensor data on app but it gives error bad list arguments.I have trouble in receiving data on separate text. would you please explain me how can i receive data on separately. 
please reply as soon as possible.


--
See the posts on using Delimiters in the Arduino/Bluetooth section of this FAQ:

For more specific help, include in your post attachments with:

Your Arduino sketch (.ino)
Downloaded blocks images 
Screen shots of your Bluetooth component options in the Designer
a .aia export
Screen shots of run time behavior

-- 
 I am Attaching below my arduino code file , block images and screenshot of run time behaviour. would you please explain me how can i remove this error. 

code

#include <SoftwareSerial.h>
#include <DHT.h>

#define DHTPIN 7      // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino

SoftwareSerial BTserial(4, 3); // RX | TX

float t;
float h;

char Temp_data;
char Hum_data;
char buffer [10];
float Temperature ()
{
 // Read temperature as Celsius (the default)
  t = dht.readTemperature();
  return (t);
  
 }
float Humidity ()
 {
  //Read data and store it to variables hum and temp
  h = dht.readHumidity();
  return (h);
 }  

 void setup() 
{
   Serial.begin(9600);
   BTserial.begin(9600);
  // put your setup code here, to run once:
pinMode (DHTPIN, OUTPUT); // Temperature pin set as output

}

void loop() 
{
  // put your main code here, to run repeatedly:

  int temp = Temperature ();
  int hum = Humidity ();
  sprintf (buffer, "%d ,%d", temp, hum);

  Serial.println(buffer);
  BTserial.println (buffer);

  //BTserial.print ("temperature =");
  BTserial.print (temp);
  BTserial.print ("C");
  delay(1000);

 // BTserial.print ("humidity =");  
  BTserial.print (hum);  
  BTserial.print ("%");
  delay (1000);
}





-- 
You did not supply a .aia export, so diagnosis will be limited.

You are sending three different types of message from your Arduino:
1. a comma separated list of temp and humidity, ending in LF
2. temperature readings ending in "C"
3. humidity readings ending in "%"

You need to test each incoming message to see if it contains a comma, or a "C", or a "%",
so you can decide which label to put it into.

If the incoming messages contains a comma, only then should you split it into a list.

Don't make any assumptions about how many items will be on the list.
Test if length of list (list) > 1 before asking for item 2.
Test if length of list (list) > 2 before asking for item 3.
etc.

Also, you should not need 2 clocks, 1 will work for you if you do it right.

See this link for how to use println() to send separate messages,
and for how to receive them one at a time using a delimiter.

-- 
Hello Sir, I am not getting separate data in app. How can i differ it. would you please send me correct arduino code and block in my app

-- 
I am not getting separate data in app. How can i differ it. would you please send me correct arduino code and block for my app.
I am sending my app .aia file. File attach below.


--

댓글 없음:

댓글 쓰기