Closed chinswain closed 7 months ago
Hi,
you have created an interesting application! I just found the information regarding the counter/flags here: https://github.com/pvvx/ATC_MiThermometer?tab=readme-ov-file#custom-format-all-data-little-endian
If you like, you can implement the changes and create a pull request. Otherwise it may take a while until I find some to do this.
Best regards, Matthias
Hi Matthias,
It's an excellent solution and at a very low cost compared to commercial solutions! I know exactly how each beehive is doing in the middle of winter so can go and check for problems.
I think I've worked out how to extract the reed switch status, I can't find the count though (position 13 seems to increment on each advertisement)
https://github.com/chinswain/ATC_MiThermometer/blob/main/src/ATC_MiThermometer.cpp
Added to .h
uint8_t count; //!< measurement count
bool reedSwitchState;
bool gpioTrgOutput;
bool controlParameters;
bool tempTriggerEvent;
bool humiTriggerEvent;
Added to .cpp
// Count
uint8_t flagsByte = foundDevices.getDevice(i).getServiceData().c_str()[14];
// Flags
data[n].reedSwitchState = flagsByte & 0x01; // Extract bit 0 (Reed Switch)
data[n].gpioTrgOutput = (flagsByte >> 1) & 0x01; // Extract bit 1 (GPIO_TRG pin output)
data[n].controlParameters = (flagsByte >> 2) & 0x01; // Extract bit 2 (Control parameters)
data[n].tempTriggerEvent = (flagsByte >> 3) & 0x01; // Extract bit 3 (Temperature trigger event)
data[n].humiTriggerEvent = (flagsByte >> 4) & 0x01; // Extract bit 4 (Humidity trigger event)
Data from the flashing tool shows the counter and flag data is in the advertisement so I assume the device is configured and transmitting correctly:
Vbat: 3002 mV , Temp: 23.30°C, Humi: 48.06%, ID: 1464, Reed switch counter: 11, flg: 0x05:r1/t0
Output from library: Sensor 1: a4:c1:38:9f:03:47 23.90°C 47.59% 2.971V 100% -44dBm Count: 63 Reed Switch State: Closed GPIO TRG Output: Low Control Parameters: Set Temperature Trigger Event: Not Triggered Humidity Trigger Event: Not Triggered
Maybe you can configure if the counter is incremented on each advertisement or only on events?
You can create a pull request by clicking "Contribute" in your branch.
@chinswain Added in https://github.com/matthias-bs/ATC_MiThermometer/pull/8. Thanks for your contribution. Released ATC_MiThermometer v0.3.1.
Would it be possible to add support for reading the state of the reed switch that's been added the custom format?
I have 10 sensors located in 10 beehives (they fix perfectly inside) that are currently reporting temp and humidity (Healthy beehives are always around 35C) which are monitored by an ESP32 that sends the data via LoRa to my house a few miles away.
I'd like to place a magnet in the lid to activate the reed switch I've added to the LYWSD03MMC's so I have an alert if anyone opens the hives.
Custom format (all data little-endian):