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


#1

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.


The Judges Have Spoken! ~CONTEST RESULTS~
#2

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


#3

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…


#4

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


#5

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

-B


#6

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.


#7

Hello, please check below pictures of the project:



#8

@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 ?


#9

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


#10

@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?


#11

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.


#12

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.


#13

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


#14

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


#15

Barbara, did it work?


#16

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?


#17

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


#18

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.


#19

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.


#20

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.