Go Down

Topic: Transferring data from serial monitor to iPhone app (Read 209 times) previous topic - next topic

Liz0905

Hello!
Maybe some of you have seen my previous messages about the HM-10 module.

I'm trying to transfer the temperature readings of my lm35 from the serial monitor to the screen on my iPhone, using "serial" app.


Code: [Select]

int val1;
int tempPin1 = A0;
char c = ' ';
char b = ' ';


void setup()
{
Serial.begin(9600);
Serial1.begin(9600);

}
void loop()
{
     
val1 = analogRead(tempPin1);
int C1 = ( val1/1024.0)*500;


      if (Serial1.available())
    { 
        c = Serial1.read();
        Serial.write(c);
        c = ' ';
     }
     

//
//
//Serial.print("TEMPRATURE C1 = ");
Serial.print(C1);
//Serial.print("*C");
Serial.println();
delay(1000);

  if (Serial.available())
     {
        b = Serial.read();
        Serial1.print(b);
        b = ' ';
     }

}


when i type on my app some Letter or number i receive it on my serial monitor, lm35's readings appears on the serial monitor but i don't see it on my app screen but when i type some Letter or number in the serial monitor i see it on my app screen but don't see the temperature readings!

maybe you can help me please.
thanks you very much

ieee488


blh64

You are checking for incoming data on Serial1 and then writing it out to Serial.

You are reading your analog pin and then writing it out to Serial.

If you want to communicate with your app, you have to write it out to Serial1 as well.

Nick_Pyner

#3
May 26, 2018, 02:17 am Last Edit: May 26, 2018, 02:22 am by Nick_Pyner
I'm trying to transfer the temperature readings of my lm35 from the serial monitor to the screen on my iPhone, using "serial" app.
It doesn't sound like a good idea, and probably not what you are really trying to do.
IF you have succeeded in sending your LM35 data to the serial monitor, all you need do is connect bluetooth to hardware serial, pins 0,1. No further code required, i.e., in pseudo-code
loop(){
receive data from sensor;
Serial.print(data);
delay(1000);
}
That's all. Serial monitor is not involved.

GolamMostafa

@OP

I would like to about your hardware setup -- which one of the following:

(1) iPhone equipped with BTT (Bluetooth Terminal) <-----> Arduino with Bluetooth Module <----> Serial Monitor.

(2)   iPhone equipped with what communication hardware (?) <-----> Arduino with HC12 Radio Module <----> Serial Monitor.

(3)  iPhone equipped with IR communication hardware <-----> Arduino with IR Module <----> Serial Monitor.

(4)  What else?
 

Liz0905

It doesn't sound like a good idea, and probably not what you are really trying to do.
IF you have succeeded in sending your LM35 data to the serial monitor, all you need do is connect bluetooth to hardware serial, pins 0,1. No further code required, i.e., in pseudo-code
loop(){
receive data from sensor;
Serial.print(data);
delay(1000);
}
That's all. Serial monitor is not involved.
Thanks!
I succeeded thanks to you.

Nick_Pyner

I'm really glad to hear that - for more than one reason.

I'm a bit of a fan of bluetooth and I have a couple of HM-10s, but I have never actually used them, indeed I studiously avoid BLE as I think it is more trouble than it is worth, and I know nothing at all about IOS.

In the light of your experience, I reckon it is now time to re-think the former, and also be less dismissive about using IOS. I have produced get-you-started notes on using HC-0x bluetooth which some people have found useful, and now I should update them with some comment on HM-10.

So...
1. what IOS phone app are you using specifically?
2. Is it just a plain vanilla terminal?
3. Have you tried any other apps?
4. Exactly which bluetooth module are you using?
5. Which Arduino?
6. and you really were able to do exactly what I said - connect bluetooth to serial port, go serial.print, and get exactly what you want?

You are not the first to successfully use Bluetooth>IOS for datalogging, but you are only the second that I actually know of, and I lost contact with the other guy before I could confirm exactly what was going on.
So, your contribution could be important, and I want to raise it with others who are more familiar with HM-10. 

Go Up