Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP8266-01 Question.

Status
Not open for further replies.

Robo_Pi

New Member
I would like to send and receive text between my laptop computer and an Arduino board. I don't want to need to go through the Internet or a 'cloud' in order to achieve this connection. I just want the text to be sent between the laptop and the Arudino board using an ESP8266 WiFi module. It's ok if I need to use a router, I just don't want to need to be connected to the Internet in order to make this connection.

My question: Is this possible?


I can write programs on the Laptop using either C# or Python. But what I can't find is any tutorials or information on how to do this. All the tutorials I find seem to be using things like Blynk for Android phones that also use the Internet and a cloud. Is there a way to by-pass the Internet? Can anyone point to any articles that address using the ESP8266 Wifi Module directly from a PC using C#, Python, or any other computer language.

Thanks.
 
You can setup the 8266 to be an access point and connect that way. Once connected the simplest way to communicate is to run a server on the 8266 and use post and get to communicate via a browser.

Mike.
 
I have just picked up a couple of these and started playing around with them myself, definitely still an Uber-Noob, so I will watch this thread with interest.
It would appear that they are practically un-brickable, because I haven't managed to do so yet.
Aside from using the arduino IDE, there are some other useful tools out there:
ESPlorer:
https://www.esp8266.com/viewtopic.php?f=22&t=882
Espressive firmware flasher:
https://www.espressif.com/en/support/download/other-tools?keys=&field_type_tid[]=14
ESP Easy:
https://www.letscontrolit.com/wiki/index.php/Tutorial_ESPEasy_Firmware_Upload
SDK's:
https://www.espressif.com/en/support/download/sdks-demos

Regards.
 
HI Robo-pi, I've done a lot of work with the ESp8266, you're in for a good ride but it can be frustrating at the same time!

There are loads of example and open source projects out there doing this kind of thing. Most of my work has been done using esp-open-sdk, and native C development, but I'd suggest sticking to the Arduino environment to start with, it has better support.

Why dont you try this: https://github.com/G6EJD/ESP8266-WebServer-Getting-Client-Data

I started with this project if you'd rather go straight C - it'll give you all the necessary building blocks https://github.com/Spritetm/esphttpd
 
Thanks Cicero,

I'll definitely look into trying the Arduino project. It looks complicated. Is the Arduino emulating a webserver and webpage here? Also I'm not sure what's going on. What I ultimately want to do is communicate between a laptop computer and an Arduino board via WiFi.

I've been thinking about this and if I can get two Arduino boards communicating with each other via WiFi, then I'm home free, because I can easily then get my laptop to communicate directly to one of the Arduino boards via a hardwired serial com.

My ultimate goal is to use this to control a robot wireless. I'm starting to think that this WiFi module might actually be overkill and more complicated than I need. Perhaps I should just try using a standard radio communication like the NRF24L01 because I really don't need to have any actual communication with a router or network. All I'm really looking for is wireless communication locally.

 
Oh yeah! UDP is much better for my purposes. All I want to do is send a few bytes back and forth. I don't need anything more than that.

The only reason I'm using the WiFi is for the wireless capability. I'm just controlling a local robot, and I would prefer that it really has no connection or dependency on the Internet at all. If I can get it down to where my laptop is talking directly to the robot without even using a router that would even be better yet.

I'm just going to be sending very small commands back and forth. I only need to send a few bytes at a time. The robot has its own programming onboard and knows what to do. So all it needs are basic simple commands to tell it what to do, then it can deal with all the details of carrying out that task internally on its own. If it's in the lab and I want it to go to the kitchen all I need to do is send over a couple bytes telling it to go to the kitchen. It can then figure out how to get to the kitchen on its own.

I just need to be able to tell it very simple commands. No major communication required.
 
Ok, I'm having some super elementary problems here. I'm just starting out with these ESP8266 boards, and so I haven't even been able to get anything happening. Not even a serial connection with the Arduino monitor. I also tried using Putty but nothing happening there either.

Let's me explain some things I've tried.

To begin with I have the module wired up as per this article: Getting Started with the ESP8266

Although they say to use a 1k and a 2.2k resistor. But they don't say which is which? So I used a 1k resistor in both places.

I'm also using a buck voltage regulator set to 3.3 volts. And a FDTI USB serial module set to 3.3vots. I have them both grounded to a common ground.

I'm starting with a very simple ASCIITable example sketch. I've loaded this sketch on an Arduino Uno and it runs as expected.

However, when I try to load this sketch on the ESP8266 things don't go well.

To begin with after uploading the program I get an error msg saying that there was a problem uploading the code. I'm uploading at 9600 baud. I tried uploading at 115200 but that fails instantly. At 9600 baud it at least appears to upload. It goes all the way to the end and then reports that there was an error uploading.

Then when I open the serial monitor on the Arduino IDE I do get a very small set of garbage characters. (that's progress since I was getting nothing before). It appears to be sending about 25 or 50 characters. Then it pauses, and sends another 25 or so. Also if I hit the reset button that also causes it to send this same shot of garbage characters. So it's trying to do something. And the reset function appears to be working to some degree.

I'm wondering if I need to change some settings?

I'm basically set up with the default settings for a generic ESP8266 board:

Flash Mode QIO
Flash Size 512k (no SPIFFS)
Debug Port (disabled)
Debug Level (none)
lwIP variant "V2 lower memory"
reset method "clk"
Crystal Freq 26Mhz
Flash Freq 40 Mhz
CPU Freq 80 Mhz
Builtin LED 2
Upload speed 9600 (was originally set to 115200 but that won't work at all)
Erase Flash "Only Sketch"
Port COM4 (I'm sure that much is correct) It actually does download the program
Get Board Info returns:

BN: Unknown board
VID: 0403
PID: 6001
SN: Upload any sketch to obtain it

But it doesn't seem to take a sketch upload cleanly.

I have two of these boards and I've tried both of them. They both seem to be acting in the same way.

Obviously I'm not going to be doing any UDP when I can't even get a simple example program to run on these.
 
Don't know what board you're using but I use a Wemos mini and that just connects via usb and works. I pay less than US$5 each for the boards.

The serial output sounds like a debug dump that you get when the WDT resets the chip.

Mike.
Edit, Example can be found here.
 
Never mind, I got it working!

I had to go back and download an older version of the ESP8266 board tools for the Arduino IDE. Instead of using the latest version I'm using 2.4.0-rc1 and that works. I probably have some older ESP8266 chips. But it seems to be working now. So now I can look into the UDP set up.
 
Before you can look at UDP you need to establish a connection. This can be either through a router or by using the esp as an access point as in the link above.

Mike.
 
Before you can look at UDP you need to establish a connection. This can be either through a router or by using the esp as an access point as in the link above.

Mike.

I'm an absolute raw beginner with these ESP8266 modules so I really have no clue what I'm doing. I wasn't able to ever get the AT commands to work or give me an "ok" prompt, or anything like that. Apparently a lot of my problems had to do with the Arduino ESP8266 board manager. Now that I installed an earlier version things seem to be working. I found this suggestion to install an earlier version on the web and it seems to have worked.

So now do I need to reinstall some original programming again to get the AT commands? Right now all it does is keep printing out the ASCIITable. It's nice to see that working, but I'm guessing that this isn't going to work for any WiFi communication.

I'm going to go back now and try uploading that UDP example code. From here: UDP - ESP8266

See how that goes.
 
WOW! It's WORKING!

I uploaded the UDP sketch to the ESP8266, pressed the reset button and on my serial monitor I got the following message:

Connecting to Robo_SID ..... connected
Now listening at IP 192.168.1.15, UDP port 4210

Robo_SID is the name of the network I use for my robots.

I also looked on my WiFi connections on my laptop and the ESP module shows up as an Access Point.

Finally, I looked at my Robo_SID router using my web browser and sure enough the ESP module shows up as being connected there too.

I can't believe it was that simple!

Of course I haven't actually exchanged any data yet, but I imagine that will all work now that I have it up and running.

I'll use that PacketSender that Cicero pointed to. But I'm not going to do that until tomorrow. It's bedtime for me tonight.

Then from there I'll see about trying to talk to it using either Python or C#.

This is going to be GREAT! I'm so glad I didn't give up. I've been at this for over a week (and almost threw in the towel). And apparently the bulk of my problems was with the Arduino board software. I just needed to install an earlier version and now everything seems to be working. Hallelujah!
 
Ok, I had to install the PacketSender and just see it work before I went to bed. It's works! Bingo! I've got communication! Now I can sleep well.

Thanks Cicero, that UDP sketch made things really easy, short and sweet. I love it!
 
Woohoo congrats, its a super little module, but can be highly frustrating!

There are a few gotchas or good-to-knows with ESP's:
  • Very dependent on having a good and solid 3V3 supply with caps as close as possible. Breadboarding can often cause more problems than expected because of this.
  • That garbage you're seeing when it resets, you can see legible text if you set the baud rate of your terminal to 76800 (its actually a bit less but you can listen at that speed and I remember it easily as 38400*2). It provides some startup info, and will give you an indication as to why it resets.
 
It seems to be working rock solid now that I have updated the Arduino board software to an older version. That's was the problem all along evidently.

It could be that they are moving beyond these little -01 modules. But I really like these tiny boards. As long as they work I'll continue to use them.

Now my next challenge is to hook this ESP board up to the Arduino Mega on the robot. That interface will need to be hard-wired serial. I suspect that I'll need to do some voltage leveling on the Rx and Tx connections. I'm also thinking that I'll want the ESP8266 to trigger an interrupt on the Arduino Mega when it gets an incoming message. I don't want the Arduino to need to be monitoring the ESP constantly, so using an interrupt when a message comes in will probably be the best way to go.

I think I can figure all this stuff out over time. I can also use that PacketSender program in the beginning to send messages to the robot and make sure the Arduino board is getting the messages and sending back a reply. I can do that easily in the beginning by just having the Arduino board monitoring the serial connection to the ESP continually. Then once I get that working I'll look into changing it over to having the ESP tap the Arudino on the shoulder with an interrupt when a communication comes in.

Once I get that all squared away, then I can move on to replacing the PacketSender program with my own Python or C# program. I typically use C# because that has the full Windows Forms GUI interface.

But yeah, this is way better than where I was with it last week!

Arduino ESP board software! <--- That was the problem. Can't use the latest version with these ESP8266-01 boards evidently. Got to revert back to an earlier version.
 
Nice sounds good.

One of my projects interfaces the ESP with an STM32 via serial. I made the STM the master, and the ESP a slave, otherwise it gets messy with bidirectional comms, handshaking etc. It might be worth thinking about that kind of hierarchy for your system. That way the time critical work the Mega does can be done in its own time, then perhaps use a status query command to see where the ESP is, if it has comms waiting for you, or any other status updates. The mega can then pull that data when it wishes to without compromising the control functions and other deterministic work it needs to do.
 
I just bought a bunch of STM32 boards. I'm only just learning about them. I'll probably end up replacing the Arduino boards with the STM32 boards if only because of their smaller size. They are also a lot cheaper. And faster. I think they have more memory too, but I'm not sure about that.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top