Comments (7)
I would suggest you start with the temperature example (https://github.com/floe/BTLE/blob/master/examples/temperature/temperature.ino) and change the UUID to the one for humidity (should be in the BTLE specification UUID list).
from btle.
Thank you for your answer. I tried, I succeeded. However, I need battery power, temperature and humidity. I tried to use NRF_DEVICE_INFORMATION_SERVICE_UUID, but nothing works. Please tell me what I'm doing wrong?
`#include <BTLE.h>
#include <RF24.h>
RF24 radio(9, 10);
BTLE btle(&radio);
struct battery_level_data {
uint16_t service_uuid;
uint8_t battery_percentage;
};
void setup() {
Serial.begin(9600);
Serial.println("BTLE multichunk sender");
btle.begin("RD"); //can be emptystring
}
void loop() {
battery_level_data battery_data;
battery_data.service_uuid = NRF_BATTERY_SERVICE_UUID;
battery_data.battery_percentage = 80;
nrf_service_data temp_data;
temp_data.service_uuid = NRF_TEMPERATURE_SERVICE_UUID;
//temp_data.value = BTLE::to_nRF_Float(36);
temp_data.value = 36;
nrf_service_data hum;
hum.service_uuid = NRF_DEVICE_INFORMATION_SERVICE_UUID;
//hum.value = BTLE::to_nRF_Float(77);
hum.value = 77;
btle.preparePacket();
if (!btle.addChunk(0x16, sizeof(battery_data), &battery_data)) {
Serial.println("Battery level does not fit");
}
if (!btle.addChunk(0x16, sizeof(temp_data), &temp_data)) {
Serial.println("Temperature does not fit");
}
if (!btle.addChunk(0x16, sizeof(hum), &hum)) {
Serial.println("hum does not fit");
}
btle.transmitPacket();
btle.hopChannel();
delay(500);
}`
from btle.
INFORMATION_SERVICE won't work for humidity, that's something entirely different. 0x2A6F seems to be correct, see also here: NordicSemiconductor/Android-nRF-Connect#52
from btle.
I probably asked the question not quite correctly .. I managed to send the humidity, as you advised, replacing 0x1809 with 0x2A6F. But I do not understand how to transfer 3 parameters at once in one package - tempurature, humidity, and battery charge. My sensor needs all of them.
from btle.
I think the code you posted actually looks pretty correct (apart from the humidity UUID). What does e.g. the nRF Connect app show for your device when all 3 parameters are present?
from btle.
Only 2 parameters will arrive in NRF connect. There is no third at all (humidity). The message "hum does not fit" arrives in the serial port. It feels like btle.addChunk doesn't add a third parameter. If we swap the blocks
if (! btle.addChunk (0x16, sizeof (temp_data), & temp_data)) {
Serial.println ("Temperature does not fit");
}
and
if (! btle.addChunk (0x16, sizeof (hum), & hum)) {
Serial.println ("hum does not fit");
}
in some places, then in the series the message "Temperature does not fit" and in the NRF connect there is no temperature ...
from btle.
OK, then you're running out of space in the advertisement, for the nRF24, you can only have at most 21 bytes of payload. Try setting the name to "" (empty string).
from btle.
Related Issues (20)
- consider adding BTLE the arduino library repo HOT 1
- Sensor detected but UUID unrecognized HOT 1
- Why am i getting this error? HOT 2
- Estimote HOT 1
- How can i set/change nrf24l01 UUID? Can it support Eddystone? HOT 3
- nRF receiving wrong payload? HOT 9
- How to set MAC address of nrf24l01 HOT 2
- function reversing to_nRF_Float(float t) HOT 2
- pdu_type incorrect? HOT 4
- eddystone_url.ino Does not see the program Physical WEB and Nearby HOT 10
- multichunk.ino compilation problem
- window / door sensor HOT 4
- error while compiling 'send' example after install BTLE HOT 6
- Receive data from phone HOT 1
- Sending CSV file over nrf24L01 as BLE to Android App HOT 1
- Support for NRF52x devices? HOT 1
- Doesn't show up on iPhone 6 HOT 17
- What data is contained in the payload using recv file? HOT 1
- Is it possible to catch data from smartphone? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btle.