Code Monkey home page Code Monkey logo

Comments (4)

vojtamolda avatar vojtamolda commented on June 25, 2024

Hello @TechFactory,

Thanks for posting the question and using the plugin. The problem here is that most of the examples provide sketches only for Arduino 101, which is a different board than you have. Some examples like the humidity/ and thermometer/ also contain a sketch for Bluefruit Micro. There's no special reason to use only these BLE boards. Any board when programmed correctly will work with this plugin. I just happened to have these two at home, so I used them.

Unfortunately, the sketches are generally not compatible between different boards and require changes. That's why you see the puzzling error messages about missing ble_protocol.h file. The file really doesn't exist for your Bean, but it's needed to run on an Arduino 101.

Your Bean has a different set of functions that talk to the BLE subsystem. The best way to get started is these examples. Try to create a scratch characteristic, that turns on a LED, when you write 1 to it and turns the LED off when you write 0. When you match the UUIDs with the config.json from the lightbulb/ example, you should be able to get it working.

Sometimes it's a struggle, but when it's finally working HomeKit is a lot of fun and it's certainly worth it. I'll be happy to add support for more boards and merge a pull request with your new Bean example if you want to do it.

from homebridge-bluetooth.

CloudMass avatar CloudMass commented on June 25, 2024

Hi @vojtamolda,

Thanks for the help.

I've made this so far. It's shows up in the home app on the iPhone but the temperature says 0 no matter what I do. Any idea?

#include <SPI.h>
#include <BLEPeripheral.h>

BLEPeripheral ble;
BLEService informationService("180A");
BLECharacteristic modelCharacteristic("2A24", BLERead, "101");
BLECharacteristic manufacturerCharacteristic("2A29", BLERead, "Arduino");
BLECharacteristic serialNumberCharacteristic("2A25", BLERead, "2.71828");

BLEService thermometerService("1D8A68E0-E68E-4FED-943E-369099F5B499");
BLEFloatCharacteristic temperatureCharacteristic("1D8A68E1-E68E-4FED-943E-369099F5B499", BLERead | BLENotify);

void setup() {
  
  Serial.begin(115200);

  ble.setLocalName("Thermo");
  ble.setAdvertisedServiceUuid(thermometerService.uuid());
  ble.addAttribute(informationService);
  ble.addAttribute(modelCharacteristic);
  ble.addAttribute(manufacturerCharacteristic);
  ble.addAttribute(serialNumberCharacteristic);

  ble.addAttribute(thermometerService);
  ble.addAttribute(temperatureCharacteristic);
  temperatureCharacteristic.setValue(0);

  ble.begin();
  
  Serial.println("Bluetooth on");
  
}

void loop() {
  
  ble.poll();

  int tempRead = Bean.getTemperature();
  temperatureCharacteristic.setValue(tempRead);
  Serial.print(tempRead);

  delay(3000);
  
}

Thanks again.

from homebridge-bluetooth.

vojtamolda avatar vojtamolda commented on June 25, 2024

I don't have a Bean to test, but I think you're puting an int value in place of a float value. HomeKit requires the temperatureCharacteristic to be of type BLEFloatCharacteristic . Try changing your code to something like this:

  float tempRead = (float) Bean.getTemperature();
  temperatureCharacteristic.setValue(tempRead);

The conversion is probably happening implicitly anyway, but getting the values to match is what matters here. You're seeing 0, because it's the default used by Homebridge when nothing is received.

Another way to check where is the problem is to use the LightBlue iOS app. When you change the type of the characteristic to float the number there has to match the output from the serial console.

from homebridge-bluetooth.

vojtamolda avatar vojtamolda commented on June 25, 2024

One more thing - Maybe I'm wrong, since I'm not very familiar with Bean's hardware, but I don't think it is currently supported by the BLEPeripheral library. Check the list of supported hardware here.

Bean is in fact an ATmega328p processor and the LBM313 module with battery. The module contains the CC2240 BLE SoC chip by Texas Instruments and an antenna in a nice FCC certified package.

Unfortunately the CC2240 isn't supported by the BLEPeripheral library as it was written for the competing Nordic Semiconductor's nRF5* family of chipsets. It's possible that the code will actually run, but it won't do anything useful.

from homebridge-bluetooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.