Skip to content
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

Huge thanks, and a request to cover saving parameters #29

Open
Dingolingo opened this issue Jun 5, 2022 · 2 comments
Open

Huge thanks, and a request to cover saving parameters #29

Dingolingo opened this issue Jun 5, 2022 · 2 comments

Comments

@Dingolingo
Copy link

Hi Stéphane,

First, thank you for your clear and helpful tutorial. However, I'd like to see an additional chapter on how to save preferences. I'm working on a particular project where this would be useful, but I think the need is not uncommon.

I'm building a macro rail device with a camera on a platform, supported by rails and moved by a stepper motor. The camera approaches the subject in tiny steps, taking a new image each step. Later specialised software stitches the sharp bits from each image into one image with an incredible depth of field.

The hardware is built, and I used a tutorial similar to yours to create a web interface. I'm not a programmer but have a basic understanding of a couple of languages. I've integrated stepper functionality using ESP-FlexyStepper and remote control of the camera via Canon BLE Remote. It's not finished yet, but I have a working prototype.

About a dozen settings are needed, e.g. camera sensor, focal length, f-stop, the delay between steps, etc. Ideally, a user would save these between sessions. I think that a flexible system could be devised using JSON and SPIFFS, mainly since these are already part of the system.

I've researched SPIFFS and ArduinoJason, but following step by step doesn't give you the depth to extract principles and apply them creatively. Instead, I found articles covering saving parameters and others covering server communication but not an integrated combination of the two.

Would you be interested in writing this? I would be surprised if I'm the only one interested.

Having thought about it, these are the questions that it could answer.

  • What would you save? A string? The aduinoJSON object?.
  • At the web server end, does the parsed JSON object persist for the session, or would I have to create a javascript object?
  • How often should I save? Would I save the entire object or just the changes?
  • Is there a better approach altogether

FYI At the moment, the project is not a commercial. I intend to release it as open-source (Hardware, 3D printed and software). It would only be in the unlikely event it was popular that would I think about commercialising it.

Again, thank you for the article, it was very helpful

Kind regards

peterC

@m1cr0lab
Copy link
Member

Hi Peter,

And thank you for your feedback. I'm glad I could bring you some interesting elements in the development of your project, which seems very promising.

The tutorial is focused on the use of WebSockets and I don't plan to add what you ask. Nevertheless, to answer your question, there is a very simple library that perfectly answers your need. I mean the Preferences library. It is really easy to use, and there are many tutorials on the net to show you how to use it. The idea would be to collect the values of the parameters you want to save in a struct object, then use the putBytes() method to save them, then getBytes() to read them back. The main advantage of this process is that it preserves the saved data, even after powering off or restarting the ESP32.

I think you will be able to use this library without any difficulty.

Among the examples provided with the library, you can have a look at this one, which details the code needed to save a struct object.

Good luck with your project.
Best regards,
Steph

@Dingolingo
Copy link
Author

Dingolingo commented Jun 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants