Bluetooth mesh network(Zephyr Project) BBC microbit SSH integration

Hi I am trying to figure out a way to read my sensor data in home assistant.
I am currently doing a home monitoring project for my degree and need some help integrating what I currently have:
I have used the zephyr projects Bluetooth mesh network with some modifications using bbc microbits to create a low powered motion detection system for a home.

  • PIR motion detector (HC-501)
    -BBC microbits
    -Raspberry pi 3 with home assistant

I have used a Motion sensor to act as a “button switch” so when motion is detected it will trigger and send data through the mesh network and onto my final device connected to the raspberry pi (currently just to my pc connected using ssh (putty), once it is received it displays a warning message in the terminal stating motion detected, I want this message to display onto home assistant if possible).

Im not sure what the best/easiest way to do this is, should i look into using MQTT or stick to serial communication. I feel like serial communication would be a lot easier if I can somehow get a message to display in home assistant like it does in the terminal.

Any help would be appreciated, thanks for your time!

Hi Daniel,

Just for clarity, is your Raspberry Pi part of the BLE Mesh?

1 Like

I would use your motion-sensing device to send a message to Home Assistant using HA’s Rest API:

https://developers.home-assistant.io/docs/en/external_api_rest.html#post-apistatesltentity_id

You would have an input_number entry in HA, and use a curl command to increment that by 1.

It’s how I have my security cameras tell HA when it detects motion in a particular part of the image, and simultaneously record how many times it has happened.

The curl command I use is like this:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer [[ very long bearer token from HA ]] -d '{"entity_id": "input_number.times_motion_cam_detect_triggered"}' http://192.168.1.xxx:8123/api/services/input_number/increment

You will have to let HA know the IP address of the device that sends the curl command by authorising it in your configuration.yaml file, e.g.

homeassistant:
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.xxx [whatever IP your sending device has]

1 Like

BBC Microbits have no WiFi, only Bluetooth, so I don’t know if that’s an option.

I’ve got a setup that might be similar. I’m using an Adafruit nRF51 board (with an HC-SR04P sensor) and that talks via BLE Mesh to an ESP32. The ESP32 connects to an MQTT server (Using WiFi) and acts as a bridge.

The nRF51 sends readings over the Mesh, and the ESP32 takes those readings and sends them over MQTT to HomeAssistant.

I’ve got one device connected to it at the moment and everything is hardcoded, but it’s reliable. The nRF51 is battery operated and wakes only once a day to take a few readings.

2 Likes

thanks sorry for the late reply, I will take a look into it thanks !

I’m happy to share any code etc. if it would help.

I was thinking would it be possible to use node-red to read the usb port and transmit the message to home assistant? e.g bbc microbit connected to rasp pi usb port and then show that data to the main home assistant(currently I just use minicom to read terminal message).If node red wont work i may need to get the esp32’s.

Sorry for the late reply, I hope this makes sense I am a complete beginner when it comes to home assistant.

I don’t know about the USB port. I did a google and found this question:

Maybe that will be you on the right path??

1 Like

thanks i will give it a try now!

Awesome work! Can ESP32 also work as a provisioner?By the way ,where can I find your code. Thanks a lot.