wokwi-features icon indicating copy to clipboard operation
wokwi-features copied to clipboard

ESP-01 WiFi modem (AT command)

Open MykolaKyrylenko opened this issue 4 years ago • 44 comments
trafficstars

Would it be possible to add the equivalent of an ESP-01 component for integrating to an Arduino Uno or Mega project at a WiFi modem. Some ideas:

  • 4-pin interface
  • USART interface (Rx and Tx only)
  • 5V supply + Ground
  • AT commands, which match the Espressif command set (https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html). A subset to enable a WiFi link and data transmission will be a great start.
  • TCP/IP traffic sent via browser (not sure if this is possible)

Thanks.

MykolaKyrylenko avatar Aug 30 '21 00:08 MykolaKyrylenko

Thanks for the suggestion @MykolaKyrylenko !

Would an ESP32 simulation also fit for your use case? Or do you need at ESP-01 specifically?

urish avatar Aug 31 '21 09:08 urish

Thanks for the response. I am flexible with the implementation, so an ESP32 will be good. Are you intending an AT command interface?

MykolaKyrylenko avatar Aug 31 '21 12:08 MykolaKyrylenko

Are you intending an AT command interface?

Not at the moment. But if you run your code directly on the simulated ESP32, you should be able to use the WiFi functions directly. Does this not fit your needs?

urish avatar Sep 01 '21 21:09 urish

I lecture at a technical college, and we are using the Atmel processor on the Arduino Mega to teach low level C programming, e.g. DDR, PORTC, etc. registers. The ESP32 will be too complicated for our students. We are trying to incorporate IoT thinking, and I believe the simplest way it to have a "WiFi modem", with AT commands and a serial interface. I would prefer not to change processors / boards part way through the topic.

NOTE: in industry I had to integrate a cellular modem to a microcontroller, and that worked well.

MykolaKyrylenko avatar Sep 01 '21 23:09 MykolaKyrylenko

Got it. Yeah, ESP32 is indeed pretty complex.

There might be a way, at some point, to run both the AVR and ESP32 simulators in different tabs and have them communicate over virtual UART, which may be helpful.

How long until you get to teaching the WiFi modem part?

urish avatar Sep 11 '21 23:09 urish

Thanks for that. Either solution will be great. We are teaching the WiFi modem part in about 4 weeks, so I do not expect this feature this semester. But we teach this topic each semester, so it will be great for the future.

PS I noticed another enhancement request, was using WebSockets. Can something be done with that work?

MykolaKyrylenko avatar Sep 12 '21 23:09 MykolaKyrylenko

I had an interim solution, if that is of interest.

Would it be possible to have a 'serial' device which just sends a HTTP POST request? e.g. https://randomnerdtutorials.com/cloud-weather-station-esp32-esp8266/ [same hardware interface as my original post]

MykolaKyrylenko avatar Sep 15 '21 08:09 MykolaKyrylenko

PS to my previous comment. Sort of like the CURL command (https://curl.se/) to generate HTTP requests.

MykolaKyrylenko avatar Sep 16 '21 04:09 MykolaKyrylenko

Sorry - I forgot to reply to your suggestions :)

There's a way to achieve what you suggested with the features that we already have, though it's not very straightforward (and also undocumented):

  1. Use the Chrome browser
  2. Use wokwi-serial-port together with a virtual com port driver (see here for details)
  3. Write some script that will read the requests from a serial port (e.g. a curl command), perform them, and write the result back to the serial port. You could probably do with with python + PySerial.

I'm pretty positive that we'll have something usable for the next semester. You can track the roadmap in the public features page.

How's the semester going so far?

urish avatar Oct 05 '21 20:10 urish

Thanks for the message. Some of our students are remote, so doing your suggestion will confuse them. For this purpose, I am getting them to use real hardware. It will be great to have something by next semester.

Overall, the students are loving Wokwi. I needed to adapt bits due to known limitations, e.g. resistor divider network cannot be created for A/D conversion, so I used the potentiometer slider instead. A full integration of Wokwi and Falstad will be gold. Great work.

MykolaKyrylenko avatar Oct 08 '21 02:10 MykolaKyrylenko

Thanks for the feedback!

