Using DHT11 + HC-SR04 Ultrasonic sensor and ESP8266 as Wifi


No you dont need to do anything with the ESP, just download the code and look the LED states of the ESP module, if the blue LED flashes means that is trying to connect with your local wifi network, with this configuration I was not able to check the ESP configuration usind the serial monitor of arduino IDE, thats why I had to check my router statistics to make sure the ESP had successfully connected to my router and received an IP address… Once I know the IP of the ESP module I was able to ping it.


I understood @cassio.lucass.
I did the same as you said, checking my router and in fact my ESP is not connecting to my router.
Do you what can I do?


It seems to me that your in AP mode as you mentioned you can see it listed on your computer as a hotspot. Is this a esp8266 shield? Are there dip switches?


Yes, maybe, I dont see a reason that it wont work, if everything is exactly
like I did you should get it working… can you send pictures of your ESP
module, how it is connected to your arduino… ?


The devices I am using are:

I took of the sensors because I am trying to first get conexion with Cayenne.

The ESP and Arduino are conected in this way:

The others pins if ESP are desconnected.

Without the sensors the code became:

//#define CAYENNE_DEBUG // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
//#include CayenneESP8266Shield.h

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “*";
// Your network name and password.
char ssid[] = "
char password = “******”;

// Set ESP8266 Serial object
#define EspSerial Serial
ESP8266 wifi(EspSerial);

void setup()
Cayenne.begin(token, wifi, ssid, password);

void loop()



Hi Barbara, I will test it here and will let you know the results.




Barbara, your code didnt work here, please find below a working code for you and also the library which you need to copy to Cayenne folder (rename the .log file into .h)

Codigo.txt (586 Bytes)

CayenneESP8266Shield.log (1.1 KB)

For your information, if you want to use my complete code from the beginning of this post it will also request the Adafruit_Sensor.h file, just google it and download from Gift-hub.


Maybe there was a problem during upload of the CayenneESP8266Shield.log file on the previous post, I have uploaded again, please try.


Hello Cassio,
Sorry for bother you.
I really need to make the project work, It’s for College.
I don’t understand why it does not work. Did you make some change on you
router to get the ESP connected?
I am able to connect the arduino on Cayenne trough the USB conection, but
using the wifi shield that does not work.


Hello Barbara I really don’t know,I didn’t need to make any more change to
make it work… Didn’t need any adjustment on the router.


I see.
Which ESP firmware you used?


Cassio, you are a Brazilian, right?
May I have your contact so we can talk in Portuguese?


Is your esp firmware flashed for AT commands? Open serial monitor and try entering AT command and see if you get a response.


No I can’t read anything on serial monitor, I don’t know if is because of
firmware or the way it is electrically connected.


Do you see garbage characters or nothing at all?


Garbage. But I didn’t worry about it as it connected and worked normally.


That usually just means you have the wrong baudrate set for the serial monitor. Set it to whatever you have specified or just go down through one at a time and one of them will give you characters that actually mean something.


Yes, my esp firmware is flashed for AT commands. I get “OK” when I type AT on the serial monitor.
I’m thinking that the problem can be with my firmware version. Do you know if those libraries work fine with any version?
The other problem I can think is with the electral power, because I am using the usb port of my computer. Does it make any sense?


Understood. Thanks for the information I didn’t spend time on it because it
was working…