ESP-01 compatible Arduino library

Has anyone come across a library that works with these?

I could write one but no sense in re-inventing the wheel if one already exists.

WiFiEsp library doesn't seem to work with them....successfully initializes but then generates a 'shield not present' error.

What do you want to do with the ESP? Use AT commands? Program the ESP with the IDE?

ESP8266 beginners guide.

groundFungus:
What do you want to do with the ESP? Use AT commands? Program the ESP with the IDE?

ESP8266 beginners guide.

In this instance all I want to do with it is send and receive simple text as you would with a HC-05 module.
But it would be convenient if there was a library for it like WiFiEsp for the serial ESP8266 shields e.g. ESP13....should I decide to do more with it in another project.

You can use the ESP-01 module with the WiFiEsp library.

From the readme:

The WiFiEsp library has been designed to work with the ESP WiFi shield.

Then if you go to the link for the shield the library was specifically written for, lo and behold it shows the same ESP-01 module on it:

If you would provide your code and circuit then we might be able to help you get it working.

Been there and done all that. The ESP01 is working....just not with the WiFiEsp library.

I guess, short of writing a new library, I could get into the WiFiEsp library code, where the no shield error is generated, and hack my way past the error.

E.G. Add flag for ESP01 usage and disable that particular check.

Apart from the sufficient current issue, for some reason there is a limit to how rapidly you can send AT commands to ESP01.

It seems to be significantly lower than the regular ESP8266 shields.

So, to get WiFiEsp library to work with a ESP01 module you need to stick a delay(50) at the top of each of the versions of EspDrv::sendCmd...(...) functions

In file utility/EspDrv.cpp....example...

I just added another class data member '_SendCmdDelay' and set this to 50 /milliseconds/
Could probably make this delay specific to ESP01 via a flag in the constructor or something so that shields are not effected by this unnecessary delay.

/*
* Sends the AT command and stops if any of the TAGS is found.
* Extract the string enclosed in the passed tags and returns it in the outStr buffer.
* Returns true if the string is extracted, false if tags are not found of timed out.
*/
bool EspDrv::sendCmdGet(const __FlashStringHelper* cmd, const char* startTag, const char* endTag, char* outStr, int outStrLen)
{
    int idx;
 bool ret = false;

 delay(_SendCmdDelay);

 outStr[0] = 0;

 espEmptyBuf();

 LOGDEBUG(F("----------------------------------------------"));
 LOGDEBUG1(F(">>"), cmd);

 // send AT command to ESP
 espSerial->println(cmd);

 // read result until the startTag is found
 idx = readUntil(_Timeout, startTag);

 if(idx==NUMESPTAGS)
 {
 // clean the buffer to get a clean string
 ringBuf.init();

 // start tag found, search the endTag
 idx = readUntil(500, endTag);

 if(idx==NUMESPTAGS)
 {
 // end tag found
 // copy result to output buffer avoiding overflow
 ringBuf.getStrN(outStr, strlen(endTag), outStrLen-1);

 // read the remaining part of the response
 readUntil(2000);

 ret = true;
 }
 else
 {
 LOGWARN(F("End tag not found"));
 }
 }
 else if(idx>=0 and idx<NUMESPTAGS)
 {
 // the command has returned but no start tag is found
 LOGDEBUG1(F("No start tag found:"), idx);
 }
 else
 {
 // the command has returned but no tag is found
 LOGWARN(F("No tag found"));
 }

 LOGDEBUG1(F("---------------------------------------------- >"), outStr);
 LOGDEBUG();

 return ret;
}

EspDrv.cpp (24.1 KB)

WiFiEsp.h (6.53 KB)

WiFiEsp.cpp (4.7 KB)

EspDrv.h (8.68 KB)

Delay is needed after each byte sent. Im not using libraries but very reliable way i found is to put 1-5ms delay after each byte is sent to serial. Without delays its working but not reliable sometimes you got what you want sometimes esp is missing.

Made small function which just rips string appart and start adding 1ms delay after each char sent.

surepic:
Delay is needed after each byte sent. Im not using libraries but very reliable way i found is to put 1-5ms delay after each byte is sent to serial. Without delays its working but not reliable sometimes you got what you want sometimes esp is missing.

Made small function which just rips string appart and start adding 1ms delay after each char sent.

Have not needed any delays with HC-05, ESP8266 12E and ESP8266 13.

With this ESP01 module, this is the first time I have encountered the problem.