Controlling two buttons in house trough 4G on phone (First project)

Hello guys!

I'm currently working on my first project and need some advice on my thoughts. I'm trying to create a system that can push two seperate buttons in my house trough my smartphone with an app. Now I am entirely new at this but I'm an IT student for many years and have a lot of knowledge about multiple IT related stuff and have a basic understanding in programming. I'm using two nodeMCU esp8266 CH340 and intend to use a relay which i still need to receive.

I currently got both nodeMCU's configured in such a way that they connect to my wifi network. I can connect to the nodeMCU's trough a browser on my phone which is connected to the same network. Here I programmed a button that can be pressed which lights up a LED I connected for one second. The LED functions as the relay for the moment. Now my next goal is to allow the NodeMCU's to be accessed trough a browser anywhere with a mobile network connection. I already found some tutorials about the subject so that should be fine.

Now I was thinking about using an app. I want to be able to use an app connected to both nodeMCU's trough mobile network. The app would have three buttons. The first for one nodeMCU button press, the second for the other nodeMCU button press and the third for both NodeMCU buttons pressed.

Now I was thinking, what is the right way to achieve my goal?

I currently able to press the button to light up the LED on both NODEMCU's but this requires me to connect to two different ip adresses separately in order to press both buttons. I'm unable to create an app (well maybe with a lot of work but let's say i'm unable). Is there maybe a way to use an app that allows buttons to be configured. Maybe in a way that when a button is pressed it navigates to one or more buttonclick url's in the background. Is this a feasible solution?

What would be the correct steps and/or structure for this? And what about security? The buttons should notbe allowed to be accessed by anyone but me and relatives. All help is greatly appreciated!

Thanks,
Sjoerd

You say you have your NodeMCUs connecting to your WiFi network and you say that your phone can send a message to the NodeMCU.

But you have not told us how you have achieved that - is there a server? where is it running?

If the server is running on the NodeMCU then I presume a few different phones can connect to it as clients.

I don't understand why there are two NodeMCUs ? How do they each relate to the project?

You say you are familiar with IT stuff. If you were implementing this on a PC, how would you do it? It won't be much different using NodeMCUs.

Do you have the option of using a cheap laptop or a RaspberryPi to run the server. To my mind that would make the whole thing much easier to develop because there are ready-made web-framework programs that do almost all of the donkey work and leave you to concentrate on the pretty things.

...R

Robin2:
You say you have your NodeMCUs connecting to your WiFi network and you say that your phone can send a message to the NodeMCU.

But you have not told us how you have achieved that - is there a server? where is it running?

If the server is running on the NodeMCU then I presume a few different phones can connect to it as clients.

I don't understand why there are two NodeMCUs ? How do they each relate to the project?

You say you are familiar with IT stuff. If you were implementing this on a PC, how would you do it? It won't be much different using NodeMCUs.

Do you have the option of using a cheap laptop or a RaspberryPi to run the server. To my mind that would make the whole thing much easier to develop because there are ready-made web-framework programs that do almost all of the donkey work and leave you to concentrate on the pretty things.

...R

Thanks for your response. I will clarify. I am familiar with IT but not with home automation and related subjects for this project. My field of study is more business and process related. I am a fast learner though. The current state of the project is just experimenting and watching tutorials.

There is a server running on the nodeMCU yes. Every phone that is connected to the wifi network can connect to the nodeMCU trough a browser by inputting the ip adress as url. There are two NodeMCU's because there are two physical buttons in my house that I want to make smart. These buttons are located more than 25 meters from each other. I believed two nodeMCU's together with two relays would be sufficient to do what I want and allow me to experiment/create parts of the project myself.

Sjoerd1234:
There is a server running on the nodeMCU yes. Every phone that is connected to the wifi network can connect to the nodeMCU trough a browser by inputting the ip adress as url. There are two NodeMCU's because there are two physical buttons in my house that I want to make smart. These buttons are located more than 25 meters from each other. I believed two nodeMCU's together with two relays would be sufficient to do what I want and allow me to experiment/create parts of the project myself.

Although you have not said so my guess is that both NodeMCUs are running separate servers so your phone needs to choose which one to connect to and you would prefer a single interface.

If that is correct then why not use one NodeMCU as the server and program the second NodeMCU as a client. The client can call the server to see if one of the phones has left a message for it?

...R

You say you are not able to build an App ? really it is not that hard to make what you want.. do you know any Java ? Creating an app that has 3 buttons 1 that sends 1 URL, one that sends another and one that sends both. It would take some time but i could help you out a bit. i am currently working on an App that controls WS2812 strip via WiFi, so i a actually have some or most of the parts you need. Robin's plan is also quite feasible and a lot less work.

i haven't tried this tutorial yet (lack of time) but that is what you want also isn't it ?
for security try the arduinoOTA library i think it's great simple to use and flexible for multi-users if you want it to be.

Robin2:
Although you have not said so my guess is that both NodeMCUs are running separate servers so your phone needs to choose which one to connect to and you would prefer a single interface.

If that is correct then why not use one NodeMCU as the server and program the second NodeMCU as a client. The client can call the server to see if one of the phones has left a message for it?

...R

thanks for your advice i will look into that tomorrow!

Deva_Rishi:
You say you are not able to build an App ? really it is not that hard to make what you want.. do you know any Java ? Creating an app that has 3 buttons 1 that sends 1 URL, one that sends another and one that sends both. It would take some time but i could help you out a bit. i am currently working on an App that controls WS2812 strip via WiFi, so i a actually have some or most of the parts you need. Robin's plan is also quite feasible and a lot less work.
https://www.instructables.com/id/Control-ESP8266-Over-the-Internet-from-Anywhere/
i haven't tried this tutorial yet (lack of time) but that is what you want also isn't it ?
for security try the arduinoOTA library i think it's great simple to use and flexible for multi-users if you want it to be.

I'm not familiar with Java. I am with Python though. Creating an app like that would be awesome but I don't know where to begin. My current plan is to be able to connect to the nodeMCU trough the internet, thanks for the link! Any advice on the app? Creating one would be awesome and quite an achievement for myself, otherwise using an existing app will suffice

Well started on my App not even a year ago by reading a general Java for dummies and an Android App development book. Using Android Studio and getting my head around the ESP part of the thing. I had no experience with HTML and a huge gap in my knowledge about the internet and networks (this all happened while i was paying guitar in the streets) Anyway what you are trying to do is not very complex. If the IP-addresses are static you know where they are, sending a URL (which is what you do when you press a button on an HTML based page) is easy. (once you got the Java method sorted) and sending 2 URL's is just as easy...

Hi,
Look at this page... blynk

Tom... :slight_smile:

TomGeorge:
Hi,
Look at this page... blynk

12 blynk Projects - Arduino Project Hub

Tom... :slight_smile:

Blynk looks really promising thanks! I see blynk uses a authentication token, will that be enough for security?