So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By btidey
#87069 Do the temperature and humidity go missing in pairs? If so then that would tend to indicate a glitch in getting wifi connectivity on that cycle. If only one goes missing then it would tend to indicate a glitch in just transmitting one reading.

Also if you are interested in driving battery usage as low as possible then you could consider using a slightly smarter reporting strategy. The overall consumption is being largely determined by the active current even during the few seconds every 10 minutes as the active wifi current (say 80 mA) is much higher than the sleep current. When you have slowly varying readings like temperature and humidity then one can measure and compare with the last reported values (stored say in EEPROM). Only if they differ by more than a significant amount do you then activate wifi, report the measure, and store the measure. These type of sensors have a fair bit of noise in the readings so could for example say that only if the temperature had moved by 0.5C was that meaningful. When I use this strategy I also back this up by forcing a report if one hasn't been done for several cycles (also needs a counter stored). So, for example I might only report if either a significant change has happened or if an hour has elapsed since last report. As turning on the wifi increases the current a lot and increases the duration of the active period, this can have a significant impact on battery drain.
User avatar
By amadeuspzs
#87078 Thanks @btidey that is a good v2 to extend battery life.

I attached a serial console overnight so I could correlate missing readings (this is a mains powered unit).

Image

Above you can see 2 missed readings before 22:56 and one missed reading after. However in the serial console not a single reading is missed, and the result of the MQTT `publish` command is 1 (success) every time:

