Read Data from external Microcontroller

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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 🙂

0 Likes
1 Solution
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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).

View solution in original post

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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).

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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).

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

Anonymous
Not applicable

Ok. Thank you very much for your detailed response! I will try this and will respond how it went .(y)

0 Likes