Puck.js, exposing Sensor Data to Google Science Journal

Posted on
  • Hi Gordon,

    I would like Google Science Journal to be able to record sensor data from my Puck.je over BLE.

    Can you point me to an example that would be relevant please?

    Here are the details, from a user who had a similar problem, visa vi, the Micro:Bit

    "As I understand it the Science Journal app is looking for Bluetooth advertising a service with the UUID "555a0001-0aaa-467a-9538-01f0652c74e8" and sends the value of the sensor on a characteristic with the UUID of "555a0003-0aaa-467a-9538-01f0652c74e8.

    If you use online tools, such as https://pxt.microbit.org/, to program the micro:bit then it will use the UUIDs as specified in the default micro:bit profile as specified at https://lancaster-university.github.io/m­icrobit-docs/resources/bluetooth/bluetoo­th_profile.html

    You would need to use the mbed platform (https://developer.mbed.org/platforms/Mic­robit/) to expose the sensors with the right UUIDs."

    I'm looking to translate that logic to Espruino code. I guess temperature would be good place to start. Note, I'm not trying to create a BLE temperature sensor with the expected temp sensor profile, but rather this particualr flavor the the Science Journal requires.

    Thanks,

    R.

  • It looks like you need to port the arduino code here:

    https://github.com/google/science-journa­l-arduino/blob/master/src/arduino101/sci­ence-journal-arduino.cpp

    You should be able to take a puck.js sample, and change the service Id's like you have identified.

  • Using the link above, it looks like:

    NRF.setServices({
      '555a0001-0aaa-467a-9538-01f0652c74e8' : {
        '555a0003-0aaa-467a-9538-01f0652c74e8' : {
          value : [0],
          maxLen : 20,
          readable : true,
          notify : true, 
        }
      }
    }, { advertise : ['555a0001-0aaa-467a-9538-01f0652c74e8']­ });
    
    // then every so often call:
    NRF.updateServices({
      '555a0001-0aaa-467a-9538-01f0652c74e8' : {
        '555a0003-0aaa-467a-9538-01f0652c74e8' : {
          value : [your_value_here],
          notify : true, 
        }
      }
    });
    

    I guess you might need to add the config characteristic, but it might work as-is

  • Thank you! I think that's exactly what I need...

  • As luck has it, I do have an Arduino 101 in my lab to test this further.

  • This turned out to be quite an adventure.

    https://productforums.google.com/forum/#­!topic/sciencejournal/1C6YI1erycU;contex­t-place=forum/sciencejournal

    Can anyone share if a vanilla Micro:Bit running the 16k ram version of the nRF51822, have the horse power to run a simple ble peripheral with a custom UUID, and a couple of characteristics?

    I wish my Puck had an accelerometer, to go with the magnetometer. Maybe a IMU is in order for next spin?

  • Just checked - looks like there's a crash if you do:

    NRF.setServices({
      '555a0001-0aaa-467a-9538-01f0652c74e8' : {
        '555a0003-0aaa-467a-9538-01f0652c74e8' : {
          value : [0],
          maxLen : 20,
          readable : true,
          notify : true, 
        }
      }
    }, { advertise : ['555a0001-0aaa-467a-9538-01f0652c74e8']­ });
    

    But try this one instead:

    NRF.setServices({
      '555a0001-0aaa-467a-9538-01f0652c74e8' : {
        '555a0003-0aaa-467a-9538-01f0652c74e8' : {
          value : [0],
          maxLen : 20,
          readable : true,
          notify : true, 
        }
      }
    }, { advertise : ['555a0001-0aaa-467a-9538-01f0652c74e8']­, uart:false });
    

    The issue was that it was trying to advertise two 128 bit UUIDs (the UART and the Google one). If you disable the BLE UART it should be fine.

    You could also manually specify the advertising payload to remove the name and put the UUID in the main packet with:

    NRF.setServices({
      '555a0001-0aaa-467a-9538-01f0652c74e8' : {
        '555a0003-0aaa-467a-9538-01f0652c74e8' : {
          value : [0],
          maxLen : 20,
          readable : true,
          notify : true, 
        }
      }
    }, { });
    NRF.setAdvertising([2,1,5,17,7,0xe8,0x74­,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46­,0xaa,0x0a,0x01,0x00,0x5a,0x55])
    

    But that's probably overkill :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Puck.js, exposing Sensor Data to Google Science Journal

Posted by Avatar for user81224 @user81224

Actions