Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


View this topic in a long page with up to 500 replies per page Create new topic
1 | 2 | 3 | 4
davidcole
6011 posts

Uber Geek

Trusted

  #1987254 2-Apr-2018 18:42
Send private message

And when you post the open command if you have the it plugged in via serial monitor do you see it respond to the mqtt command?




Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


 
 
 

Shop now on AliExpress (affiliate link).
jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #1987288 2-Apr-2018 20:02
Send private message

Don’t hear a click. I have both the topics open in terminal windows checking the reed switch and the relay - the posts appear fine from both - physically triggering the reed switch and manually posting to the correct topic.

Maybe I just need to order a few more relays??

Jon

jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #1987290 2-Apr-2018 20:07
Send private message

Thanks @davidcole - hadn’t thought to connect it and monitor the serial port I was vaguely wondering about logs etc but it has been running over WiFi. Will try and report back...

Jon



hebegb
77 posts

Master Geek

Trusted

  #1998781 18-Apr-2018 17:09
Send private message

I have also been on the hunt for a way to use Alexa and my smartphone to open my garage.

 

I found this and are waiting for it to arrive.

 

https://aurahome.wixsite.com/aura/product-page/garage-door-opener-circuit-board

 

 

 

This place appears to be different from the Australian company https://www.aurahome.com/ as it is shipped out china and only has 2 products

 

This device was US$29.95 and states it can do this in-conjunction with the eWeLink app and IFFT

 

I shall have a play anyway.

 

My question however, is I have just got a new Dominator Garage door opener (Motor). The old opener had 2 simple terminals on the exterior to connect a wired switch to (momentary contact). On the new opener these are buried on the circuit board. I have found a reference to the terminal block connections in the manual, but they are very vague as to how to connect it. I suppose they want you to buy their $300 Smartphone/hub product.

 

Terminal Block.
24V PWR is used to power devices such as:
- PE (Input) for photo electric beam for safety and Auto-Close function.
- LGT (Input) allow hard wired external trigger for the opener’s courtesy light.
- O/S/C INPUT is used for the connection of a wired switch (momentary contact). This switch
can then be used to open, stop or close the door. Install the wall switch in a location where
the switch is out of reach of children and the garage door is visible.

 

So am I switching 24v on to the O/S/C terminals to trigger this? HELL NO!

 

Worked it out. 0V and OSC are the trigger terminals. FYI for anyone with a Dominator GDO9 Enduro opener

 

Terminals

 

V+| SB1| 0V |SB2| 0V| OSC |AUX

 

                             X     X

 

SORTED

 

 

 

Thanks in advance





They see me rollin, they hatin!

scottr
262 posts

Ultimate Geek

Trusted

  #1998965 18-Apr-2018 20:43
Send private message

jonherries:
snowfly:

I've done this using a wemos d1 mini, relay shield, and reed door sensor. All up probably less than $20, with a little plastic case, and usb power cable.


Wemos d1 mini programmed directly via arduino ide, few lines of code.
Relay is normally open, connected to the same terminals on garage opener that our hard wired switch is connected.
To open or close door, just pulse the relay for 1 second (just like simulating pressing the hard wired button), to close circuit for 1 second.


Reed switch tells me if door is open or closed.


You can find similar approach here: https://automatedhome.party/2017/01/06/wifi-garage-door-controller-using-a-wemos-d1-mini/


And a similar geekzone post here: https://www.geekzone.co.nz/forums.asp?forumid=141&topicid=198633


 



So, had a go at this approach myself and having trouble with triggering the relay (sensor works). Have tested that closing the pins on the door triggers the motor. Have then tried manually posting to the mqtt topic. Have yet to solder the relay shield but reluctant to if it is faulty. Is there a simple way to trigger or test the relay itself - guessing adding some sort of voltage on the expected pin? If so how much?

Jon


Hey, the script file on that site doesn't work - I found the same thing a few weeks back when trying it myself. relay works when shorting it, but wouldn't click when reading the topic which i'd proven to work.

Try the below, it’s the original script with fixes to make it work



#include //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include //Local DNS Server used for redirecting all requests to the configuration portal
#include //Local WebServer used to serve the configuration portal
#include //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include //MQTT
#include
#include

////**********START CUSTOM PARAMS******************//

//Define parameters for the http firmware update
const char* host = "GarageESP";
const char* update_path = "/WebFirmwareUpgrade";
const char* update_username = "admin";
const char* update_password = "YourPassWordHere";

//Define the pins
//#define RELAY_PIN 5
//#define DOOR_PIN 4
const int relayPin = D1;
const int doorPin = D2;

//Define MQTT Params. If you don't need to
#define mqtt_server "MQTT Broker IP Address"
#define door_topic "garage/door"
#define button_topic "garage/button"
const char* mqtt_user = "mqtt_user";
const char* mqtt_pass = "mqtt_pass";

//************END CUSTOM PARAMS********************//
//This can be used to output the date the code was compiled
const char compile_date[] = __DATE__ " " __TIME__;

//Setup the web server for http OTA updates.
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;

WiFiClient espClient;

//Initialize MQTT
PubSubClient client(espClient);

//Setup Variables
String switch1;
String strTopic;
String strPayload;
char* door_state = "UNDEFINED";
char* last_state = "";

//Wifi Manager will try to connect to the saved AP. If that fails, it will start up as an AP
//which you can connect to and setup the wifi
WiFiManager wifiManager;
long lastMsg = 0;

void setup() {
//Set Relay(output) and Door(input) pins
pinMode(relayPin, OUTPUT);
//pinMode(relayPin, LOW);
pinMode(doorPin, INPUT);

Serial.begin(115200);

//Set the wifi config portal to only show for 3 minutes, then continue.
wifiManager.setConfigPortalTimeout(180);
wifiManager.autoConnect(host);

//sets up the mqtt server, and sets callback() as the function that gets called
//when a subscribed topic has data
client.setServer(mqtt_server, 1883);
client.setCallback(callback); //callback is the function that gets called for a topic sub

//setup http firmware update page.
MDNS.begin(host);
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
httpServer.begin();
MDNS.addService("http", "tcp", 80);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your browser and login with username '%s' and your password\n", host, update_path, update_username);
}

void loop() {
//If MQTT client can't connect to broker, then reconnect
if (!client.connected()) {
reconnect();
}
checkDoorState();
client.loop(); //the mqtt function that processes MQTT messages
httpServer.handleClient(); //handles requests for the firmware update page
}

void callback(char* topic, byte* payload, unsigned int length) {
//if the 'garage/button' topic has a payload "OPEN", then 'click' the relay
payload[length] = '\0';
strTopic = String((char*)topic);
if (strTopic == button_topic)
{
switch1 = String((char*)payload);
if (switch1 == "OPEN")
{
//'click' the relay
Serial.println("ON");
digitalWrite(relayPin, HIGH);
delay(600);
digitalWrite(relayPin, LOW);
}
}
}

void checkDoorState() {
//Checks if the door state has changed, and MQTT pub the change
last_state = door_state; //get previous state of door
if (digitalRead(doorPin) == 0) // get new state of door
door_state = "OPENED";
else if (digitalRead(doorPin) == 1)
door_state = "CLOSED";

if (last_state != door_state) { // if the state has changed then publish the change
client.publish(door_topic, door_state);
Serial.println(door_state);
}
//pub every minute, regardless of a change. - UPDATED TO 3 seconds
long now = millis();
if (now - lastMsg > 3000) {
lastMsg = now;
client.publish(door_topic, door_state);
}
}

void reconnect() {
//Reconnect to Wifi and to MQTT. If Wifi is already connected, then autoconnect doesn't do anything.
wifiManager.autoConnect(host);
Serial.print("Attempting MQTT connection...");
if (client.connect(host, mqtt_user, mqtt_pass)) {
Serial.println("connected");
client.subscribe("garage/#");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}

andrewNZ
2487 posts

Uber Geek
Inactive user


  #1999004 18-Apr-2018 22:53
Send private message

@jonherries have you ever triggered the relay using any code?

The Wemos IO addressing is a little unintuitive in Arduino.

Start at the start.
Can you switch the relay.
Can you see the message arriving using serial (buffers often contain junk if you don't clear them before using them) open != openæ&*#∆~

jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #2001813 24-Apr-2018 17:33
Send private message

Follow up - have the serial monitor connected, and publishing to the MQTT topic using the following command:

 

mosquitto_pub -m "Open" -t garage/button

 

It shows up on the topic, but can't see it appear on the serial port...

 

So not even getting as far as the Serial Monitor...

 

 

 

Jon




davidcole
6011 posts

Uber Geek

Trusted

  #2001857 24-Apr-2018 18:13
Send private message

Does it get into the callback at all? You have no logging in there to tell.

Also your code is looking for “OPEN” and your message payload for mqtt is “Open”




Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


andrewNZ
2487 posts

Uber Geek
Inactive user


  #2001864 24-Apr-2018 18:38
Send private message

Add this to the beginning of the callback function. It will send the topic and payload to the serial monitor.

Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();


jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #2001868 24-Apr-2018 18:53
Send private message

davidcole: Does it get into the callback at all? You have no logging in there to tell.

Also your code is looking for “OPEN” and your message payload for mqtt is “Open”

 

 

 

That change to upper case worked. Still isn't catching the relay though... Wonder if it is because I am using a Wemos Mini Pro?

 

Jon


andrewNZ
2487 posts

Uber Geek
Inactive user


  #2001870 24-Apr-2018 19:08
Send private message

Open the blink example sketch, change all 3 instances of LED_BUILTIN to 5, upload it.
If the relay doesn't toggle there is a wiring problem/oversight.

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(5, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #2001877 24-Apr-2018 19:32
Send private message

andrewNZ: Open the blink example sketch, change all 3 instances of LED_BUILTIN to 5, upload it.
If the relay doesn't toggle there is a wiring problem/oversight.

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(5, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

 

 

 

Had another wemos so took the relay put both together on a separate breadboard, compiled this sketch and plugged it in - didn't trigger the relay either. Have now ordered four more relays from Aliexpress...

 

Jon


andrewNZ
2487 posts

Uber Geek
Inactive user


  #2001878 24-Apr-2018 19:38
Send private message

Have you tried connecting the relay directly to 3.3v and Gnd to see if it switches?

jonherries
1385 posts

Uber Geek

Trusted
Subscriber

  #2001880 24-Apr-2018 19:45
Send private message

andrewNZ: Have you tried connecting the relay directly to 3.3v and Gnd to see if it switches?

 

No, will try that in the morning - presumably it should be 5V rather than 3.3V though?

 

https://www.aliexpress.com/item/Relay-Shield-for-WeMos-D1-mini-button/32596395175.html?spm=a2g0s.9042311.0.0.gMPwCO

 

This is the relay - it is the one linked from the Wemos site so should work - is stacked per my image from the previous page.

 

Jon


andrewNZ
2487 posts

Uber Geek
Inactive user


  #2001887 24-Apr-2018 19:51
Send private message

The Wemos inputs and outputs are 3.3v. There appears to be a transistor to switch the 5v supply to the relay.

1 | 2 | 3 | 4
View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Logitech Introduces New G522 Gaming Headset
Posted 21-May-2025 19:01


LG Announces New Ultragear OLED Range for 2025
Posted 20-May-2025 16:35


Sandisk Raises the Bar With WD_BLACK SN8100 NVME SSD
Posted 20-May-2025 16:29


Sony Introduces the Next Evolution of Noise Cancelling with the WH-1000XM6
Posted 20-May-2025 16:22


Samsung Reveals Its 2025 Line-up of Home Appliances and AV Solutions
Posted 20-May-2025 16:11


Hisense NZ Unveils Local 2025 ULED Range
Posted 20-May-2025 16:00


Synology Launches BeeStation Plus
Posted 20-May-2025 15:55


New Suunto Run Available in Australia and New Zealand
Posted 13-May-2025 21:00


Cricut Maker 4 Review
Posted 12-May-2025 15:18


Dynabook Launches Ultra-Light Portégé Z40L-N Copilot+PC with Self-Replaceable Battery
Posted 8-May-2025 14:08


Shopify Sidekick Gets a Major Reasoning Upgrade, Plus Free Image Generation
Posted 8-May-2025 14:03


Microsoft Introduces New Surface Copilot+ PCs
Posted 8-May-2025 13:56


D-Link A/NZ launches DWR-933M 4G+ LTE Cat6 Wi-Fi 6 Mobile Hotspot
Posted 8-May-2025 13:49


Synology Expands DiskStation Lineup with DS1825+ and DS1525+
Posted 8-May-2025 13:44


JBL Releases Next Generation Flip 7 and Charge 6
Posted 8-May-2025 13:41









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.







Backblaze unlimited backup