You THE MAN, @tomrm! From my quick tests, this code works fine at 460800, with all satellites staying rock solid. AND, BLE now works with iOS devices, which is what I really wanted.
I see you disabled the console writes (which I had tried also) but it appears that activating the 2nd core is what did the trick. Well done!
I see that I am always the last wheel of the cart. Despite Tomrmâs suggestions, I was unable to compile his sketch unfortunately!.
I reduced the baud rate of lg290p to 115200 and with the simplest sketch (the one I managed to install without problems - Evandro Copercini 2018 - classic Bluetooth) I still see a certain instability in the satellite situation.
I am therefore very interested in the Tomrm version: tell me step by step what I can do to solve it? Without saying it, Iâm a novice with the Arduino idea.
Sorry for the inconvenience.
Thanks to everyone who replied!
Greetings
AF
@falajons Basically, in your Arduino IDE, you need to use version 2.0.17 of the esp32 espressif board manager in order to compile it without errors. In order to check, you select the IDE sidebar item marked in yellow below:
Then you search for esp32 and you should see the version you currently have, most likely 3.0.5. You uninstall it, and then select 2.0.17 to install and that should do it. I donât know if the version of the IDE affects it, but I was able to compile it with 2.3.2
Well, I finally succeeded: thanks to you @splee for the assistance and thanks to @tomrm for programming and sharing the sketch.
After changing PC I redid the uninstallation procedure of version 3.0.5 and reinstalling 2.0.17 of esp32 solved the problem.
I tried it at home (itâs now 9.45pm where I come from) and the connection seems to work.
To verify the functioning with the data I have to wait until tomorrow morning.
I inserted the sketch into two esp32 modules.
I also changed the reference to the rx and tx pins for an esp32 module (I put 2 and 4 instead of 16 and 17 - I hope I didnât make a mistake).
I take this opportunity to ask the following question: could the sketch work on an esp32 mini (c3)? But the âminisâ only have, if Iâm not mistaken, the ble.
Greetings and thank you very much again
Your board may be different, but the pin definitions should be the same.
The esp32 C3 does support both WIFi and BLE but it only has 1 core processor while the esp32 has 2, and the two better software use both processor, so the code wonât work as is.
Ok Tomrmâs sketch works (thanks again) but I still have the usual âballetâ of satellites.
What could be wrong with it!? I attach the video!
Greetings
Thanks for your interest: I donât remember the exact model but Iâve attached the photo.
Itâs the wroom 32 in the center of the photo.
Yes, I reach the fix but it comes and goes, i.e. very unstable
How do I set the CPU frequency to 240 MHz!?
Greetings
AF
OK @splee, thanks again.
My problems are rightly not strictly related to quectel and the lg290p module.
What do you mean âIâll PM himâ.?
So where can I still contact you and take advantage of your suggestions!?
Greetings
AF
Here we go @splee! Thanks to your help I solved the problem of connecting via Bluetooth with both the LC29HEA and the LG290P.
I must also thank the author of the sketch very much, namely Mr. Tomrm. I am thrilled with your solution. Without your help I would have been content to wander around the countryside with the GPS attached to my cell phone by wire.
I apologize to Mr. @splee because I made him work because of my inabilities.
Iâll tell you this: as I said a few days ago I saw the satellites âflashingâ in SW maps.
I discovered that when I changed the reference to the tx1 pin on the n. 2 I didnât realize that in the sketch a few lines below the same pin (n. 2) was assigned to âledpinâ!
I ask @splee if he can show me an alternative contact to this forum because I have a question about an esp32 wroom mini module similar to the one I saw in the photos of its configuration.
Thank you again and thanks also to Bamarcante and Jadilson_Motta.
Greetings
AF
Hah @falajons, very good catch! You DID mention that you were using pins 2 and 4, but no one noticed that it was the LED pin, which was being used by the program. I had actually sent you another simple version of the BT (non BLE) only code by forum private message, which was optimzed to work at full speed too. It doesnât use the LED, so it probably would have solved the problem too. But then, we would still be wondering what the issue was!
Ah ok @splee, Iâm sorry but I didnât have the opportunity or time to try your classic bluetooth only version but I saved it and put it in the safe. I will try it soon also because I bought an LC29Hda module (itâs on the way).
Regarding your hardware solution for LG290P in the photo you posted I only see (pins used) where you have attached/connected three wires but not the fourth wire because it is hidden.
Greetings and thank you very much for your interest and availability.
AF
Ok, I ask for the rx and tx wires where you soldered them on your esp32 module (it should be similar to the one in my photo).
Iâll try to guess: RX on IO16 and TX on IO17 (or IO04?). Thank you
Well @falajons, I have some good news for you. Since my issues have been resolved, Iâve been going through cleaning up stuff. Iâve been looking at the various code and managed to get a BLE only UART bridge working on the esp32 C3, based on tomrmâs code. It is only single core but it turns out that most of the work was being done by the uart buffer so it works fine at 460800 bps:
The esp32 C3 doesnât support classical BT, so this version only supports BLE. It works fine on my iOS device but my old Android tablet doesnât support BLE so I canât test it on Android. I understand that later Android versions also supports BLE, so if you have one of those devices, perhaps you can test it out?
Here is the code:
/* esp32 C3 BLE UART Bridge
Use this Code with ESP32 C3 Supermini. Tested to run up to 460800 bps on single core
LED lights when BLE is connected, but doesn't flash with data
Needs to be compiled with board library esp32 expressif V2.0.17
*/
#include <BLEDevice.h> // Library for BLE Bluetooth
#include <BLE2902.h>
// Change to your desired pin, but check data sheet first
#define TX1_PIN 2
#define RX1_PIN 3
#define LED_PIN 8
#define BLE_NAME "TEST_RTK" // Name of the ESP32 BLE for iOS
#define UART_BAUDRATE 460800
#define CONSOLE_RATE 115200
// BLE UUIDs for the Nordic UART Service (NUS)
#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"
BLEServer* pServer = NULL;
BLECharacteristic* pTxCharacteristic = NULL;
BLECharacteristic* pRxCharacteristic = NULL;
bool bleDeviceConnected = false;
bool oldBleDeviceConnected = false;
bool sentOnce = false;
// Callback class for BLE
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
bleDeviceConnected = true;
Serial.println("BLE device connected.");
digitalWrite(LED_PIN, LOW);
};
void onDisconnect(BLEServer* pServer) {
bleDeviceConnected = false;
Serial.println("BLE device disconnected.");
digitalWrite(LED_PIN, HIGH);
}
};
class MyCallbacks: public BLECharacteristicCallbacks { // This callback sends BLE data to UART
void onWrite(BLECharacteristic* pCharacteristic) override {
std::string value = pCharacteristic->getValue();
if (value.length() > 0) {
Serial1.write((uint8_t*)value.c_str(), value.length());
}
}
};
void setup() {
Serial.begin(CONSOLE_RATE);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Initialize UART with baud rate
Serial1.begin(UART_BAUDRATE, SERIAL_8N1, RX1_PIN, TX1_PIN);
// BLE initialization for IOS devices
BLEDevice::init(BLE_NAME);
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
BLEService* pService = pServer->createService(SERVICE_UUID);
pTxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);
pTxCharacteristic->addDescriptor(new BLE2902());
pRxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_RX,
BLECharacteristic::PROPERTY_WRITE
);
pRxCharacteristic->setCallbacks(new MyCallbacks());
pService->start();
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(true);
pAdvertising->setMinPreferred(0x06);
pAdvertising->setMinPreferred(0x12);
pAdvertising->start();
Serial.println("BLE started and advertising sent.");
}
void loop() {
if (bleDeviceConnected && !oldBleDeviceConnected) {
oldBleDeviceConnected = bleDeviceConnected;
}
if (!bleDeviceConnected && oldBleDeviceConnected) {
oldBleDeviceConnected = bleDeviceConnected;
pServer->startAdvertising();
Serial.println("Advertising restarted.");
}
// Receive data from UART buffer and forward to BLE (iOS). BLE to UART direction is handled in callback
while (Serial1.available()) {
size_t len = Serial1.available();
uint8_t buffer[len];
Serial1.readBytes(buffer, len);
if (bleDeviceConnected) {
pTxCharacteristic->setValue(buffer, len);
pTxCharacteristic->notify(); // Send data to connected iOS device
sentOnce = false;
} else {
if (sentOnce == false) {
Serial.println("No BLE device connected. Data not being forwarded.");
sentOnce = true;
}
}
}
}
However, SW Maps for Android doesnât seem to have to option to select the BLE device, so I canât use BLE, just classical BT. Oh well, I guess the esp32 C3 option is just for iOs users
I only remembered the terminal program recently while testing. It was useful to see the data and verify all the checksums at the end, so I know no packets were being corrupted. Before , using the non-optimized code, you could see lines that didnât have checksums and other ill-formed lines from the bridge not being able to keep up.
Excellent @splee: good and generous!
I hope to have the opportunity to reduce my debt with you if you come to my area (Italy) but perhaps you are a little too âhands offâ.
At that time:
I loaded your latest sketch onto two esp32 c3 minis without problems;
with my mobile phone (S21 Samsung) I see that there is a new Bluetooth connection but when I âpairâ nothing is paired (unfortunately) and I canât use it with the GNSS apps;
I attach a screenshot
Yes, I realize that I always have problems unfortunatelyâŚ
Be patient!