My question: I don't know how to connect ULTRASONIC SENSOR(hc-sr04) which is for getting the fill level of garbage and DHT11 for temperature and humidity to connect both in a ESP8266 to mobile application that I am developing.

I should provide three devices,that are located far from each other with breadboard and battery with case holder. Will be connected through wifi, and send notification to the mobile app to maintenance person.

  • Yes it is possible. You need to do some research and identify a solution. If your chosen solution does not work let us know what went wrong and we may be able to help.
    – joan
    Sep 24, 2018 at 14:16
  • @joan, what step should I follow? I'm in struggle about ESP8266 in connecting it with both DHT11 and Ultrasonic sensor with breadboard,battery with case holder and get specific data and send to mobile application Sep 25, 2018 at 8:03
  • This appears to be an Arduino question with no relation to Raspberry Pi. Sep 27, 2018 at 13:08
  • @DmitryGrigoryev recently it was Sep 29, 2018 at 6:04

1 Answer 1


There are many solutions to this project. Also, while the DHT11 sensor is well defined, simply saying "Ultrasonic sensor" is not. So only the DHT11 and Raspberry Pi will be included in this answer.

One approach would be to use an ESP8266 WiFi based board to interface with the DHT11 and transmit data over WIFI to the Raspberry Pi. Here is one of many project published on the internet where this is done.

If you are going to run the ESP8266 boards on batteries, it would be best to study the deep sleep capabilities of the ESP8266. This github.com repository contains some code examples.

Finally, you might consider MQTT as a way to transfer data from the ESP8266 devices to the Rraspberry Pi. Here is one of many examples on the internet regarding MQTT between an ESP8266 and a Raspberry Pi.

  • Ironically, one of the easier ways to program an ESP8266 is to use the Arduino (the stack exchange site you were migrated from) IDE.
    – st2000
    Sep 24, 2018 at 13:19
  • thank you so much sir!, I'm confused on dht11 and dht22. This two are different to each other? Sep 24, 2018 at 13:40
  • sir my project was about garbage monitoring system using mobile application, I need to connect 3 separated devices in the campus (with dht11 and ultrasonic sensor with battery and breadboard for each trash) then as you told me connect it with 1 esp8266 through internet and send the data in my mobile application. This will work? Sep 24, 2018 at 13:50
  • The DHT11 sensor itself has no ability to send anything wireless. It must be connected to something like ESP8266. So, if there are 3 seperate DHT's you would need to connect it either: 3 DHT11 to one ESP8266 with wires, or each DHT11 to one ESP (it mean you would need 3 x DHT11 AND 3 x ESP8266 AND 3 x battery AND 3 x ultrasonic sensor)
    – smajli
    Sep 24, 2018 at 15:07
  • hi @smajili wow thanks :) do I need breadboard for each? and do I still need a raspberry then? Sep 24, 2018 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.