So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By MegaTux
#83799 Hi,

I'm trying to build a simple doorbell but I'm not finding something close enough to what I need on the internet. The closest I got to this on this forum is this: viewtopic.php?f=160&t=17672&p=76165&hilit=doorbell#p76165

I'm considering two options, depending of which is simpler.

OPTION A:
1) Client Device is a esp8266 with a push button hanging on the door that when pressed
a) makes a LED go on (to signal to the guest that the message has been received);
b) sends a http post to a linux apache server that will log the event in a mysql database (i.e. so I can consult when the button was pressed after I return home from a holiday);
c) sends a http post to a linux apache server to play a mp3 on the server;
d) and finally sends a http post to a linux apache server to send an email to a couple of accounts. or SMS

2) Server Device is the linux apache server with mysql.


OPTION B
1) Client Device is a esp8266 with a push button hanging on the door that when pressed
a) makes a LED go on (to signal to the guest that the message has been received);
b) sends a http post to a linux apache server that will log the event in a mysql database (i.e. so I can consult when the button was pressed after I return home from a holiday);
c) and finally sends a http post to a linux apache server to send an email to a couple of accounts or SMS.

2) Server Device is the linux apache server with mysql.

3) Third Device that is a portable speaker with an esp8266 that plays a mp3 when it receives the signal and blinks a LED for a fixed time, say 20 secs;

I would probably want to go for Option A as its the simplest to start with but I'm not sure I know where to start. Questions are:

a) Has anyone come across projects that implement similar functionalities, even if only some of them (I do not want to post anything on external IoT servers, nothing must leave my LAN other than the emails/SMS)

b) Would be using one of the digital pins on the ESP to hook the button up to that would be shorted with GND pin?

c) WIth OPTION A, I suspect I would get apache to play a mp3 when it gets the message from the doorbell and send the emails? Anyone know where I can get some php code to o this?

Thanks in advance for tips/helps
User avatar
By Bonzo
#83803 As you say option A is the simplest way to get started amd I would go with the Arduino IDE as there are a lot more tutorials for that.

There are plenty of tutorials around about how to get an LED to illuminate with a button push - it does not have to be for a door bell. Which esp8266 device are you intending on using?
I would get that to work first as that should be the hardware part done.

Again there are examples on how to send a string to a php page and it is easier to use a http URL than a https one. You just need to combine the two codes.

Do you know anything about php? You will need to do the email, database save an mp3 in one go.
User avatar
By picstart1
#83804 How you power the esp8266 is something to consider. If it is via batteries then the esp8266 is power hungry and will chew up batteries within a week unless power management like deep sleep is employed.
It too has issues about how you plan to wake the esp8266 up.
User avatar
By MegaTux
#83924 The ESP unit I intend to use is the HUZZAH Feather. I already have a unit acting as temperature unit doing deep sleep and waking up every 15 minutes to send temperature to server.

I suspect that the button press would wake the ESP up, cause it to run through the code and then go back to sleep. Of course, this is part I need to work on :)

I've got a 1300mAh battery on it and it lasts a good month without problems. Once a month, I plug a 20,000 mA usb bank into it, give it a 2 hr charge and it runs for another month. Pretty happy with this setup for now. The door bell option should last a lot longer as it would only be waking up once or twice a day rather than every 15 minutes.

I actually got a Pi3 running with OpenHAB and MQTT over the weekend. I've been testing it with MQTTfx to see if I can publish/subscribe to MQTT and it seems to be working. I may end up using this instead of the Apache option. It seems like a more sensible approach. Once I figure out how to set up the rules/actions.

I guess the logic of the code would be:

a) if button is CLOSE, then wake up
b) connect to wifi
c) blink LED for 10-15 seconds
d) publish "home/Ground Floor/Door Bell" to MQTT
e) go back to deep sleep but does it need to go back to deep sleep?

Why not ON when button pressed, goes through cycle and then turns itself off? This would make the battery run forever.

What do you think? This post seem to be relevant viewtopic.php?t=10987
This also seems to be quite relevant https://blog.hobbytronics.pk/esp-deep-s ... ut-wakeup/

I guess I have some work/reading to do this weekend but any thoughts would be appreciated.

Thanks