Shop OBEX P1 Docs P2 Docs Learn Events
ESP32 WiFi Interface and Propeller 2 - possible support and request for community input! — Parallax Forums

ESP32 WiFi Interface and Propeller 2 - possible support and request for community input!

Ken GraceyKen Gracey Posts: 7,392
edited 2020-07-30 20:08 in Propeller 2
Hello,

It seems that most Propeller 2 products, projects, and applications will include a connection to the internet in some way. Of the early product examples we've seen, each has included the ESP32 - just like we saw in yesterday's Propeller 2 Live Forum - Peter Jakacki Presents P2D2 presentation. Two other product design efforts I'm aware of also include an ESP32 (one in remote environmental sensing, another for machine control).

I imagine many of us have knowledge around both the ESP32 and the P2.

Parallax would like to offer a Spin2 object (and ESP32 firmware) for our customers which is easy to use, reliable, and fully (enough) featured. The internet already has so many examples with ESP32 - a quick look turned up this interesting site Random Nerd Tutorials and others. GitHub is loaded with examples as well from an active community of developers, often around the Arduino. The ESP32 module is a dual-core processor and it runs Arduino firmware, too.

How to proceed with creating a useful interface for the P2 is currently beyond my current level of understanding. @"Jeff Martin"
has far more knowledge on the subject and @JonnyMac has included this as an important addition to our list of needed objects.

Some of the thoughts I have about it:

Do we really only need a Spin2/PASM object if we can use the Arduino firmware and libraries? It seems that the Arduino ESP32 firmware does what would be commonly needed for the Propeller - except for the "more of it, faster" part to satisfy the P2's many I/Os and high baudrate capability. Could existing firmware be leveraged for our use, or is it already useful?

What uses would the P2 present that are already not provided for by other processors? Many examples I see are fairly simple and very useful: activate an alarm, send an e-mail, turn things on and off. These can be easily achieved with current examples and hardware.

What does the Propeller 2 community need in a ESP32 object? Parallax needs to sell P2 chips to applications that have some potential. If the needs are limited to detecting your dog with RFID and counting doggy-door clicks, this has already been solved. If you're making a product, what are your exact needs?

As mentioned above, we're willing to support an effort but we're not sure that it's actually needed or how we'd define the scope of work to be done. We'd like this to be easy for our customers to use and properly supported.

To move forward, perhaps it makes sense to schedule this topic as a Propeller 2 Live Forum - Early Adopter Series. Or, you can place your thoughts here. How do we move forward with IoT for the P2?

Thanks,

Ken Gracey

«1

