-
Notifications
You must be signed in to change notification settings - Fork 130
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
ESP32 OTA Example with a DHT11 data sent - fail to finish download #221
Comments
First of all I'm pretty sure this issue occurs with the last chunk that we attempt to download, because the size is smaller than the chunk size of 4096. Meaning it is the last chunk which contains the remaining data. It is weird tough that the calculation seems to be off, because if the received firmware size shared attribute is correct, then it should be 189 * 4096 and 1 * 2816 bytes big. However in your case it seems like the received firmware size was 189 * 4096 and 1 * 2832. How do you set the firmware size shared attribute. Are you simply using the Firmware Dashboard and assigning a new firmware or are you chaging the shared attributes by hand? |
I'm new to thingsboard. I simply used the Firmware Dashboard to assign a new firmware. |
Okay weird, if you assign the firmware from the dashboard it should work. The only thing I can currently imagine is that it is sending while receiving the data. For now at the top of your Additionally can you switch the PubSubClient version you are currently using to my fork. Currently both sending and receiving write into the same buffer my fork has seperated that behaviour into 2 buffers instead, which means you should be able to send while receiving data. Perhaps that was the issue. |
I have enabled And also replaced the PubSubClient to your fork. Still the same. Let me chop out all the |
You should see more log messages if you retry the udpate with the |
More weird is that despite I deleted v1.0.3 of the firmware and explicitly set the assigned firmware in dashboard for the device to use v1.0.2, the device has still detected a new firmware of v1.0.3. Is there some sort of cache behind the scene for firmware versions binaries in thingsboard? As I have been getting myself familiar with thingsboard I might have created a version of 1.0.3, deleted it, and re-uploaded a different v1.0.3 with a different binary size. |
|
There is not really a cache per se, however the The first thing could you assign |
I checked the device's shared attributes and there's no entry. However, there are Is there a detailed up-to-date (thingsboard v3.7) version of an OTA tutorial I can follow? |
Okay if the shared attributes do not look like this, that would be very weird. Because the update shouldn't even be able to start if these keys do not exist on the device. Can you make sure that in the Shared Attributes Tab of the Device you want to update, if those keys exist and if yes what there values are. |
No, it doesn't have any Shared attributes (admittedly there was a device that had shared attributes but after a few attempts of deleting devices and re-doing the Rule chains etc., nothing shows up in shared attributes and latest telemetry anymore, only server attributes) I have trimmed it down to only running the example 0009 as-is with
|
Yeah that error atleast makes sense you have no shared attributes assigned that could inform the device that it has a new firmware version to update to so it doesn't. What exactly have you changed on the rule chain. Because the OTA update should run perfectly without any changes to it, perhaps those are somehow causing problems. Because normally if you assign the Firmware over the Firmware Dashboard it simply sets the Shared Attribute values as shown above, if that is not the case then something goes wrong in the rule chain probably. |
Please confirm the steps for the OTA process:
|
I'm highly confused by at least half of theese steps, the OTA update works perfectly with the default rule chain, the checking if the firmware is synced is done by this library you don't need the rule chain to do that. (Step 3, 4) Furthermore I don't know why the ESP32 should send shared attributes that isn't even possible (without workarounds), the device can only ever subscribe or request shared attributes but not create them. You don't need step 8. Step 9 to 11 are correct, I'm pretty sure these rule chains you added are somehow borking the expected update process of this library. Can you retry simply with the default Rule chain. So just skip step 3, 4, 7 and 8 I might have an idea, perhaps you are using a really old Firmware Update dashboard which we don't support. Download the firmware dashboard from this documentation page and use that one if you aren't already doing that. |
May I ask where should I put the |
After lots of tweaking, I can only make the OTA process partially work. What's working is that the firmware is actually pushed to the device, but only if I specifically choose the version of firmware from the Firmware dashboard, assign the firmware in device or device profile will not work. I am so sorry that it's taken so long to implement this feature. But I'm really struggling between reading the documentation, putting the settings into my thingsboard instance and guided (or mis-guided) by a very limited video in Youtube together with a 5-year old official video of the OTA feature.
|
No problem I hope it hasn't been too much of a hassle. For the OTA process it is not partially working, OTA is working exactly as expected now. Because if you assign the firmware over the Device Profile or directly to the Device it will not work, because it does not change the If you assign it over the Dashboard however it does change thoose
Will be fixed it the newest version, but currently if you call |
I finally got it working for what I want with 'examples/0011-esp8266_esp32_subscribe_OTA_MQTT/' My expected behaviour is to have a device loaded with v1.0.0 version of firmware, i upload the firmware v1.0.1 in ThingsBoard OTA, change the device profile assigned firmware, the device detect version increment, the device download and flash the v1.0.1 firmware, the device sent updated state when completed, ThingsBoard OTA dashboard shows updated. On the side note, what's the approach if I have a bunch of ESP32 grouped in the same device profile that I want to deploy an update to all of them? Because the sample code has the access token hard coded in, do I have to create partitions in the ESP32 and store the credentials in a partition that will not be updated (so I can write firmware code without the access token in it)? Many many thanks for the help along the way. I feel the whole OTA topic deserves a lot more TLC from an overview write up in the documentation to an updated guide either in video or writing. I can only understand half of what it does after investing 20 hours in it :( but worth the effort |
Yeah sorry to hear I hope the OTA process atleast makes more sense now.
The easiest way which I would recommend is to use The official documentation from ESP32 on NVS might help. For small stimple steps what you need to do is. Write the access token into NVS once and then you can read it again at the start of the application and then use that token to start connecting with ThingsBoard.
If you want to understand how it works under the hood on the ESP32 with the partitions and what it writes this documentation from ESP32 might be useful. And for the general process on the Cloud and how it get's notified this page does exaplain it pretty well and is up to date. I think the main reason for confusion was simply that you used this guide which is pretty old and is not compatible with this library. |
@MathewHDYT once again thank you for your help, I have written up a firmware that uses NVS based on the Once I iron this issue out, I thought it'd be useful if I release the source code of that, together with another example of self-provisioning, in case someone wants to jump-start and build a close-to-production workflow for a ESP32 sensor data logger with self-provisioning to Thingsboard. I have also written up a build script and a upload script for the PlatformIO IDE and the code base is under Arduino framework. |
There is no premade widget available that fufills that functionality and I think there are 2 major ways to solve it both including custom JavaScript code on the ThingsBoard cloud instance. Either you detect the change of the assigned firmware in teh device profile on the rule chain and then write the necessary shared attribute values to every device of that type from the assigned firmware. Or alternatively you make a completly custom widget that allows to select multiple devices or a device profile in a dropdown and select an OTA package and when a submit button is clicked all selected device will have the necessary shared attribute values written,
Sounds good to me the example provided in the library are only meant to provide a jump start, so more complete exampled providing combined functionality would be surely interesting as well. |
I am planning to write code using Arduino framework to use a ESP32 to send DHT11 sensor data to Thingsboard while checking if there's a new version of OTA.
My thingsboard rule chain has been set and have tested with the
0009-esp8266_esp32_process_OTA_MQTT
sample.I suspect it's either the way I code the dht sensor sending to thingsboard that causes the problem.
Here's the main.cpp
https://gist.github.com/csvke/b649ae904155312580a9d9b9c6ddaf58
Here's the ESP32 serial monitor output
[TB] Received chunk size (2832), not the same as expected chunk size (2816)
[TB] Failed to receive requested chunk (190) in (5000000) us. Internet connection might have been lost
The text was updated successfully, but these errors were encountered: