Share My Creation Garage Door Opener (with source code)

Hi all:

*** ADDED Project with B4XPages working on B4A and B4J. See post #15

Not sure if this is the rigth place, or if I should publish it in Examples, @Erel, feel free to move.
The code is not perfect, but it works.
Most of code is copied/pasted/modified from forums, so this app is made by the forum people.

Attached a B4A and a B4R app. You will need an ESP8266 and a remote.
The ESP8266 sends a FCM message to the B4A app when someone rings the bell.
From the B4A app, you can send a mqtt message to the ESP to close the contacts of a remote to open a garage door.
You can send the mqtt message from the app or from a widget.

The schema is something like this. I open two garage doors and a pedestrian door, so it can be simplified with just a remote.
*** WARNING ***
I get the ring bell signal from a 220v doorbell, so I use a 220v relay. You don't have to do this if you don't know what you're doing, it's dangerous.
You can avoid the relay and get the doorbell signal input from an open/close contact, or even omit this part if you just want to open the door instead.
*******************

Schema:
schema.jpg


So you need to open your remote, and try to close the button contacts. If your door opens, it will work
1579182805422.png


Feel free to improve it and share!!

Some things you could add:
- Loggin and log in a database when someone open the door
- Check the GPS position before opening with the widget, to avoid open the door when you are far away by mistake
- You can see the images from your webcam with a webview
- Send a picture taken when someone press the doorbell with the FCM notification.
It would be great using this project from @miker2069 instead of ESP8266 to get the picture an open the door.

Installed:

1579189365880.png
installed.jpg


 

Attachments

  • B4ARemoteGarageDoor.zip
    95.3 KB · Views: 979
  • B4RRemoteGarageDoor.zip
    5.9 KB · Views: 774
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
The problem I had with FCM is in B4A side, I do not know if it is possible compile an application without add APY_KEY as static in compilation, so everyone can register and use it at runtime.

I've managed to register topics at runtime, but in the code the API_KEY is static, so if the app is personal no problem, but if it should distribuite, here is the problem.
This is not fully clear to me, even if I wrote an ESP FCM library that require me about 6 months to develop..... I will study your B4A code to see if it is different.

Ah, note that I wrote this same library for ESP in C++, for B4A and for B4J, started a port for B4R but I had problems, so paused it.

This allow to send 'speaking' (or not) FCM notifications from PC, Android, Raspberry etc. Note even that for B4J I wrote it as UI and NONUI libraries, the last do not have dependencies from JavaFX and works even in command line from terminal, just a line to send a notification to exactly a specified device.
 
Last edited:

josejad

Expert
Licensed User
Longtime User
I do not know if it is possible compile an application without add APY_KEY as static in compilation, so everyone can register and use it at runtime.
I'm not sure to understand. I think you're refering to the google-services.json you must save in the project folder.

The API_KEY is for an app (or group of apps), and you subscribe to a topic or several topics. Not every user needs his own API_KEY, just the app developer need it.

Please start a new thread if you have some problem or question about "Integrating Firebase Services" or "FirebaseNotificacions - Push"

Thanks¡
 

max123

Well-Known Member
Licensed User
Longtime User
Yes sorry, you are right, the problem is not API_KEY, I'm confused here.

The problem is the google-services.json that need to be downloaded and app should be compiled after that....

I'm in this situation, I want distribuite an Android app that remotely control 3D printers, actually it works over USB-OTG cable and here no need notifications....

When use it to connect remotely the app send a gcode file (3d printer file to work with) and SMTP account properties (that user set in the app), like smtp server, smtp server port etc.... to a server side connected to a 3D printer over USB.
The server side receive these infos and save it to send emails notification, eg. when the printing process start, when when are problems, when print finis... and so....

Using emails work well, but sometime the message will arrive with delay..... and email not is a good way to do this.

For this motivation I want substitute it with FCM notification, the problem is that I cannot recompile an app for any user with a different google-services.json.

My app that control remotely should receive notifications from Server side (Raspberry or ESP32) that register to a topic and so can send back a notification.
 

josejad

Expert
Licensed User
Longtime User
Please, as this is not related with my app, start a new thread with an apropiate subject to discuss it and get help from more people.
You don't need to recompile your app with differents google-services.json, you just use YOUR google-services.json. After that, every user can subscribe to a different topic to just get their own notifications.
Anyway, maybe you can do all that things just with MQTT, but please, open a new thread.
 

max123

Well-Known Member
Licensed User
Longtime User
Ok thanks I will do it.
 
Top