Comments

  • I have taken the ESP8266 WX firmware and ported it to the ESP32 using only Espressif firmware and removed all third party code. 90% of the stuff works with remote code not functioning because of web server differences.

    Github: Parallax-ESP32

    Maybe a better mouse trap can be constructed since this firmware came along.

    Mike
  • My general thought on IoT and the ESP32 is the following:

    Many IoT projects are just going to be able to use a standalone ESP32 and Arduino code. It has a couple ADCs, it has a couple UARTs, and most stock modules expose ten or so pins.

    Where the P2 comes in, I think, is twofold. One case is "I really like working with the propeller and want to code everything in Spin, and want an easy wifi/bluetooth/TCPIP coprocessor". The other is "I am building something too big for an ESP32", such as home automation (way too many I/Os) or doing something more than a toy application for the audio processing or machine vision capabilities of the ESP32 (they really don't work if you put any other load on the micro).

    I think a big part of the attraction is that an ESP32 provides this functionality for less money than a lot of standalone radio modules.
  • jmgjmg Posts: 15,173
    Ken Gracey wrote: »
    It seems that most Propeller 2 products, projects, and applications will include a connection to the internet in some way. Of the early product examples we've seen, each has included the ESP32 ...

    To move forward, perhaps it makes sense to schedule this topic as a Propeller 2 Live Forum - Early Adopter Series. Or, you can place your thoughts here. How do we move forward with IoT for the P2?

    I think your primary focus here is WiFi links, rather than being locked to ESP32 per-se ? so it may be worth looking at what else is out there, for WiFi bluetooth

    The WIO terminal I've linked before, at just $29 it has an enclosure and a LCD display.

    https://www.seeedstudio.com/Wio-Terminal-p-4509.html
    https://files.seeedstudio.com/products/102110419/Basic documents/00014457-UM0401-RTL872xD-Datasheet-v1.7_205016.pdf
    https://files.seeedstudio.com/wiki/Wio-Terminal/res/Wio-Terminal-SCH-v1.2.pdf

    The RTL872xD Wifi/Bluetooth module is $3.90 1+ here
    https://www.seeedstudio.com/Realtek8720DN-2-4G-5G-Dual-Bands-Wireless-and-BLE5-0-Combo-Module-p-4442.html

    The Realtek WiFi/Bluetooth chip/module used here, looks to support 2.4GHz and 5GHz WiFi, and one data sheet says RTL872xD has 4MBytes PSRAM included, and there is also mention of HS-USB and i2s Audio codecs.




  • Ken,

    I think the gateway for success is in making the default be as simple as possible. For most users, there should be no need to access the ESP32's inner workings. The ESP32 should just be the WiFi (or Bluetooth) interface for the P2, just as the FTDI chips (or other simple USB interface options) are to USB.

    Of course, there could be access for more-experienced developers, with specific needs that require ESP32 firmware changes or alternate modes of use (sockets, UDP, etc...). Just make sure to keep those options more simple than what is currently available in the Arduino world. The experience of getting several different microcontroller types to communicate via WiFi (Arduino, ESP32, M5Stick, etc...) is an effort, with each having its own libraries and APIs.

    And, just make sure there are libraries available from the get-go!

    dgately
  • iseries wrote: »
    I have taken the ESP8266 WX firmware and ported it to the ESP32 using only Espressif firmware and removed all third party code. 90% of the stuff works with remote code not functioning because of web server differences.

    Github: Parallax-ESP32

    Maybe a better mouse trap can be constructed since this firmware came along.

    Mike

    Mike, I was looking for a better description of your port with the hope of finding an example. Can you describe what this port can/can't do with the P2 (or is the code for P1?)? I'm wondering if it could be the starting point for a complete ESP32 system, or if it may already be.

    Thanks,

    Ken Gracey
  • We need to ascertain the level of interest with the ESP32. We need to know if you would likely be using it in an application, along with the extent and type of use. I'm happy to put zero resources towards this project if there's a lack of interest.

    Ken Gracey
  • I am wiring up an ESP32 to my P2D2 just so I can test the connections for my new boards. Initially I just want to be able to test out WiFi serial and being able to reprogram the ESP32. The P2PAL boards also connects to a secondary ESP32 serial port as well as the 6-pin HSPI bus. Bluetooth HID is next. FTP will be very useful as well.
  • I am wiring up an ESP32 to my P2D2 just so I can test the connections for my new boards. Initially I just want to be able to test out WiFi serial and being able to reprogram the ESP32. The P2PAL boards also connects to a secondary ESP32 serial port as well as the 6-pin HSPI bus. Bluetooth HID is next. FTP will be very useful as well.

    Should you get a hankering for more in your copius free time, try the object shared by iseries above. I'm wondering if we could build upon this code.

    Ken Gracey
  • Cluso99Cluso99 Posts: 18,069
    For me, nice interest but am I likely to use it? Not for now.
  • The reason I haven't said anything about ESP32 and porting the code is that is does what the existing WX module does. Why bring in new hardware if there is hardware that already does the job.

    The only thing the ESP32 brings to the table is that it can do Bluetooth. Whether it's straight Bluetooth or the new BLE. With BLE it would be possible to advertise services that your project supports.

    I use the WX module to do code updates and to push data on my local network and to interface to internet services.

    Mike
  • Ken, it is definitely of great interest to me. I already use them connected to P1s (household power logger, acoustic chronograph, pool control system) and plan on moving all these to P2 with it's massively more powerful IO capabilities especially the smartpin ADCs. Having standardized excellent ESP32 interface code as vetted by Parallax and/or any of the other big hitters around here would be very helpful. I've been very painfully using that Arduino IDE for the ESP32 and the lack of comments and organization in that ESP32 codebase is appalling.
  • There are many different ways and possibilities how to connect esp32 to wifi and Bt. There are many examples and tutorials for esp32 available. It will be not possible, to make them all available for access for a P2 as master.
    So perhaps it is better, to see esp32 as master and use whatever wifi library is needed for the application.
    P2 can be used as subsystem with tachyon as already existing very powerful protocol over a serial line.
    For this kind of usage/connection, only a few examples are needed in the arduino environment of esp32.
  • ESP32 as master is an interesting proposition, though I don't agree with the rest of what you're saying. What in 5416 requires custom firmware? Nothing in BT and BLE does, the controls are literally in the RFC. Sadly the commands and responses are slightly nonstandard so you can't just use an HC05 object for it, but now that I look at it there might be code I can reuse from my HC05 object.
    pmrobert wrote: »
    Ken, it is definitely of great interest to me. I already use them connected to P1s (household power logger, acoustic chronograph, pool control system) and plan on moving all these to P2 with it's massively more powerful IO capabilities especially the smartpin ADCs. Having standardized excellent ESP32 interface code as vetted by Parallax and/or any of the other big hitters around here would be very helpful. I've been very painfully using that Arduino IDE for the ESP32 and the lack of comments and organization in that ESP32 codebase is appalling.

    I'm interested in hearing more. I share your experience with the codebase, though it's to be expected - a large, unconnected open source community is going to produce a lot of code that needs to get done quickly and work once.
  • Adding a esp32 to your project clearly make me ask: if I have a esp why use a P2?
    sure some projects require more adc, dac or io but there are some solutions for this on the market.

    To benefit P2 and to benefit education Projects we need a simple WiFi board for the p2 that needs no further thinking of. Just add the board. Rum some p2 code and you have ip Communication

    It you can deliver a zero maintain board I take it. If I have to program the esp forget it. Even loading the firmware one time is too much trouble.

  • Surac wrote: »
    Adding a esp32 to your project clearly make me ask: if I have a esp why use a P2?
    Should you have a need for very precise timing, the ESP32 is not a good fit. I've used the P1 for an engine ECU providing crankshaft wheel angular determination, fuel injection and very accurately timed ignition (spark) events. Different devices have different pros and cons - the ESP32 hardware seems to be extraordinarily well suited as a communication bridge for such things. The ESP32 is very, very cool in a quite different way from the P1 and P2 and may be a better fit for some applications. You ask an excellent question that has a lot of "it depends" as an answer.

  • iseries wrote: »
    The reason I haven't said anything about ESP32 and porting the code is that is does what the existing WX module does. Why bring in new hardware if there is hardware that already does the job.

    The only thing the ESP32 brings to the table is that it can do Bluetooth. Whether it's straight Bluetooth or the new BLE. With BLE it would be possible to advertise services that your project supports.

    I use the WX module to do code updates and to push data on my local network and to interface to internet services.

    Mike
    So you've ported the WX module firmware to the ESP32? I'd like to see that.
  • I don't understand what an ESP32 is. Can the details be ignored, and just used as an inexpensive serial to WiFi bridge?
  • whicker wrote: »
    I don't understand what an ESP32 is. Can the details be ignored, and just used as an inexpensive serial to WiFi bridge?


    The ESP32 is a board with a dual core micro that can clock up to 200MHz (though with only an internal clock) designed for inexpensive IoT (internet of things) devices. They're dirt cheap, and have built in WiFi and Bluetooth radios. They can be programmed in C with their own libs or in Arduino C (by down-compiling). They're an amusingly cheap way to add radio functionality to a project running on another micro such as a P2, without requiring as much processing load on the main micro.
  • ...and just used as an inexpensive serial to WiFi bridge?
    It can be, and that's the suggestion. The bridge program could also treat the ESP32 as an external IO co-processor.
  • jmgjmg Posts: 15,173
    edited 2020-08-03 00:46
    whicker wrote: »
    I don't understand what an ESP32 is. Can the details be ignored, and just used as an inexpensive serial to WiFi bridge?

    Yes and no.
    The ESP32 is a WiFi MCU, so it needs something loaded to make it 'look like' a useful bridge.

    I did find this
    https://subethasoftware.com/2018/02/28/wire-up-your-own-rs-232-wifi-modem-for-under-10-using-esp8266-and-zimodem-firmware/
    which covers the TXD.RXD and also expands into the other handshake lines too. ( DCD CTS RTS RI DTR DSR )

    This comment was interesting :
    "Serial Drivers
    Most of the low-cost ESP parts use serial hardware that is not recognized by a Mac or PC (not sure about Linux). If you plug up your ESP part to your computer and it is not recognized as a serial port (Like COM5: on windows, or /dev/cu.SLAB_USBtoUART on Mac), you will need drivers.
    Most sellers will provide links to where to find drivers. For the Amazon parts I purchased, they used the CP2012 chipset, and I had to download and install the drivers for it. Once installed, you can plug the ESP module up and it should show up as a new serial port device."


    So it looks like you can load Zimodem or equiv and a suitable compatible PC-side driver, and have things 'look like' you have a CP2102 - which is the same driver the EFM8UB3 uses on P2D2x

    I think they are saying once loaded, the WiFi block looks just like a serial port to the user.
  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2020-08-02 21:40
    One could offload things that the P2 isn't very good at to the ESP - such as handling encrypted network connections or cryptography in general (the ESP has all sorts of hardware-accelerated cryptography functions)
  • Wuerfel_21 wrote: »
    One could offload things that the P2 isn't very good at to the ESP - such as handling encrypted network connections or cryptography in general (the ESP has all sorts of hardware-accelerated cryptography functions)

    Yes, agree. It has amazing capabilities for a relatively inexpensive device.
  • Wuerfel_21 wrote: »
    One could offload things that the P2 isn't very good at to the ESP - such as handling encrypted network connections or cryptography in general (the ESP has all sorts of hardware-accelerated cryptography functions)

    That's my thought, yeah.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-03 03:42
    That serial driver thing about the ESP32 sounds strange but probably is specific and could simply be about the USB serial bridge that are on devkits, not the chip or module itself. All types of PC O/Ses handle the standard USB serial devices such as FT232 and CP21xx out of the box without requiring extra drivers. Reading the comment "For the Amazon parts I purchased, they used the CP2012 chipset, and I had to download and install the drivers for it." makes me wonder: what kind of O/S was this guy using that it didn't recognize a common CP2102???? I'd say more than likely he just downloaded it per outdated instructions when he could have just plugged it in.

    P..S I noticed that the comment said "CP2012" but that sounds like a mistake, just like it was a mistake to assume he had to download the drivers.

    Now, as for whether it is simple depends upon the hardware implementation. Take for example the tiny EFM8UB3 USB micro I designed into my P2D2 hardware, while there has been a lot of work in getting the USB serial software and support functions functioning correctly, for the user they either just use it as is with this software preloaded, or else they can download new firmware as a binary blob from the PC. So the details can be ignored, just treat it like any other preprogrammed black-box micro, and besides, the EFM8UB USB serial bridge appears as a common and known CP21xx device to the PC.

    On the P2PAL, an optional companion layer on the P2D2 board, I have an ESP32 designed in, The WiFi serial bridge firmware will be preloaded but the firmware can be updated OTA or via the P2 in a number of ways. One way to change the firmware from the PC would be via a script (python etc) that would load the P2 serially as one normally does but with an ESP32 loader program, and then send the ESP32 binary.

    As for the ESP32 replacing the P2, that is like saying let my little USB serial bridge replace it because it is good at this one USB thing. While the ESP32 has a lot of memory, it "only" has 2 cores :) The ESP32 has been designed specifically for this WiFi use and while it can run other software, including microPython and "flash leds", it can never come close to matching a P2 with its capabilities. I imagine that if the Espressif people were able to use the P2 as the CPU for the ESP32 40nm silicon!!!, what they would be able to achieve would be far far greater than what they have now, it would be the ESPP2 and the existing ESP32 would start to look like a crippled ESP8266 does now.

  • I am well aware that eps32 and p2 are completely different beasts.
    But don’t overlook the popularity of esp chips now. Some special things the p2
    Can give you are also possible with esp like some basic streamer over i2s.

    People have managed to output cvbs or vga over this streamer interface.

    If I can have wish granted I will wish for a transparent WiFi BT „thingy“ to attach to the
    P2. Include a spin object or a Pam file and get my communication handled.
    So no need to fire up some esp toolchain to make a P2 design work.
    I also wish to get some pc/Mac/Linux driver/api to do communication with p2 then
  • Interesting wifi possibilities of esp32 that I know of are:

    Get time and date from internet.
    Serial connection with putty terminal
    Behave like a NAS file server
    Write and Read from a Nas
    Mqtt
    Internet Server



  • Interesting wifi possibilities of esp32 that I know of are:
    ...

    Also can handle TLS and SSL encryption

  • @ Ken Gracey
    ESP32 WiFi Interface and Propeller 2 - possible support and request for community input!

    I use the ESP 32 for experminting and like the idea.
  • In addition to applications Christof Eb. already mentioned above, a socket based interface over SPI via ESP32 to the outside world from the P2 would be good too for higher performance. Basically behaving a bit like what those Wiznet devices do over Ethernet, but over Wifi instead and with the IP stack remaining within the ESP32 to not burden the P2. The standard serial port bridge function could still be used in parallel with this for extra debug/download capabilities too. There's a lot of possibilities opened up here with that extra SPI channel into the ESP32 from the P2.
  • Just a tease...

    Here's an M5JoyC (joystick: https://m5stack.com/products/joyc-w-o-m5stickc), talking over WiFi to an ESP32 Developer Module, that is in-turn, talking via serial to a P2ES. The M5JoyC is coded in Arduino as is the ESP32. The P2 just uses SmartSerial via flexgui (thanks ersmith!) to interface with the ESP32.

    The M5JoyC is just using the stock UDP-based code that it normally uses to talk to the M5StickC-based RoverC robot (https://m5stack.com/products/rovercw-o-m5stickc). No changes needed. The ESP32 board uses a modified version of the M5StickC Rover code that just sends the command data that it receives from the joystick to the P2 for display. At some point the P2 will use the command data to do something "useful"!

    In the image, the terminal on the left is displaying date from the ESP32. The P2 is displaying its input from the ESP32 in a CoolTerm terminal window.

    M5JoyC_ESP32_P2.jpg

    dgately
    3024 x 4032 - 2M
Sign In or Register to comment.