Code: Select all22:18:07.887 -> rld⸮⸮⸮⸮l⸮| ⸮⸮d⸮p⸮r⸮⸮⸮⸮|"⸮ c⸮⸮oN⸮lNn⸮⸮⸮ cp⸮⸮#$`{lp⸮N⸮ ⸮⸮l ⸮⸮  cn⸮|$⸮d⸮ #⸮⸮oN⸮l⸮⸮l ⸮oN d Ns⸮⸮⸮⸮ ⸮d r⸮⸮o ⸮l`⸮r ⸮p⸮ l⸮r⸮ ⸮⸮N⸮Connecting to SSID
22:18:08.190 -> ..............................
22:18:11.921 -> WiFi connected
22:18:11.921 -> IP address:
22:18:11.921 -> IP.ADD.RE.SS
22:18:11.921 ->
22:18:11.921 -> Temperature (C): 14.50
22:18:11.921 -> Humidity (%): 48.70
22:18:11.921 -> Attempting MQTT connection...connected
22:18:11.956 -> 1
22:18:11.956 -> 1
22:18:11.991 -> Going to sleep
22:27:40.067 -> {ll⸮⸮⸮⸮l⸮| ⸮⸮$⸮"|⸮⸮⸮⸮{⸮c⸮b⸮⸮no⸮loN⸮⸮⸮cp⸮⸮cd`{lp⸮N⸮ ⸮l⸮⸮ B o⸮|l⸮l⸮b⸮⸮oo⸮l⸮⸮l ⸮nol or⸮ےn ⸮$`r⸮⸮o ⸮l ⸮{⸮p⸮$⸮s⸮`⸮⸮o⸮Connecting to SSID
22:27:40.399 -> ..............................
22:27:44.107 -> WiFi connected
22:27:44.107 -> IP address:
22:27:44.107 -> IP.ADD.RE.SS
22:27:44.107 ->
22:27:44.107 -> Temperature (C): 14.30
22:27:44.107 -> Humidity (%): 49.00
22:27:44.107 -> Attempting MQTT connection...connected
22:27:44.145 -> 1
22:27:44.145 -> 1
22:27:44.181 -> Going to sleep
22:37:12.290 -> {l$ܞ⸮⸮$⸮| ⸮ $⸮ "|⸮⸮⸮⸮r⸮B⸮ B⸮p⸮o⸮loN⸮⸮⸮ cp⸮⸮$s$r$p⸮o⸮ ⸮ l⸮⸮ bN⸮|l⸮l⸮b⸮⸮oN⸮l⸮⸮d`⸮2Nnl`or⸮ےn ⸮$`sےn ⸮l`⸮{⸮p⸮l⸮{⸮ ⸮⸮o⸮Connecting to SSID
22:37:12.582 -> ..............................
22:37:16.299 -> WiFi connected
22:37:16.299 -> IP address:
22:37:16.299 -> IP.ADD.RE.SS
22:37:16.299 ->
22:37:16.299 -> Temperature (C): 14.30
22:37:16.299 -> Humidity (%): 48.80
22:37:16.342 -> Attempting MQTT connection...connected
22:37:16.342 -> 1
22:37:16.342 -> 1
22:37:16.386 -> Going to sleep
22:46:44.763 -> rl$ܞ|⸮l⸮| ⸮l⸮b|⸮⸮⸮⸮{⸮⸮⸮b⸮⸮no⸮lNn⸮⸮⸮ #p⸮⸮$s$rdp⸮o⸮ ⸮l ⸮⸮ B o⸮|$⸮d⸮ B⸮⸮no⸮l⸮⸮l ⸮2Nnl`or⸮ےn ⸮l`{⸮⸮⸮ ⸮⸮l ⸮r⸮p⸮l⸮r⸮ ⸮⸮o⸮Connecting to SSID
22:46:45.070 -> ..............................
22:46:48.807 -> WiFi connected
22:46:48.807 -> IP address:
22:46:48.807 -> IP.ADD.RE.SS
22:46:48.807 ->
22:46:48.807 -> Temperature (C): 14.30
22:46:48.807 -> Humidity (%): 48.30
22:46:48.807 -> Attempting MQTT connection...connected
22:46:48.841 -> 1
22:46:48.841 -> 1
22:46:48.912 -> Going to sleep
22:56:17.108 -> rl$ܞ|⸮l⸮|  ⸮ d⸮p⸮{⸮⸮⸮⸮|b⸮b⸮⸮on⸮loN⸮⸮⸮ Bp⸮⸮bl {lp⸮n⸮ ⸮l⸮⸮ bn⸮|l⸮l⸮ #⸮|⸮o⸮l⸮⸮l ⸮Nnl N{⸮⸮⸮o ⸮l`{⸮⸮o ⸮$`⸮{⸮p⸮l⸮r⸮`⸮⸮n⸮Connecting to SSID
22:56:17.410 -> ..............................
22:56:21.113 -> WiFi connected
22:56:21.113 -> IP address:
22:56:21.152 -> IP.ADD.RE.SS
22:56:21.152 ->
22:56:21.152 -> Temperature (C): 14.10
22:56:21.152 -> Humidity (%): 48.90
22:56:21.152 -> Attempting MQTT connection...connected
22:56:21.152 -> 1
22:56:21.152 -> 1
22:56:21.195 -> Going to sleep
23:05:48.553 -> rdl⸮⸮|⸮l⸮| ⸮ $⸮b|⸮⸮⸮p⸮{⸮#⸮ #⸮p⸮n⸮lon⸮⸮⸮ "p⸮⸮c$`rlp⸮n⸮ ⸮l⸮⸮ cn⸮|d⸮⸮ B⸮⸮no⸮l⸮⸮$`⸮no $`or⸮ےn ⸮l rےn ⸮l ⸮r ⸮p⸮ $⸮{⸮ ⸮⸮N⸮Connecting to SSID
23:05:48.867 -> ..............................
23:05:52.597 -> WiFi connected
23:05:52.597 -> IP address:
23:05:52.597 -> IP.ADD.RE.SS
23:05:52.597 ->
23:05:52.597 -> Temperature (C): 14.10
23:05:52.597 -> Humidity (%): 48.70
23:05:52.597 -> Attempting MQTT connection...connected
23:05:52.638 -> 1
23:05:52.638 -> 1
23:05:52.674 -> Going to sleep
23:15:20.938 -> {dl⸮⸮⸮⸮d⸮| ⸮ l⸮ c|⸮⸮⸮⸮2⸮⸮|2"⸮B⸮⸮NN⸮$NN⸮⸮c bp⸮⸮cl`slp⸮o⸮ ⸮⸮⸮l ⸮⸮ BN⸮|d⸮$⸮"⸮⸮NN⸮l⸮⸮l`⸮NN$ ns⸮⸮⸮n ⸮l`r⸮⸮{⸮$ ⸮r⸮p⸮ l⸮r⸮`⸮⸮N⸮Connecting to SSID
23:15:21.242 -> ..............................
23:15:24.997 -> WiFi connected
23:15:24.997 -> IP address:
23:15:24.997 -> IP.ADD.RE.SS
23:15:24.997 ->
23:15:24.997 -> Temperature (C): 14.00
23:15:24.997 -> Humidity (%): 49.00
23:15:24.997 -> Attempting MQTT connection...connected
23:15:25.032 -> 1
23:15:25.032 -> 1
23:15:25.075 -> Going to sleep


So in response to the topic title, the ESP8266 seems to wake up reliably, but the data is not being transmitted reliably despite a 'success' result. Is there anything I need to "flush"?

(on a side note should I PULLUP the TX pin to reduce garbage on wakeup?)
User avatar
By schufti
#87079 That's no garbage at startup - it is the bootloader, using 74880 baud.
If the MQTT publish command returns 1 every time and no record can be found on the server ... either the MQTT library or the server is to be questioned.
User avatar
By amadeuspzs
#87085 Thanks all.

In addition to the serial console, I attached an mqtt listener and have confirmed that both the esp8266 and mqtt broker are correctly receiving all signals. That leaves Home Assistant and InfluxDB as the causes for investigation.

Image

I'll mark this topic solved even though it isn't in its entirety - I've narrowed down where I need to dig deeper.

Thank you for all your help! I'll be sure to implement your suggestions.