- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to attach a BLE module like PSoC BLE to read the data from an external microcontroller via UART/SPI and store them in various characteristics of a BLE Service ( for eg. I want to read the data via UART rx (PSoC) and store it in temperature measurement characteristic of Health thermometer Service and then transfer this data using BLE HTP(Health thermometer Profile).) Any ideas / documents suggestions how to do it ? In what format the temp values should be sent from the external microcontroller and what should be in the firmware of PSoC to read it correctly ?
Thanks in advance for any help 🙂
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Short answer: whatever you want it to be.
Long answer: since you are writing the code for both systems, you are free to define the protocol for the PSoC BLE and the external MCU to communicate. Think about what data you need to transfer. Think about how you can synchronize both systems during startup and if anything goes wrong inbetween (e.g. a CS signal like SPI does).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because the two microprocessors (the PSoC and the one delivering the data) might have different endianess it would be best to convert the yalues to ASCII, send them via serial interface and convert them back to digital (ints, floats) when needed. This allows to terminate the transmission of a data field with a newline which can be seen by the receiver.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank You very much for your fast reply. do u also know if we need to add some kind of address to identify which type of data it is ? . For eg if i am using the same UART port to send the data for two sensors such as weight measurement and temperature measurement.
How should it be sent from external microcontroller(lets say arduino from now) ? How will my PSoC chip identify which value is it !
Secondly, please correct me if i am wrong.In the PSOC creator 3.3 i think we need to configure UART in the design and initallize it accordingly so that it reads the data from arduino using UART rx (at PSOC).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Short answer: whatever you want it to be.
Long answer: since you are writing the code for both systems, you are free to define the protocol for the PSoC BLE and the external MCU to communicate. Think about what data you need to transfer. Think about how you can synchronize both systems during startup and if anything goes wrong inbetween (e.g. a CS signal like SPI does).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may of course define a message as a struct in C-language which you send over th interface as
struct MyMessage {
char SensorNumber;
char SensorASCII[8];
char XtraData;
};
Using UART in PSoC:
- Drop a UART onto your TopDesign
- Double click on it and set properties (ie.Rx Buffer Size to 32)
- Assign pins if not done automatically
- Build
in main.c:
- Call the UART's Start() function
- Poll using _GetRxBufferSize() for number of characters received
- retrieve characters using _GetChar() or GetByte(), see UART's datasheet
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. Thank you very much for your detailed response! I will try this and will respond how it went .(y)