• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

BLE tutorial trying to send more than one value

Q&A Forum › BLE tutorial trying to send more than one value
0 Vote Up Vote Down
Graham Gibb asked 7 years ago
6 Answers
0 Vote Up Vote Down
Graham Gibb answered 7 years ago

I have spent many evenings working on this problem but have failed to come up with a solution.
I have programmed the ESP32 BLE example and managed to get the reading on my phone (MIT app).
My next challenge was to add a second temperature probe and get a two readings. I thought this would be a simple modification to the code and app. How wrong could I be.
I have spent hours rummaging through Google pages and have made dozens of changes to the code and to the app.
I have tried to send the second by concatenating to the first reading and putting a character in between so that I can use the Split function in the App Inventor.
I can see the two readings in Serial Monitor but the App can only see one value and I get an error in the app.
Can anyone suggest what commands I should be using? I don’t fully understand the char array but it seems that strings are more resource hungry than chars.

0 Vote Up Vote Down
Juan David Barrero answered 7 years ago

i had the same problem i fixed it using this function sprintf(buffer,”%1s,%1s,%1s,%1s”,temp,pres,high,hum);
pCharacteristic->setValue(buffer);
pCharacteristic->notify(); so i can sent more that one value in a UUID, (but of course you can create several UUIDS and use several BLE on MIT APP however i think that isn’t efficient is better this way) and now the last thing you have to do is add two timer and create to global functions (i call it data_in anda data_list) after that i just do same thing you saw on the moduel with one exception set data_it to stringValue and after that data_list slipt data_in at “,” (you’ll find that box in Text) and thats it and now you only have to do select intem in the lista de Data_list index 1 or 2 or 3 and set it on the expected value. and finally use the second timer to reset the data on that list

0 Vote Up Vote Down
Graham Gibb answered 7 years ago

Hi Juan,
Thanks for the reply,
I saw your solution yesterday and tried it but I wasn’t sure where to put the line of code and what else needed changing in the ESP32.
I put the code (modified for my two inputs) after the dtostrf command, but when I ran the code it kept rebooting the CPU. The sprint command seems to crash the CPU.

0 Vote Up Vote Down
Graham Gibb answered 7 years ago

Success!
Your method is now working for me. I was using the wrong variable names in the wrong part of the code.
Thank you Juan, you have put an end to hours of frustration.

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Thank you for sharing the solution Juan! I’m glad it worked for you too Graham.
Regards,
Rui

0 Vote Up Vote Down
Graham Gibb answered 7 years ago

I still have a small problem. I’ve tried several things but can’t find the cause.
I am sending two values to the app, using Juan’s method and displaying them on separate lines on my phone, but the first value has an open bracket before the number and the second value has a close bracket after the number.
Example:
Temperature 1 (22.5   
Temperature 2  23.7)
I added a label in the app, to display the buffer value, in order to see what the board is sending and it displays (22.5,23.7)
If I print the buffer to the IDE serial monitor it shows 22.5,23.7 i.e no brackets.
Any idea what causes the ()
Thanks
Graham
 
 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.