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

Hello guys, I would like to share my project which measures, Temperature, Humidity and Distance using the DHT11 and ultrasonic sensor HC-SR04.

DHT11-HC-SR04-ESP8266.txt (1.5 KB)

CayenneESP8266Shield.log (1.1 KB)
Ultrasonic-master.log (6.7 KB)
DHT-sensor-library-master.log (14.0 KB)
ESP8266HardwareSerial.log (23.0 KB)
Adafruit_Sensor-master.log (6.7 KB)

Code attached as txt file, and libraries are in .log files, please rename the .log into .zip files… if you need help please let me know.

Please remember to remove the TX and RX wires of ESP module from Arduino while upload the code or you will get errors.

IMPORTANT: I have used the Arduino 3.3 power supply for the ESP8266 and the 5V for the sensors just for test purposes, please consider using and external power supply and avoid any damage to your Arduino power supply as the current is very low.

5 Likes

Thanks for submitting this @cassio.lucass!

Are you monitoring something specific? We have a home automation contest going on right now that you should enter this in :slight_smile: cash prizes!

-B

I let this running inside my house… I am waiting for new sensors parts arrive from China, like door magnetic sensor, gas leakage sensor, microphone sensor… I am afraid they will not arrive in time to include the final version of the project into this automation contest, but, I really would like to participate using what I have now in hands… I live in Brazil, how can I submit my projects into this automation contest? Being among the 100 first projects would be already very nice…

When your new sensors arrive I think your project will be very good! I have just submitted your project to the contest by entering it into the right category.

Do you think you can take some pictures of your sensors and also can you show how you’ve used the Cayenne triggers and alerts feature?

-B

Do you have an Arduino you can add to your project too?

-B

Yes I have used the following list of materials:

  • 1 Arduino UNO R3;
  • 1 Ultrasonic HC-SR04 Sensor;
  • 1 DHT 11 Humidity and temperature sensor;
  • 1 ESP8266 Wifi Module.

I will add an LDR for luminosity level as well.

I will take some pictures and show how everything is connected, about Cayenne triggers and alerts I have an example, next week I will travel to Europe and I will adjust this Ultrasonic sensor on the main door of my apartament, if the distance is below the limit I set, should receive an SMS or e-mail, like and alarm, so I know if the door was opened… this project can also be powered up usind a 9V battery in case you don’t have an electrical plug near the door.

1 Like

Hello, please check below pictures of the project:


1 Like

@cassio.lucass I downloaded the files, and changed it to .zip files. But when I try to open it seems to be unkwon or damaged. I think I am doing this wrong, how do you change the extension?
I am using windows 10, and arduino IDE version 1.6.13 , is it a problem ?

Hello Barbara, you just need to rename the .log into .zip files and then you can extract them normally…

@cassio.lucass Thanks for answer, that finally worked.
The problema now is that cayenne is not connecting with my esp8266. What I got in the serial monitor of arduino is:

AT+CIPMODE?
AT+CIPMUX=0
AT+CWJAP=“MySSID”," Logon"
AT+CIPSTART=0,“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE
AT+CIPSTART=0,“TCP”,“arduino.mydevices.com”,8442
AT+CIPCLOSE

After that, nothing happens. Do you know what is wrong?

Did you copy the code and downloaded it to you arduino? When you did compile did you get any error messages? You dont need to open the serial monitor in this case, just make sure to have your Network ID, Password and Cayenne Auth code.

How is the ESP8266 LED state? RED led means it is powered up and blue LED should blink randomly that means you have communication with you wifi.

Yes, I copied, and I did not get any error after compile.
The ESP stays for a little bit with the blue led blinking, but after a few seconds it stops.

Check on your local Wifi router if ESP Module was recognized and received an IP Address.

Ok, I’ll try that.
I’ll give a feedback as soon as possible.
Thanks.

Barbara, did it work?

Hi @cassio.lucass, it didn’t work.
I checked if the esp was receiving a IP, I did it by send AT commands through the arduino IDE, and it seems to work.
Doing that, I got a IP address. I also could visualize the ESP as a availabe network in my computer. However it doesn’t connect to anything, looks like the ESP doesn’t got the internet access. Seems to be a problem with my router, how can I solve this?

@cassio.lucass Did you chose the the conection to Cayenne the Arduino UNO wifi shield?

Hello Barbara,

Are you using the Arduino UNO and connected exactly like the drawing on the top this post? Yes I am using the WiFi Shield on Cayenne connection. If you have everything connected like me, you should have problems to download the program to Arduino without disconnecting the RX and TX between arduino and ESP module, so disconnect just to download.

Yes, I’m using UNO and I connected exactly like the post.
I also have this issue with the RX and TX, but I had already desconnected.
The problem is after that. Cayenne does not connect to my board. I don’t know if I heve to do something else with the ESP before download the code to the Arduino.

When you said: Check on your local Wifi router if ESP Module was recognized and received an IP Address.
What exactly was I supposed to do?
I think the problem can be with my router, because the ESP is not getting Internet access.
The ESP has been set as a hotspot, but I am not able to access Internet through it.