-
Notifications
You must be signed in to change notification settings - Fork 82
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
Can you switch the codes from ESP-IDF to ESP32 libraries in Arduino IDE? #29
Comments
Hi there, and thanks for you interest. We've never looked at the ESP32 Arduino IDE, it might not be an easy thing to do. I'll have a look at it tomorrow and comment again here. |
Thanks, Rob for the quick response, if you look at something like Sparkfun LTE libs that would be great too; Details: Gpy is ESP32 plus Sequans Monarch, but they do not have good library support as you do, so that is why we switched to SaraR410M-2B and we wanna integrate it with our ESP custom-designed board. So I recently bought some Sparkfun level-shifters to connect ESP32 3.3 volts to Sara modem 1.8 V Uart pins, similar to Sparkfun Arduino shield Eagle design, but I need codes to send a message(eventually image) from ESP to our website using Sara cellular modem, unfortunately, ESP-IDF is not that optimal, however, I am looking at some easier ways like using Visual studio IDE for IDF integration now, but if you could migrate to Arduino Libs, that would be gold! Thanks, |
Hi again. I started writing a comment about how I didn't understand the relationship between Arduino and ESP-IDF but then I found this article which suggests that ESP-IDF is already there, inside the pre-built libraries included with the Arduino IDE. In other words, you should be able to take the Then you would have the Have you tried doing anything like this? |
Hi Rob, Thank you, I looked at my Arduino lib folder, I found IDF-related files, so the integration sounds cool! I used Sparkfun Sara-r4 shield eagle files and added your LTE modem schematic to our ESP integration board in Eagle but I am worried on software side; It is a little vague how to use ESP-IDF ubxlib APIs for me (I worked with ESP-IDF previously, I need to install it again), For example, which ESP32 pins to connect to Sara-R4? I assume Uart0 to UART pins of Sara-r4 using a level shifter... I have components, but honestly, I could not understand how your cellular example work, what should we set when uploading the code, where to add APN? what your example will print in the terminal of ESP-IDF? My goal (and I assume every developer's first goal) is to send a "Hello World" message using Sara LTE with ESP-IDF, how can I do that with ubxlib Github examples with ESP32? Then I will modify that to send my images... Some LTE messaging examples; I know you guys are busy but if one of your engineers could add an LTE messaging Github example or record a video on how to use ubxlib/GPIO APIs with ESP-IDF on your ublox1 YouTube channel that would be great. Thanks, |
Having checked other priorities we will be able to make time to have a poke at this in the next few weeks. I can't promise that it will work, there might be impossibilities or too-hard-for-us-to-solve things hiding within it but I'm hoping this will be just another set of build metadata, no code required. If that is true it will indeed be a valuable addition. I will report back. |
Sounds good, Rob, really appreciate it! Also, adding more info on how to use the current cellular API examples will help too, I will dig more on cellular documentation too! |
On the issue of documenting how to use the cellular API examples, can you provide some hints as to what needs to be clarified? Since we know how to use it and have made an attempt to explain we need your help to figure out where we can improve. |
Sure, I think first I need to install IDF and run it asap to get a better user experience, However, today I checked the runner folder, it gave more clues on how it might work; It looks like you made some "general" examples here; https://github.com/u-blox/ubxlib/tree/master/example Also, the hardware part is not clear, if there was a schematic picture (fritzing, or eagle) that would help a lot; Thanks |
Hi again. We have implemented Arduino support and have pushed a preview branch here, see the port/platform/arduino directory for more information. This is for you to have a look at, maybe try out, see if it is what you are after. Note that it is (a) still subject to change (it has not been reviewed internally yet) and (b) this preview branch will be DELETED when the feature is merged into On the documentation, what would usually happen concerning hardware is that you would consult the u-blox integration manual for your chosen module and go from there. I will see if we can provide some form of "HW hints and tips" |
Hi Rob! Thank you so much for the great explanation. I was able to copy the files using your Python code in the Arduino Library folder and build the ubxlib src folder, then include and compile a sketch in Arduino IDE successfully, more details after my question. Now I want to write the sketch code there... My question:
There are two cell resources in ubxlib; My Updates; Things I need to do;
Thanks, |
That's great progress, thanks for looking at the preview branch. If you were able to include and compile/link the On the examples, the So, if you want to open a socket to a server, look at the sockets examples, if you want to use MQTT look at the mqtt_client examples, if you want to do location stuff look at the location examples, etc. These examples each include all of the You mention SMS above: is that a requirement? I imagine you aren't going to send a picture over SMS? If it is a requirement then we will need to add SMS support on cellular (not something anyone has asked us for yet). Not a huge issue, it is on the TODO list, just needs to be moved up. |
Aloha and Thanks, Rob, I will check the TCP example, that's what I want. Oh, I thought you mean installing esp-idf independently, I did that previously not sure if I deleted it... My goal is to send ESPCAM pictures using sockets, so I was thinking at SMS as a starting point that I know hardware works!, but thinking about it again... more relevant thing I see in Gpy or OpenMV codes as the first step is getting a website IP address using TCP (like Google!). So if you write a code that gets an IP address using TCP in Arduino using the ubxlib lib we have, that is great! Thanks, |
Sounds like you're having fun! For TCP sockets (assuming ignoring TLS security for now) this is the example you want. The entry point, I suppose the start of I've never used
...just re-using the
The thing to remember with the Looking forward to seeing a picture of your ESPCAM :-). |
Good morning Rob! Thanks for your patience, I know it's hard dealing with non-computer engineers, it took me a while as an electronics engineer to learn Python from Coursera (I knew C to some extent). Anyways, I tried copying the parts you mentioned in Arduino and call the functions, I got this error; exit status 1, 'networkHandle' was not declared in this scope Here are two examples I was talking about, tested in OpenMV which I found useful for wireless projects (fetching IP address of a website and photo upload); Ok, since you said you know IDF more, I will start with it to make sure the sarar4 hardware is working, then I will go back to Arduino for the photo upload project. I have the ESPCAM photo upload code in Arduino already. Ok I installed ESP-IDF again, and I went to configure these files (pins for ESPCAM); It looks like I should change most of them to -1 as they are not connected to sara r4, I am trying to mimic Sparkfun shield wiring, they just connect rx and tx, and I will just connect rx,tx,vcc,gnd from espcam to sparkfun. In Sparkfun SaraR4 shield, they mention they connect all uart handshake signals to ground as recommended for a UART "with NO FLOW CONTROL" mentioned at the lower part of page two of their schematic; https://cdn.sparkfun.com/assets/3/9/d/5/f/lte_cat_m1_shield_schematic.pdf Hopefully, when I am able to run Sarar4 with ESPCAM, I will definitely send its success picture, haha! Thanks, |
Understood, in that case I will see if I can write an Arduino example, making some assumptions about how the application should behave, which does the same send/receive to a TCP echo server as the sockets example. On the setting of pins etc., yes, you either edit the I won't close this issue until I've seen the picture :-). |
Hi again: I have pushed an updated version of the Arduino preview branch, called preview_feature_arduino_updated (the previous preview branch is still there, unchanged, in case you need to refer to it for some reason). Please delete any stuff that was created last time by running the Python script, read the revised README.md (some of the script names and certainly the script behaviours have changed). The most important thing about this update is that it includes an example sketch, an Arduino version of the sockets example. This branch has also passed testing on our test system and so is likely quite close to the version I will merge. When I have merged Arduino support into |
Hi Rob, it is awesome to test the socket example in Arduino, I deleted my previous libraries to try the preview version. However, I get the following error when trying to run u_arduino.py; I guess it is because in the code you have added; Source file listing fileSOURCE_FILES = "source" + UBXLIB_LIB_POSTFIX + ".txt" But there is no "source_lib.txt" file in your Arduino folder... |
Comparing to the previous Arduino preview folder; https://github.com/u-blox/ubxlib/tree/preview_feature_arduino/port/platform/arduino It looks like you probably forgot to add these files in the new Arduino preview folder; source_lib.txt and include_lib.txt, so I will just copy those from the previous preview and hopefully it will work! |
Sorry, my fault, I was testing with the automated test system which always specifies the names of those text files on the command-line to I have update the branch so that |
No problem my friend, |
We test |
Thanks. I get the following error compiling empty sketch example in Arduino IDE; Library ubxlib has been declared precompiled: |
That's strange: it looks like the version of the underlying ESP-IDF code is different in your case, their definition of |
idf4.2_py3.8_env but I can install a version that worked for you... |
All I did was follow Espressif's instructions; it compiled for you yesterday and none of that code has changed. Don't understand what's different. |
Oh, actually, I did not know I can remove the 16 clippers from the package! |
Oooo, weird: mine came in a little plastic bag, which is a tad more obvious! |
I think we need to zoom out a little here: there is nothing in the For instance, for the UART data lines, running at 115,200 and driven by the UART HW block (not SW), one bit is 8 us, one byte is 80 us (1 start bit, 8 data bits, 1 stop bit), so we need to be looking here at many 100's of ms to see what's going on in SW terms. Anything less than that is HW which I can't really be of much help with! |
Can you attach a probe to the TXD line as well as the RXD line (TXD from the MCU is what you will see before anything else), in the Saleae PC SW attach a serial analyzer to both of the data lines displaying both ASCII and hex (@115200), then do another trace with a timespan of 15 seconds (yes, I do mean seconds!) from power-on and post the fully zoomed-out view first? |
Aloha Rob, I have two 15 seconds traces; When everything is Off and I insert the Lipo battery to energize the MCU.
I use level shifter transistors in our design to shift 3.3 to 1.8V (same as Sparkfun level shifter you use; https://www.sparkfun.com/products/12009). Our Level_shifter Gates are energized with V_int:1.8V, I guess since I do not have 1.8V when measuring V_int signal with a multimeter, TX handshake from MCU can not be converted to 1.8V equivalent and reach TXD on SARA (level shifter transistors are OFF as their Gate is connected to V_int). |
Great, so those traces all look sensible: the Enable Power line is being brought up, the Can we now add two more probes: one connected to the 3V3 power supply pin of the module and another connected to the |
Thanks for interpreting the results, before adding more probes, with your explanation I might know what is wrong; Enable Power is not inverted here; At second 2: You say; the Enable Power line is being brought up; I think that is why you were suspicious of 3.3 V and want me to add probes there, I will do shortly. |
Ummm, could be, I'm not really a HW guy I'm afraid, you know best! |
Well |
Ok, I just rechecked the spelling, it is fine; arduino-cli compile --fqbn esp32:esp32:esp32 --clean -v -u -p COM3 --libraries . --build-property compiler.c.extra_flags="-DU_CELL_PWR_ON_PIN_INVERTED -DU_CELL_ENABLE_POWER_PIN_INVERTED -DU_CELL_RESET_PIN_INVERTED -DU_CFG_TEST_CELL_MODULE_TYPE=U_CELL_MODULE_TYPE_SARA_R410M_02B -DU_CFG_APP_PIN_CELL_ENABLE_POWER=19 -DU_CFG_APP_PIN_CELL_PWR_ON=0 -DU_CFG_APP_PIN_CELL_RESET=2 -DU_CFG_APP_PIN_CELL_TXD=1 -DU_CFG_APP_PIN_CELL_RXD=3" --build-property compiler.cpp.extra_flags="-DU_CELL_PWR_ON_PIN_INVERTED -DU_CELL_ENABLE_POWER_PIN_INVERTED -DU_CELL_RESET_PIN_INVERTED -DU_CFG_TEST_CELL_MODULE_TYPE=U_CELL_MODULE_TYPE_SARA_R410M_02B -DU_CFG_APP_PIN_CELL_ENABLE_POWER=19 -DU_CFG_APP_PIN_CELL_PWR_ON=0 -DU_CFG_APP_PIN_CELL_RESET=2 -DU_CFG_APP_PIN_CELL_TXD=1 -DU_CFG_APP_PIN_CELL_RXD=3" ubxlib\examples\sockets\sockets.ino I recompiled it from the Arduino command-line interface to the board, the same issue exists. I add the #define U_CELL_ENABLE_POWER_PIN_INVERTED to the header section in the sockets.ino code, it did not help. |
Delete the build directory is the usual way, then you can see that all the object files have gone. |
Yes, I was looking at them just now, also I am deleting the temp folder content now... |
In every example and every test, when the cellular instance is created, it prints out what the "on" state of the Enable Power pin is (you've quoted such text above), so you could re-check that. |
Not sure where can I check the print of cellular instance(uCellDeinit())? Normally I use Serial.print() and read the serial monitor. |
Not sure I understand: can you not just look at the debug serial port output of the ESP32 chip? It's just as you have already quoted above ("U_CELL: initialising with enable power pin 19 (0x13) (where 0 is on)..."). |
You are right, previously when I was uploading code to feather board using USB cable in the Arduino serial monitor I would see more data; #29 (comment) Currently, I only see ATATAT... using FTDI programmer connected to the board. I am not sure if FTDI caused it or I need to modify some parameters. I will search for the ESP32 chip debugging tools, looks like Arduino CLI has a debugging tool... |
Hi Rob, Platform IO has a great debugging environment, it supports Arduino and esp32, I was able to almost build ublox sockets example there, I get one error referring to u_cfg_os_platform_specific.h lines 97; 'CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT' undeclared (first use in this function) |
Are you sure you are connected to the correct COM port of the FTDI chip on the board? What you're showing there looks like the port that is connected to the cellular module rather than the trace UART. When you boot the ESP32 chip I would expect to see a splurge of its boot output, e.g.
Do you see that in your trace output? As to the Platform IO thingy, looks like they are using a different version of ESP-IDF, I have a feeling that ESP-IDF changed their #defines for things at some point. Looks like it's become For now you can just change |
OK: it might put a bit of a crimp in your development, not being able to see any debug output from the MCU on your actual target, but that's your choice of course. As to that initial pulse over on the left, I guess that's simply due to the default state of a pin 19 for ESP32. The first thing the code does when it initialises the cellular instance is to put all of the IO lines in the correct default statues. For the Enable Power pin, with the inversion in place, the code would set its default state to high, so that it can be set low to do the Enable Power part. So I assume all your seeing there is that the ESP32, at boot, has pin 19 low, then when the code starts running it sets pin 19 high as the requested default state (i.e. "off"). It's a transitory state. |
Thanks, Rob,
In contrast, when I upload the simple code to another SARA module(the cellular shield we designed for OPENMV), I have a stable 1.53V pulled up signal on PWR_ON and 2.7V on RESET_N pins. When the code applies a Low pulse for a valid duration on the PWR_ON pin, it causes the V_INT to go to 2.19 Volts but V_INT goes back to zero afterward. //#define CELL_ENABLE_POWER 19 const int CELL_ENABLE_POWER = LTE_ON_NOT; void setup() { void loop() { Btw, I see these serial prints as I don't have AT commands in this code! |
I'm not sure I'm really following this but I think you're saying that even with your simple code you can't get the module into a state where the Also, it is worth double-checking that your board can supply both the average and the peak current required by the SARA-R410: |
Hi Rob, I used a power supply with a 750 mA limitation(500 for SARA and 250mA for ESP32) and 4.2V instead of a battery port, but the board was not pulling up PWR_On when VCC was applied, and it was a soldering issue. We soldered 2 new boards, that pull the PWR_ON pins, one of which is using the SARAR422S module. With the new SARAR410M board, I can turn the module ON and OFF with my simple code. When the module is ON, I have V_INT and RESET_N pin pulled up internally to1.8V and 0.8V on PWR_ON. I loaded sockets.ino code; I get the following AT commands; AT The Module Response; The Simcard section has failed and I do not have Voltage on the VSIM pin. It looks like a few other developers had the same issue; https://portal.u-blox.com/s/question/0D52p00008nvKcnCAE/network-connectivity-issue-with-sara-r410m02b For SARA-R422M8S module with GPS antenna(a design similar to Figure 68: of international manual); It shows 1 Volta periodically on VSIM, I have loaded the sockets code on the GPS board, it just prints ATATAT in the serial monitor, and I get no response from the module, also in contrast to the SARA R410 module, the GNSS module I tested does not turn the VCC OFF. I will use Saleae probe to check the module signals. I have set # define U_CFG_APP_GNSS_UART 1 In PCB design, we have connected TXD-GNSS pin to ESP32 GPIO 22 so I modified the u-cfg app platform-specific file as follows; #ifndef U_CFG_APP_PIN_GNSS_TXD For the SARAR422S module, I found the following codes; |
Hi There,
Thank you so much for your codes for ESP32 MCU in ESP-IDF, I have lots of ESP camera boards and a Hologram Nova that has Sara-R410 and I want to connect ESP32 to it.
But the problem is all of my previous application codings are in Arduino IDE as most ESP32 codes are written in Arduino IDE!
So would you please modify your code so that we be able to use ubxlib library in Arduino IDE platform instead of IDF, like what Sparkfun people did?
Thank you so much!
The text was updated successfully, but these errors were encountered: