Most recent activity
-
Hi, with the custom firmware everything works perfectly!
After flashing, following these directions: https://github.com/pvvx/ATC_MiThermometer
@Vlad's code fetches values without problems:
var temp = null; var humidity = null; var battery = null; function getSensorData() { NRF.findDevices(function(devices) { if (devices[0] && devices[0].serviceData.fe95) { var data = devices[0].serviceData.fe95; // console.log(data); var flag = data[11]; // console.log(flag); switch (flag) { case 4: { // temp temp = (data[14] | data[15] << 8) / 10; break; } case 6: { // humidity humidity = (data[14] | data[15] << 8) / 10; break; } case 10: { // battery battery = devices[0].serviceData.fe95[14]; break; } case 13: { // temp and humidity temp = (data[14] | data[15] << 8) / 10; humidity = (data[16] | data[17] << 8) / 10; break; } default : { print("Unknown flag: " + flag); } } } for (var i = 0; i < devices.length; i++) { devices[i] = null; } devices = null; }, { filters: [ {serviceData:{"fe95":{}}} ], timeout: 2000 } ); } setInterval(function () { print("Temp: " + temp + " humidity: " + humidity + " battery: " + battery); getSensorData(); }, 5000);
THANK YOU ALL!
-
Hi @fanoush, you are right, in the next few days I will hack one :-)
See you soon!
-
Hi @fanoush, thanks for the link, I initially saw something about: https://github.com/atc1441/ATC_MiThermometer
Then I saw that through Python, without any hacks, you can get the values easily.
Maybe later, I sacrifice one in the name of science :-)
-
Hi @Gordon, I uploaded this code to Pixl.js (2v08)
var deviceInfo = {}; function parseDevice(device) { var d = new DataView(device.serviceData["fe95"]); var frame = d.getUint16(0, true); var offset = 5; console.log("FRAME: " + frame); if (frame&16) offset+=6; // mac address if (frame&32) offset+=1; // capabilitities if (frame&64) { // event var l = d.getUint8(offset+2); var code = d.getUint16(offset,true); if (!deviceInfo[device.id]) deviceInfo[device.id]={id:device.id}; event = deviceInfo[device.id]; switch (code) { case 0x1004: event.temperature = d.getInt16(offset+3,true)/10; break; case 0x1006: event.humidity = d.getInt16(offset+3)/10; break; case 0x100D: event.temperature = d.getInt16(offset+3,true)/10; event.humidity = d.getInt16(offset+5)/10; break; case 0x1008: event.moisture = d.getUint8(offset+3); break; case 0x1009: event.fertility = d.getUint16(offset+3,true)/10; break; // case 0x1007: break; // 3 bytes? got 84,0,0 or 68,0,0 default: event.code = code; event.raw = new Uint8Array(d.buffer, offset+3, l); break; } print(event); } }; setInterval(function () { NRF.setScan(parseDevice, { filters: [{serviceData:{"fe95":{}}}], timeout: 2000 }); }, 5000);
It always prints FRAME, and when the temperature or humidity changes it prints the event:
FRAME: 22616 { "id": "a5:c2:83:xx:xx:xx public", "code": 50578, "raw": new Uint8Array([208, 117, 0, 0, 58, 221, 132, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) } FRAME: 22616 { "id": "a5:c2:83:xx:xx:xx public", "code": 15670, "raw": new Uint8Array([121, 182, 117, 0, 0, 185, 254, 166, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) }
I have no idea how to extract the temperature and humidity :-)
Can I get some useful info from this Python code (0x80, 0x7F)?
THANK YOU
-
Hi @Gordon, thanks for the reply.
As soon as I have time, I try the code on my Pixl.js and tell you!
See you soon :-)
-
I have a Xiaomi LYWSD03MMC Thermometer / Hygrometer and with this CircuitPython library I can fetch its values:
Now I'd like to make everything work on Espruino thanks to your code.
I changed filters: [{serviceData: {"fe95": {}}}] the device is found (although its serviceData should be "ebe0ccb0") but all values remain null.
How do you think it could be solved?
THANK YOU
-
-
-
Twitter.com/saraceni_andrea