Closed SongKeat2901 closed 3 months ago
Acaia Lunar 2021 FW 1.0.0.16 Using ESP32-S3
I had tried the code and it doens't want to update new weight. After some digging i found that these 2 "_read.valueUpdated() && _read.valueLength() == 13 "conditon check always fail. I have no idea on how to get .valueUpdated to turn true but i found that the valueLength is 17 instead of 13. if the device is powered of or disconnected, the valueLength is 6
Wonder did you encounter this before?
I realized if using the bareMinimum, the refresh rate was too fast, the response from the scale is 5Hz, a minimum delay (500) is needed.
As of the valueLength, it is still 17
Hi SongKeat, so if I understand correctly, read.valueUpdated() never returns true? What are you seeing on the serial output?
I just tested bareMinimum again with my Pyxis, and confirmed the refresh rate is ok. there is a lot of data other than the 5hz weight-information packets, and there shouldn't be issues with polling the scale for new incoming packets.
Hi Tatemazer, in bareMinimum when i tried with ESP32-S3, i think it is checking too frequently, as a reasult read.valueUpdated() unable to return a "true" value. until i slow it down with a delay, then this statement return "true".
The real issue is actually the " _read.valueLength() == 13", after i got pass the valueupdated(), this statement" _read.valueLength() == 13" is not true. I was testing it with the following device.
Acaia Lunar 2021 FW 1.0.0.16 Using ESP32-S3
I ended up do a print to show the value returned on the valuelength after valueupdate was true, it return 17 instead of 13.
Not sure did it even occur on your end, or is it due to the new FW 1.0.0.16. As of now, the code work flawlessly after add in some delay on the BareMinimum and changes the valuelength to 17.
Just wanna open up this topic to help out other fellows when they having issue with the codes.
Ok, I see the scale's fw version was released very recently, so maybe this update broke the code. I will get my hands on a scale in the coming days to troubleshoot a permanent solution.
@SongKeat2901 I've performed an update on a lunar 2021 and found the update seems to be causing this issue. Unfortunately I don't recall exactly what version I started with, i believe something like 1.0.006 or 1.0.008.
Could you please send me over the exact changes you made to get the code working? either via a pull request or just show me the changes in the code here.
thanks!
by the way, I've just added a debug mode in V2.2.0 to help with troubleshooting. set DEBUG to true to enable.
@SongKeat2901 I've performed an update on a lunar 2021 and found the update seems to be causing this issue. Unfortunately I don't recall exactly what version I started with, i believe something like 1.0.006 or 1.0.008.
Could you please send me over the exact changes you made to get the code working? either via a pull request or just show me the changes in the code here.
thanks!
Hi Tatemazer,
I just do it by brute force, I printed the value of _read.valueLength() and found it to be 17. So I just changed this statement to “_read.valueLength() == 17”
Yet to come up with more elegant solution for now.
@SongKeat2901 I've performed an update on a lunar 2021 and found the update seems to be causing this issue. Unfortunately I don't recall exactly what version I started with, i believe something like 1.0.006 or 1.0.008.
Could you please send me over the exact changes you made to get the code working? either via a pull request or just show me the changes in the code here.
thanks!
Hi Tatemazer,
I just do it by brute force, I printed the value of _read.valueLength() and found it to be 17. So I just changed this statement to “_read.valueLength() == 17”
Yet to come up with more elegant solution for now.
Ah. So you found that adding a delay somewhere was actually not necessary?
Yes. the delay is no longer necessary, it was part of artifact when i tried to debug the conditions. Explained below.
the old code for lunar is this "if (NEW == _type && _read.valueUpdated() && _read.valueLength() == 13 && _read.readValue(input,13) && input[4] == 0x05)"
(due to the bug in 13 and 17 in the valueLength (FW bug))when i tried to troubleshoot i think my approach was check the condition one by one. such as checking the below idividually. _read.valueUpdated() _read.valueLength()
That is when i ran into the issue where the 5Hz matters. If i just trying to print the bool result of the _read.valueUpdated(), is very hard to capture the "true" becuase it happened to fast and get flooded with subsequent falses.
i saw you had updated the code below, which should mitigate the issued i had encouter previously.
// the read.value will turn true evey 5hz and allow the data to get grabbed. if(_read.valueUpdated()){ byte input[] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; int l = _read.valueLength();
currently my code look as below: bool AcaiaArduinoBLE::newWeightAvailable()
{
byte input[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
if (NEW == _type && _read.valueUpdated() && _read.valueLength() == 17 && _read.readValue(input,13) && input[4] == 0x05)
{
// Grab weight bytes (5 and 6)
// apply scaling based on the unit byte (9)
// get sign byte (10)
_currentWeight = (((input[6] & 0xff) << 8) + (input[5] & 0xff)) / pow(10, input[9]) * ((input[10] & 0x02) ? -1 : 1);
return true;
}
i had only replace 13 with 17.
@SongKeat2901 great thanks, happy to hear that's all it takes. I just need to be able to identify this requirement so I know whether to read for 13 or 17 bytes. could you please run the code with debug-mode enabled so I can see if there are any identifiers?
The test output as below
Scale Interface test Found d2:f0:ec:30:7a:3f 'Loc' Found 60:8a:10:58:1c:b4 'LUNAR-581CB4' Connecting ... Connected Discovering attributes ... Attributes discovered
Device name: LUNAR- Appearance: 0x0
Service 1800 Characteristic 2a00, properties 0x2, value 0x4C4C55554E4E414152522D2D Service 49535343-c9d0-cc83-a44a-6fe238d06d33 Characteristic 49535343-aca3-481c-91ec-d85e28a60318, properties 0x18 Descriptor 2902, value 0x000000 Service 49535343-fe7d-4ae5-8fa9-9fafd205e455 Characteristic 49535343-1e4d-4bd9-ba61-23c647249616, properties 0x18 Descriptor 2902, value 0x000000 Descriptor 2803, value 0x Descriptor 9bb3, value 0x Descriptor 43f4, value 0x Descriptor 5b01, value 0x Characteristic 49535343-8841-43f4-a8d4-ecbe34729bb3, properties 0xC Descriptor 2803, value 0x Descriptor 3b7e, value 0x Descriptor 39b3, value 0x Descriptor 5b01, value 0x Characteristic 49535343-4c8a-39b3-2f49-511cff073b7e, properties 0x1C Descriptor 2902, value 0x000000 Service 180a Characteristic 2a29, properties 0x2, value 0x4D4D434348485050 Descriptor 2803, value 0x Descriptor 2a24, value 0x42424D4D37373030 Characteristic 2a24, properties 0x2, value 0x42424D4D37373030 Descriptor 2803, value 0x Descriptor 2a25, value 0x3030303030303030 Characteristic 2a25, properties 0x2, value 0x3030303030303030 Descriptor 2803, value 0x Descriptor 2a27, value 0x353535353030353520203131303032325F5F4C4C4545535344444B4B Characteristic 2a27, properties 0x2, value 0x353535353030353520203131303032325F5F4C4C4545535344444B4B Descriptor 2803, value 0x Descriptor 2a26, value 0x303030303939303031313030 Characteristic 2a26, properties 0x2, value 0x303030303939303031313030 Descriptor 2803, value 0x Descriptor 2a28, value 0x3030303030303030 Characteristic 2a28, properties 0x2, value 0x3030303030303030 Descriptor 2803, value 0x Descriptor 2a23, value 0x000000000000000000000000 Characteristic 2a23, properties 0x2, value 0x000000000000000000000000 Descriptor 2803, value 0x Descriptor 2a2a, value 0x000000000000011000000000 Characteristic 2a2a, properties 0x2, value 0x000000000000011000000000 New version Acaia Detected subscribed! identify write successful notification request write successful tare write successful tare write successful
not showing the scale weight if using the below code
if (NEW == _type && l == 17 && input[4] == 0x05)
sometime it show
3: 0x0221414077
3: 0x0221414077
12: 0xEFEFDDDD0CC0CC055000000000000011000077
5: 0x0000000221414077
3: 0xEFEFDDDD0CC
5: 0xEFEFDDDD0CC0CC055
12: 0x0000000000000110000770000000221414077
1: 0xEFEF
1: 0xEFEF
6: 0xEFEFDDDD0CC0CC055000
11: 0x0000000000110000770000000221414077
10: 0xEFEFDDDD0CC0CC055000000000000011
7: 0x0000770000000221414077
also not working if i only change the l equal to 17
if (NEW == _type && l == 17 && input[4] == 0x05)
only work if i used the old code as below:
if (NEW == _type && _read.valueLength() == 17 && _read.readValue(input,13) && input[4] == 0x05)
i did some modification on the debug the "14" is battery parameter that i try to get.
Scale Interface test Found 60:8a:10:58:1c:b4 'LUNAR-581CB4' Connecting ... Connected Discovering attributes ... Attributes discovered
Device name: LUNAR- Appearance: 0x0
Service 1800 Characteristic 2a00, properties 0x2, value 0x [0]:4C [1]:55 [2]:4E [3]:41 [4]:52 [5]:2D Service 49535343-c9d0-cc83-a44a-6fe238d06d33 Characteristic 49535343-aca3-481c-91ec-d85e28a60318, properties 0x18 Descriptor 2902, value 0x [0]:00 [1]:00 Service 49535343-fe7d-4ae5-8fa9-9fafd205e455 Characteristic 49535343-1e4d-4bd9-ba61-23c647249616, properties 0x18 Descriptor 2902, value 0x [0]:00 [1]:00 Descriptor 2803, value 0x Descriptor 9bb3, value 0x Descriptor 43f4, value 0x Descriptor 5b01, value 0x Characteristic 49535343-8841-43f4-a8d4-ecbe34729bb3, properties 0xC Descriptor 2803, value 0x Descriptor 3b7e, value 0x Descriptor 39b3, value 0x Descriptor 5b01, value 0x Characteristic 49535343-4c8a-39b3-2f49-511cff073b7e, properties 0x1C Descriptor 2902, value 0x [0]:00 [1]:00 Service 180a Characteristic 2a29, properties 0x2, value 0x [0]:4D [1]:43 [2]:48 [3]:50 Descriptor 2803, value 0x Descriptor 2a24, value 0x [0]:42 [1]:4D [2]:37 [3]:30 Characteristic 2a24, properties 0x2, value 0x [0]:42 [1]:4D [2]:37 [3]:30 Descriptor 2803, value 0x Descriptor 2a25, value 0x [0]:30 [1]:30 [2]:30 [3]:30 Characteristic 2a25, properties 0x2, value 0x [0]:30 [1]:30 [2]:30 [3]:30 Descriptor 2803, value 0x Descriptor 2a27, value 0x [0]:35 [1]:35 [2]:30 [3]:35 [4]:20 [5]:31 [6]:30 [7]:32 [8]:5F [9]:4C [10]:45 [11]:53 [12]:44 [13]:4B Characteristic 2a27, properties 0x2, value 0x [0]:35 [1]:35 [2]:30 [3]:35 [4]:20 [5]:31 [6]:30 [7]:32 [8]:5F [9]:4C [10]:45 [11]:53 [12]:44 [13]:4B Descriptor 2803, value 0x Descriptor 2a26, value 0x [0]:30 [1]:30 [2]:39 [3]:30 [4]:31 [5]:30 Characteristic 2a26, properties 0x2, value 0x [0]:30 [1]:30 [2]:39 [3]:30 [4]:31 [5]:30 Descriptor 2803, value 0x Descriptor 2a28, value 0x [0]:30 [1]:30 [2]:30 [3]:30 Characteristic 2a28, properties 0x2, value 0x [0]:30 [1]:30 [2]:30 [3]:30 Descriptor 2803, value 0x Descriptor 2a23, value 0x [0]:00 [1]:00 [2]:00 [3]:00 [4]:00 [5]:00 [6]:00 [7]:00 Characteristic 2a23, properties 0x2, value 0x [0]:00 [1]:00 [2]:00 [3]:00 [4]:00 [5]:00 [6]:00 [7]:00 Descriptor 2803, value 0x Descriptor 2a2a, value 0x [0]:00 [1]:00 [2]:00 [3]:00 [4]:01 [5]:00 [6]:00 [7]:00 Characteristic 2a2a, properties 0x2, value 0x [0]:00 [1]:00 [2]:00 [3]:00 [4]:01 [5]:00 [6]:00 [7]:00 New version Acaia Detected subscribed! identify write successful notification request write successful tare write successful tare write successful 14: 0x [0]:EF [1]:DD [2]:08 [3]:09 [4]:30 [5]:02 [6]:02 [7]:01 [8]:00 [9]:01 [10]:01 [11]:01 [12]:0E [13]:33 Battery : 48 14: 0x [0]:EF [1]:DD [2]:08 [3]:09 [4]:30 [5]:02 [6]:02 [7]:01 [8]:00 [9]:01 [10]:01 [11]:01 [12]:0E [13]:33 9: 0x [0]:EF [1]:DD [2]:0C [3]:0C [4]:05 [5]:00 [6]:00 [7]:00 [8]:00 8: 0x [0]:01 [1]:00 [2]:07 [3]:00 [4]:00 [5]:02 [6]:14 [7]:07 13: 0x [0]:EF [1]:DD [2]:0C [3]:0C [4]:05 [5]:00 [6]:00 [7]:00 [8]:00 [9]:01 [10]:00 [11]:07 [12]:00 4: 0x [0]:00 [1]:02 [2]:14 [3]:07 19: 0x [0]:EF [1]:DD [2]:0C [3]:0E [4]:05 [5]:00 [6]:00 [7]:00 [8]:00 [9]:01 [10]:00 [11]:06 [12]:30 [13]:07 [14]:00 [15]:00 [16]:02 [17]:1C [18]:37
My result
14: 0x | Pycia Payload Number | -- | -- | -- [0]:EF | Header 1 | [1]:DD | Header 2 | [2]:08 | Command / Message Type | 8 == Setting parameter [3]:09 | 0 \| Number of byte Length | [4]:30 | 1 | &07F to get Battery Value [5]:02 | 2 | 2 == gram \| 5 == ounces [6]:02 | 3 | [7]:01 | 4 | Self off duration = payload * 5 [8]:00 | 5 | [9]:01 | 6 | Beep sound On/off 1= On [10]:01 | 7 | [11]:01 | 8 | [12]:0E | 9 \| Checksum 1 | [13]:33 | 10 \| Checksum 2 |
Acaia Lunar 2021 FW 1.0.0.16 Using ESP32-S3
I had tried the code and it doens't want to update new weight. After some digging i found that these 2 "_read.valueUpdated() && _read.valueLength() == 13 "conditon check always fail. I have no idea on how to get .valueUpdated to turn true but i found that the valueLength is 17 instead of 13. if the device is powered of or disconnected, the valueLength is 6
Wonder did you encounter this before?