This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sending data from ADC over ble to android application and integrating with other data

Hello,

I have platform base on nrf51822, collecting data through I2C and sending to android application. the device is working according following protocol: Motion data is sent twenty times per second and ambient data once per second. Motion data packet has the following format, each bigger box representing a single byte (eight bits), and smaller box representing a half byte (four bits):

Where: Seq is message sequence number F1 (hex) is a fixed constant identifying the data content AX is accelerometer X value, 12 bits AY is accelerometer Y value, 12 bits AZ is accelerometer Z value, 12 bits MX is magnetometer X value, 12 bits MY is magnetometer Y value, 12 bits MZ is magnetometer Z value, 12bits GX is gyroscope X value, 12 bits GY is gyroscope Y value, 12 bits GZ is gyroscope Z value, 12 bits IRH and IRL are infrared sensor’s temperature high and low bytes correspondingly All “X”s are don’t care half-bytes. Ambient data has the following format:

Where: BH and BL are air pressure high and low bytes correspondingly BTH and BTL are air pressure sensor’s temperature high and low bytes correspondingly HH and HL are air humidity’s high and low bytes correspondingly HTH and HTL are air humidity sensor’s temperature high and low bytes correspondingly TH and TL are temperature sensor’s high and low bytes correspondingly.

the protocols are attached. Now, I would like to add data received from an additional sensor through ADC and send it to android application. I use interrupt. how to change the protocol to these additional data will being sent without interference?

the code for android application is here:

Dim register As String = dataHex.SubString2(2, 4) Select register Case "F1" 'motion 'accelerometer Dim accXYZ As String = ParseData.AccelerationToCSV(dataHex.SubString2(4, 13)) SensorData.currentAcceleration = ParseData.ParseResultToString2(accXYZ) 'magnetometer Dim magXYZ As String = ParseData.MagnetismToCSV(dataHex.SubString2(14, 23)) SensorData.currentMagnetism = ParseData.ParseResultToString2(magXYZ) 'gyroscope Dim gyrXYZ As String = ParseData.RotationToCSV(dataHex.SubString2(24, 33)) SensorData.currentRotation = ParseData.ParseResultToString2(gyrXYZ) 'log If (Starter.logFlag) Then value = timestamp &";"& sequence &";"& register &";"& accXYZ &";"& magXYZ &";"& gyrXYZ If (Starter.CSVstore) Then CallSubDelayed2(Starter, "WriteDataToFile", value) If (Starter.SQLstore) Then CallSubDelayed2(Starter, "StoreData", value) End If

			Case "F2" 'ambient
				'air pressure
				Dim baro As String = ParseData.parseHexToAirPressure2(dataHex.SubString2(4, 8))
				SensorData.currentAirPressure = ParseData.ParseResultToString(baro)
				'air temperature (from barometer)
				Dim tempB As String = ParseData.ParseHexToFloat(dataHex.SubString2(8, 12))
				SensorData.currentAirTemp = ParseData.ParseResultToString(tempB)
				If dataHex.Length > 19 Then 'BTL_3X1 type of data
					'air humidity
					Dim humi As String = ParseData.ParseHexToFloat(dataHex.SubString2(12, 16))
					SensorData.currentAirHumidity = ParseData.ParseResultToString(humi)
					'air temperature (from humidity sensor)
					'Dim tempH As String = ParseData.ParseHexToFloat(dataHex.SubString2(16, 20))
					'SensorData.currentAirTemp = ParseData.ParseResultToString(tempH)
					value = timestamp &";"& sequence &";"& register &";"& baro &";"& tempB &";"& humi '&";"& tempH
				Else
					value = timestamp &";"& sequence &";"& register &";"& baro &";"& tempB '&";"& humi '&";"& tempH
				End If
				'log
				If (Starter.logFlag) Then
					If (Starter.CSVstore) Then CallSubDelayed2(Starter, "WriteDataToFile", value)
					If (Starter.SQLstore) Then CallSubDelayed2(Starter, "StoreData", value)
				End If		
			End Select
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		Else

Any help is appreciated. Best regards, Mostafa.protocol environment.png(/attachment/31d751de88cc2224bfe08aa620f70dc3)(/attachment/e8517409fcd5d46eb4be1cd1061ea8d0)

  • @Mostafa : You need to understand how things work, how you can send data from the device to the phone. Then you describe your challenge/issue you face. I mentioned, you can follow our tutorial and the example in the SDK.

    It's not possible to help you without you knowing how things work.

    Try to answer these questions:

    • How do you send 1 byte from your device to the phone ?

    • What is the app on the phone you are using ?

    • How often do you send data from your device to the phone ?

    • How do you organize the attribute table ? How many characteristic, which do what ?

Related