I opened a new issue (#203) for the resistor divider network, it's now also open for vote. Let's see how much love it gets!

urish avatar Oct 09 '21 18:10 urish

This one is getting many votes recently, making its way to the top of the list. We may start working on it soon if it keeps coming up the list!

urish avatar Mar 27 '22 22:03 urish

Some updates: I'm looking into using the official ESP-AT Firmware on ESP32-C3 to provide this functionality. Anyone interested in beta testing?

urish avatar Apr 24 '22 21:04 urish

I would be interested. Do you think the ESP32-C3 can be included with an Arduino on the same project?

MykolaKyrylenko avatar Apr 24 '22 23:04 MykolaKyrylenko

Thanks! In general, it is not possible to run two MCUs at once (at least until we tackle #186).

For the AT modem specifically, I'm working to make it possible. I'll share the details about the beta testing here in a few days.

urish avatar Apr 25 '22 08:04 urish

So, here's something working - you can interact with the modem directly through the virtual serial monitor:

https://wokwi.com/projects/330317327704785492

The performance is pretty bad, and I haven't tried to connect it with an Uno yet (but in theory, that should also work). The only way to connect it is through diagram.json, as there's no UI element yet.

The WiFi works similar to how it does in the ESP32 - same access point configuration, uses the same gateway settings, etc.

urish avatar Apr 30 '22 07:04 urish

WoW ...

I tested it here, by the messages I saw that it is simulating very real... Are you using real hardware on the server side??

image

ricardojlrufino avatar Apr 30 '22 12:04 ricardojlrufino

Thanks @ricardojlrufino! Behind the scenes, we're simulating the ESP-AT firmware using the same simulation engine that powers the ESP32 simulation. So it's not real hardware, but your questions shows that we are probably doing pretty good job with the simulation :-)

urish avatar Apr 30 '22 12:04 urish

yes ... failures are often good signs that things are working... =]

ricardojlrufino avatar Apr 30 '22 13:04 ricardojlrufino

Some more updates: the performance is now somewhat better (the simulation runs at 100% speed on my PC), and also fixed some issues with the UART output (wrong baud rate, missing chars when there's a lot of output, etc.).

So it should already be usable now. It will probably take some time until I get to create the board graphics, though.

urish avatar Apr 30 '22 18:04 urish

Excellent work. I had similar results to Ricardo. Very fast performance.

I am assuming IP addresses are not being fed at the moment? image

MykolaKyrylenko avatar Apr 30 '22 21:04 MykolaKyrylenko

Thanks! This was a bug - can you please try again now?

urish avatar Apr 30 '22 22:04 urish

Excellent: image AT+CWMODE=1 had instant resppnse AT+CWLAP responded in a few seconds AT+CWJAP repsonded with 'WIFI CONNECTED' instantly, and then after about several more seconds completed the response

MykolaKyrylenko avatar May 01 '22 11:05 MykolaKyrylenko

Hooray :)

If anyone gets a chance to test this with the Uno (or other Arduino board), I'd love to learn how it works

urish avatar May 01 '22 19:05 urish

I tried it with the Mega using Serial 1. The code is very crude, but commands get sent and responses are received. Works well. Responses appear on Serial Monitor. See here: https://wokwi.com/projects/330589181982016082

MykolaKyrylenko avatar May 03 '22 00:05 MykolaKyrylenko

Cool! I see you also tried to get an HTTP request working, any luck with that yet?

urish avatar May 03 '22 15:05 urish

I managed to get a POST request received on our server: image

The AT+HTTPCLIENT came back with an error: image

MykolaKyrylenko avatar May 03 '22 22:05 MykolaKyrylenko

Interesting, so it sent the POST request, but then said "ERROR" without telling anything else.

Do you have a physical ESP chip to try it and see if you get a different result?

urish avatar May 04 '22 07:05 urish

I have a physical ESP-01, and will try to get it going.

Some more information: I sent a single POST request and 11 messages appeared on the server, with a 1 second gap between them. image Could be a timeout issue?

CURL command did as expected, with only 1 record sent: image

MykolaKyrylenko avatar May 04 '22 09:05 MykolaKyrylenko

Downloading a PCAP packet capture could be helpful to understanding what's going on

urish avatar May 04 '22 19:05 urish