-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigating on values #1
Comments
On my sensor the last value is also
|
Hi there, Thanks a lot for your work. Here are my values for my 4 sensors :
|
if that's a 16-bit word, looks like this parameter is in range 0x0Bxx - 0x0Cxx and doesn't change very often. |
I think it is the value of the battery voltage in mV. This is: 0BC0 hex = 3008 mV= 3.008 V |
Thanks for the info. I saw this post with supposed voltage somewhere else a few days ago and wanted to make some tests. Didn't manage yet. Yeah it seems that the battery value of 99 % never changes. I had to change the battery in a Aqara because the device went off when placed vertically. Just lying on the table it worked without problems. Battery value read out was still 99 %. The Aqara sensors have a battery indicator which shortly was displayed before this particular device was going off. I have a voltage meter and a low battery now, so I'll report back in a few days. |
Someone may be interested to know that the LYWSD03MMC sensor has an internal operating RTC. With the advantage of having battery support. Although the sensor does not present it on the LCD screen, in the UUID ebe0ccb0 -... / ebe0ccb7 -... maintains the date and time in UnixTime format (seconds since Jan 01 1970. (UTC) - https: // www.unixtimestamp.com/index.php). This UUID allows Read and Write. To initialize the UUID, you must write the desired Date / Time with the bytes in the raw format (endian littel format). Of course, you have to take into account the time zone |
I can confirm now last to bytes are the battery voltage. Note: When measuring the battery outside the device battery level is about 0,15 V higher than displayed on the last 2 bytes. To measure "the real" voltage when Aqara sensor is sending data, I put a wire under the contact for the minus pole. On my measurement the voltage bounced about 0,05 V. Thats very strange since Bluetooth low energy consumes very little power. I think the batteries included in the Aqara are from low quality. Out of 8 sensors I now have two with empty batteries. But not the ones I'm using the longest time. I suspect bad battery quality for the second delivery. |
Hi JsBergbau, when you say Aqara (product name WSDCGQ11LM) is that the same as LYWSD03MMC? |
JsBergbau: " My first Aqara which is now running since first or second week of January now has 2554 mV. " |
I was running with a constant connection for about a month (I got 7 of those sensors, out of which 4 was polled for the home assistant), in two of them battery died - those which were not polled have 3.06V on the battery and in two discharged ones the voltmeter shows 2.6V, so I guess having a constant connection isn't very good idea. It's notable as both of them discharged with the difference of several ours. |
Oh, and for the record, the battery level that was retrieved via polling was always 99%, even minutes before they shut down, so the battery percentage is not reliable. @jaggil, great finding! @JsBergbau awesome idea on having these as a battery level. For the reference - 2.75V can be considered as 0%, as that's the voltage on a completely dead sensor. When plugged in into back the sensor, it doesn't turn on. It's the same battery that was showing ~2.6 before, I guess the voltage drops over the time and restores up to a certain point, I'm no batterologist. |
In my battery tests I have used an adjustable power supply, and the summary is as follows: OK friends, |
Where did you read that WSDCGQ11LM and LYWSD03MMC are the same? I even don't know WSDCGQ11LM sensor.... |
As I understand it, we have two different products: But you make many references to the Aqara sensor and that confuses me if you mean one or the other. |
I can confim that.
Currently my sensor with the lowest batterylevel is running at 2.29 V. The voltage even recovers a bit, it now was 2.32 V.
I've implemented now reading out the voltage and will impemtent the -b option to give an estimated percent value. For compatbility reasons you can still specifiy a number after b but it will be ignored. |
Script is now updated to read battery voltage and get an estimated battery level based on the battery voltage. |
Would be interesting to see some comparison between subscribing to notifications and polling (e.g. every 5 or 10 minutes) now with the voltage data. Has anybody done that yet? |
MiTemperature2 extensions Hello, I have continued investigating all the parameters that are accessible by communications and I have found / decoded the meaning of the following points: 1.- Command to stop / resume T / H / Batt notifications but keeping the connection active. This would be an alternative to disconnect completely and reconnect after the desired reconnection time. 2.- Command to change the units of the temperature of the LCD screen in degrees Fahrenheit. This only affects the screen, notifications remain in degrees Celsius 3.- Setting the time, date and time, internal clock (UnixTime format). 4.- By default the sensor stores records every hour of the maximum / minimum temperature / humidity and with date and time stamp. They can be read by notifications 5.- Command to read the amount of stored records. 6.- Command to delete all records. 7.- Command to read by notifications, from a specific record. 8.- Command to read the last stored record (in the last hour) 9.- Command to initialize maximum and minimum temperature and maximum and minimum comfort humidity. It is supposed to affect the face icon that appears on the LCD screen, it is still unclear. If anyone is interested in using any of them, you can let me know here, and I will post the details of how to do it. |
Hi, that’s would be a great piece of information, I think community will
greatly appreciate it. Please share!
On Sat, 22 Feb 2020 at 12:14, jaggil ***@***.***> wrote:
MiTemperature2 extensions
Hello, I have continued investigating all the parameters that are
accessible by communications and I have found / decoded the meaning of the
following points:
1.- Command to stop / resume T / H / Batt notifications but keeping the
connection active. This would be an alternative to disconnect completely
and reconnect after the desired reconnection time.
2.- Command to change the units of the temperature of the LCD screen in
degrees Fahrenheit. This only affects the screen, notifications remain in
degrees Celsius
3.- Setting the time, date and time, internal clock (UnixTime format).
4.- By default the sensor stores records every hour of the maximum /
minimum temperature / humidity and with date and time stamp. They can be
read by notifications
5.- Command to read the amount of stored records.
6.- Command to delete all records.
7.- Command to read by notifications, from a specific record.
8.- Command to read the last stored record (in the last hour)
9.- Command to initialize maximum and minimum temperature and maximum and
minimum comfort humidity. It is supposed to affect the face icon that
appears on the LCD screen, it is still unclear.
If anyone is interested in using any of them, you can let me know here,
and I will post the details of how to do it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1?email_source=notifications&email_token=AD2R7HXMR5UXBOT7HJXU5ATREBN4BA5CNFSM4KCZUDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMUMYWA#issuecomment-589876312>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD2R7HW37LGP6OQFKCJKYN3REBN4BANCNFSM4KCZUDWA>
.
--
Kind regards,
Rustam Gilyazov
|
Yeah please share. BTW: How did you manage to find out these parameters? |
To whom it May concern, (Part 1) First of all I want to apologize for my level of English. I also want to say that I have done the research with two android apps, namely: The second is a support to see the messages (logs). Until these days I didn't know anything about BLE, so I had to read some documents, this is one of the ones I've used and that can help to understand BLE a bit (sorry, it's a PDF in Spanish): Without going into deep analysis, the summary that I have been able to understand is the following: Well, after this introduction, let's get to the point. In order not to write too much, I will simplify the references to the UUIDs as follows: 1.- Then, when both devices are connected, and the central device has activated the reading by "Notifications" the "characteristic ebe0ccc1-" is received every six seconds until a command to stop the "Notifications" is sent or proceed to disconnect completely and the sensor device will return to the "Advertising" state. gatt.setCharacteristicNotification(ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6, true) gatt.setCharacteristicNotification(ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6, false) Both commands are activated in the nRF app by clicking on the three arrows icon Before continuing with the following points, please tell me if this part is understood and I am able to explain myself. |
@JsBergbau : But also I could fetch maximum and minium data within that 5 minutes. That gives a much better accuracy because you don't miss any short changes. If you're thinking of using the device's local storage to do that, I'm afraid it doesn't work, since the record you make is "per hour" and only stores a maximum / minimum temperature value and a humidity value. maximum / minimum, but within that hour not within its 5 minute connection period. |
@jaggil: Yeah thanks a lot. I understand so far. Please go on in explaining.
Yeah I know that, but we have:
So get min and max from the last hour. Delete all records, get current value. Disconnect. Connect again in 5 minutes and do the same again. I think that will work and you won't lose short spikes within that 5 minutes. |
I did some measurements and when connected the sensor used 25 times more power than on advertising mode, more details see here #10 (comment) I'm looking forward to get the UUIDs/characeteristics @jaggil found out, to implement a connection interval every 5 minutes with maintaining sudden changes within that interval. |
For power draw and battery related stuff I've created a new issue. Please discuss there #18 |
To whom it may concern (Part 2) 2.- To change the temperature units on the LCD screen, we have to use the following commands: Of course, we can also read the current value with the command The data is a single byte. 3.- To set the internal clock, we must know that it is in the following location and that the data is in UnixTime (little-endian) format. The read command is: Converting the data into decimal we have: The command to set the clock is: If the nRF app is used, the "BYTE ARRAY" data type must be selected in the menu that appears when the write icon is pressed (up arrow) 4.- Hourly records of max / min values. Each register occupies 14 bytes. All data has the little-endian format (except its has a single size byte). The next 4 bytes are the date / time in UnixTime format. The next two bytes are the maximum temperature. The following command activate the reading by notifications: Disabling notifications for ebe0ccbc-7a0a-4b0c-8a1a-6ff2997da3a6 When notifications are activated for the first time after a new connection, the sensor device sends all the records starting with the oldest one. I will finish this part here so as not to make very extensive publications. |
To whom it may concern (Part 3) 5 and 6.- Command to read the amount of stored records and deleted. What I have been able to understand, we have a record index and total records, that is: Why don't they match? Because on this device I have already done some deletion of records. The delete command is located at: And in the nRF app log we have: If we now read in "ebe0ccb9-" we find that the total number of records is 0x00000000, but the first index is the last one that had been registered. My opinion is that the delete command only affects the storage of Max / Min records, but not the evaluation that the device is currently doing with the temperature / humidity and that it will register when the 1 hour cycle is completed . What we don't know is when will the index restart? 7.- Command to read by notifications, from a specific record. The range of the value we can write will be what we determine when we have read "ebe0ccb9-" and we will have the oldest and last value. 8.- Command to read the last stored record (in the last hour) The data is decoded in the same way as in point 4 9.- Command to initialize comfort values for the face icon It is understood that the "happy face" located in the center is where the temperature and humidity limits provide the best comfort Well, the default T / H limits are found in: Where the limits are: The commands to read and write are the following: Writing request to characteristic ebe0ccd7-7a0a-4b0c-8a1a-6ff2997da3a6 Well, here is all that I have been able to decode. Luck and thanks Updated 2020/02/27 We are talking about the following characteristic: With this characteristic you can configure the communications interval, once the connection has been established, between the sensor device and the central device: When the two devices negotiate the connection parameters, they agree on parameters to transmit data very quickly, as we can see in the log with the nRF app: As you can see, the final interval is 30.0 ms But the problem is that this interval discharges the battery very quickly. To change it we can use the command: Now the interval is 500ms and the battery consumption will be much lower, but communications are slower, although for T / H parameters it is not critical. I have read that the official BLE protocol includes intervals from 7.5 ms to 4 seconds, but the LYWSD03MMC device supports a maximum of 500 ms. |
Thank you very much for investing your time in investigating and your detailed report for the community. I've linked to this issue in the readme that also other users can find it easily. |
Hi all, I would like to use an slightly modified version of this script to receive notifications from this new xiaomi bluetooth door/window sensor: The first thing is to find out the way to connect to this sensor. I have started following @jaggil instructions, but I've had no success. I have connected to the device using NRF android app, and I have enabled all notifications, but I still do not receive any notification. If I do the same with a LYWSD03MMC, I periodically receive notifications. I don't know what to test next. Any suggestion? Thanks for your help. |
Hello @pulgarzito , without having a device like yours, we cannot do tests to help you effectively.. It is also possible that there is a "CHARACTERISTIC" (a bit hidden) that blocks notifications in a general way. |
Updated the bluetooth scanning to only show devices named 'LYWSD02' to remove unwanted devices Updated updateUnit to actually read and write to set the appropriate values based on discussion on JsBergbau/MiTemperature2#1 (comment)
@jaggil, @JsBergbau I did some measurements on LYWSD02MMC - the last 2 bytes of characteristic ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6 are not battery millivolts (mV) or the measurement is extremely imprecise when the battery is low (sometimes value of these 2 bytes increase when the real voltage has decreased). The following measurements were made by connecting a single almost empty CR2032 battery in parallel with 3300 μF capacitor and 2 multimeters (manufactured by Extech and Aneng) to LYWSD02MMC.
|
Hey, great job with getting this working!
For your reference,
gattool
output for my sensor isThe unknown values for my sensor are
c0 0b
.After a while it read
e5 0b
.The other one
The text was updated successfully, but these errors were encountered: