Reading/converting - Integers from Bluetooth instead of string
Posted: Fri Nov 01, 2019 8:07 am
Hi Forum
I am working on a Generel Bluetooth Low Energy program, for use in the varius control systems my students build. I have now a system which collect data from 3 potentiometers and transmit those via Bluetooth. I am able to read the data in the serial monitor and in nRF-Connect on the phone. On the Bluetooth recever I can see the characters change when I turn the potentiometers.
Problem
I would like to receive pure numerical data.
When I look at my data in the serial monitor I send 05 0B 00 00 --- 32bit
When I receive the Characters 05 0b on “nRF Connect”, it is representative for 0x0B05 = decimal 2821
How do I change my code to get the original integers back, can I get all 32 bits in use?
Is it possible to receive the send data as two integers instead of a string?
Reading the variable from bluetooth
writing the variable to screen
I am working on a Generel Bluetooth Low Energy program, for use in the varius control systems my students build. I have now a system which collect data from 3 potentiometers and transmit those via Bluetooth. I am able to read the data in the serial monitor and in nRF-Connect on the phone. On the Bluetooth recever I can see the characters change when I turn the potentiometers.
Problem
I would like to receive pure numerical data.
When I look at my data in the serial monitor I send 05 0B 00 00 --- 32bit
When I receive the Characters 05 0b on “nRF Connect”, it is representative for 0x0B05 = decimal 2821
How do I change my code to get the original integers back, can I get all 32 bits in use?
Is it possible to receive the send data as two integers instead of a string?
Reading the variable from bluetooth
Code: Select all
//When the BLE Server sends position reading with the notify property
static void AvarCall(BLERemoteCharacteristic* pBLERemoteCharacteristic,
uint8_t* pData, size_t length, bool isNotify) {
//store position
AvarC = (char*)pData;
AvarB = true; }
Code: Select all
void printDHTReadings(){
Serial.print ("Avar");
Serial.print (AvarC);