I2C master and BLE communications

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

cross mob
PaHe_1325231
Level 3
Level 3
First like given

Hi

   

I want to read data from an I2C slave device (bme280) to my psoc 4 ble and then transmit these 3 measurements out over ble (cysmart initially). I get the ble configuration to some extent and definitely get the I2C configuration but I just dont get the moving of data from my I2C device out over ble. If i configure a temperature service in BLE, how does it know to take this data from my I2C device? The 100projects 100days sample day 31 digital sensor to me seems to have an error as I can get every other sample project to work in my custom device except for this one. Any and all help greatly appreciated

   

 

   

Regards 

0 Likes
1 Solution
Anonymous
Not applicable

Usually I find the examples to be helpful for understanding the operation to do something (like BLE advertise, read from I2C, etc), but when it comes to writing a project that implements a functionality, it seems easier to keep track of what is going on by starting more or less from scratch.

   

Steps I would suggest:

   

Start with a debugger, and run the chip in debug mode to make sure you are reading/getting the data from the BME280.

   

Once you verify that, then start working on transferring the data to the BLE database on the chip (store it locally using the cyble_gattswriteattribute() function).

   

You should be able to use cysmart to connect to the advertising device and read the attributes to see if it has changed. (You will have to read every time you want to see if the data is different)

   

Next, write the notification function to have it automatically notify the remote BLE device upon data change. (It should be automatically updated on cysmart)

   

Here's some links/posts/examples to look at for figuring it out:

   

http://www.cypress.com/forum/proc-ble/problems-custom-characteristic-notification

   

http://www.cypress.com/blog/100-projects-100-days/project-006-ble-central-immediate-alert-service

   

http://www.cypress.com/forum/psoc-4-ble/sending-int16-array-ble-notification

   

http://www.cypress.com/forum/psoc-4-ble/sending-custom-data-server-client-psoc-4-ble-devices

   

​These should be enough to get you started I think 🙂

View solution in original post

0 Likes
10 Replies
Anonymous
Not applicable

You need to tell the chip if/when to write the data it reads from the I2C sensor into the BLE database. Once you write to the BLE database, you can then read that data when you connect to the device (through BLE characteristics).

   

Another alternative, is to send a notification/indication with the I2C sensor data when it updates/reads/becomes available; This will only send an immediate update to any connected BLE device, and will not save it to the BLE database automatically. Thus, if you want to do both, you will need to run code to handle both.

0 Likes

Any pointers to good examples? Thanks for reply.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I tried this example about 1 or 2 years ago and it worked fine.  You need to use the Dongle to see the data or CYSmart or uC/Probe.  It was  written for the BMP 180 not the BME 280They are different parts and I have checked their data sheets and they are very different.  I would get a BMP 180 or you will be in for a major rewrite of the code.

   

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here are the data sheets for both parts good luck on the project.

0 Likes

Thanks very much bobgoar, it was actually the ble that doesnt show up when i scan using cysmart. However all other ble projects are fine

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Did you update your CYSmart and your ble dongle to the latest revision?

0 Likes
PaHe_1325231
Level 3
Level 3
First like given

yeah all up to date...and its weird just that example that the ble doesnt work. i think my best option is to do it from scratch. i can configure the i2c to read from the bme280 (i think) and its just ensuring then that the ble reads and sends the data to cysmart on my phone

0 Likes
Anonymous
Not applicable

Usually I find the examples to be helpful for understanding the operation to do something (like BLE advertise, read from I2C, etc), but when it comes to writing a project that implements a functionality, it seems easier to keep track of what is going on by starting more or less from scratch.

   

Steps I would suggest:

   

Start with a debugger, and run the chip in debug mode to make sure you are reading/getting the data from the BME280.

   

Once you verify that, then start working on transferring the data to the BLE database on the chip (store it locally using the cyble_gattswriteattribute() function).

   

You should be able to use cysmart to connect to the advertising device and read the attributes to see if it has changed. (You will have to read every time you want to see if the data is different)

   

Next, write the notification function to have it automatically notify the remote BLE device upon data change. (It should be automatically updated on cysmart)

   

Here's some links/posts/examples to look at for figuring it out:

   

http://www.cypress.com/forum/proc-ble/problems-custom-characteristic-notification

   

http://www.cypress.com/blog/100-projects-100-days/project-006-ble-central-immediate-alert-service

   

http://www.cypress.com/forum/psoc-4-ble/sending-int16-array-ble-notification

   

http://www.cypress.com/forum/psoc-4-ble/sending-custom-data-server-client-psoc-4-ble-devices

   

​These should be enough to get you started I think 🙂

0 Likes
PaHe_1325231
Level 3
Level 3
First like given

gentlemen! thank you very much. yes as of today i started back at scratch, however i was working on the ble side first but that suggestion makes much more sense so i will do that get the data working over i2c first. i agree definitely enough to be working with and time to coffee up, knuckle down and get stuck in. thanks again lads

0 Likes