My ESP32 application has various preferences, to keep it simple lets keep it with one temperature... Celcius or Farenheit. How do I read the currently set value through bluetooth and how do I send a new preference? The preference are stored using preferences.h library.
Since I have multiple settings I was thinking sending the settings in a JSON string... and parse the incoming string on the ESP32.
Would love to receive your thoughts and opinions about this, perhaps a link to a tutorial (tried google but could not find one that answers my questions).
How do I read the currently set value through bluetooth and how do I send a new preference? The preference are stored using preferences.h library.
Do you know how to store and retrieve data in nvs with Preferences.h with the .put() and .get() commands. There are library examples for the ESP32 and if you look at the source code for the library it is pretty easy to understand.
Since I have multiple settings I was thinking sending the settings in a JSON string... and parse the incoming string on the ESP32.
I'm not exactly certain what your JSON string is and how you will parse it but there are two methods for storing character strings.
EDIT: The Arduino JSON library is available for the ESP32.
Thank you very much for the feedback... the main issue I have is sending and retrieving data using bluetooth.
Preferences is rather simple to use, straight forward... sending and reading these values trough bluetooth not s o much and would like to get a push in the right direction here.
Great. The place to start is with the library example "SerialToSerialBluetooth". With the exp 32 selected as your board in the ide you will find it in the pull down menu of the Arduino IDE.
File>Examples (examples for ESP32)>BluetoothSerial
If you have an Android phone, I would recommend using it. I use Kai Morich's SerialBluetoothTerminal
What version of the ESP core for Arduino are you using? Did you load it from the boards manager?
There is a bug in the most recent version 1.0.5 where the phone won't reconnect after a disconnect unless the ESP is restarted. Using 1.0.4 will disconnect and reconnect freely from the terminal app. This will be fixed in version 1.0.6.
Since I have multiple settings I was thinking sending the settings in a JSON string... and parse the incoming string on the ESP32.
Why do you want to use the JSON string to hold your settings? Is it something you are familiar working with? Have you used the ArduinoJson.h library?
Have you looked at the information in the Serial Input Basics previously referenced.
Hello, thanks for getting back to me. The information you've provided is very useful.
Are you thinking of using BLE at some point? Why?
I've been reading that BLE can do a network mesh... I am in the design / testing phase for 4 devices that should communicate with each other as well. Right now I will be using canbus for this... but additionally I believe a bluetooth mesh would be good as well, avoiding the extra cables needed.
If you have an Android phone, I would recommend using it. I use Kai Morich's SerialBluetoothTerminal
That looks like an excellent tool, I'll need to get my self an Android phone, at the moment I am on iOS.
What version of the ESP core for Arduino are you using? Did you load it from the boards manager?
I am using Arduino IDE to write the software and upload... I have absolutely no clue what version of the ESP32 core I am uploading, what is the best way to check this?
Why do you want to use the JSON string to hold your settings? Is it something you are familiar working with? Have you used the ArduinoJson.h library?
Have you looked at the information in the Serial Input Basics previously referenced.
My mistake, no settings I would store with preferences.h library. I just thought sending the numerous settings via bluetooth in a JSON string (send and receive) makes most sense... just brain dumping my thought here, perhaps there is a much simpler and stable way to do it.
Thank you very much for your time and effort. Appreciate it.
I have absolutely no clue what version of the ESP32 core I am uploading, what is the best way to check this?
In the ide under Tools>Board>Board Manager you should be able to see the installed version.
I've been reading that BLE can do a network mesh... I am in the design / testing phase for 4 devices that should communicate with each other as well. Right now I will be using canbus for this... but additionally I believe a bluetooth mesh would be good as well, avoiding the extra cables needed.
The mesh network is totally out of my experience. I don't think it can be done with classic bluetooth.
BLE is complex and I'm not certain how to do a mesh network.
Typically the mesh networks are done with radios like the nrf24l01. you may be able to configure a local wifi network to do the same thing.
I think you are still in the research phase. What does Google tell you about
"Replace canbus with wireless mesh network"
I think you are still in the research phase. What does Google tell you about
"Replace canbus with wireless mesh network"
I've looked into it before, there are pros and cons, the main issue with Bluetooth is the range approximate 10 meters. In regards to the project I am working on, this would not be that much of an issue since the devices are usually located inside the space, e.g. a closet or garden house kind of space - to give you an idea.
That said, I will stay with classic bluetooth for now, for setting and configuration and canbus for communication between devices. Switching to BLE would be mainly a software upgrade which can be done any time.
Just curious, do you know if an OTA update through bluetooth could be done with ESP32, sending new firmware? Just brain dumping here... mobile application would download the latest update and then pushes this trough bluetooth to the ESP32...