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
4452 posts

Uber Geek
+1 received by user: 685

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

OpenHAB: Gigabyte AMD A8 BrixOpenHAB with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Xiaomi Humidity and Temperature sensors and Bluetooth LE Sensors
Media:Chromecast v2, ATV4, Roku3, HDHomeRun Dual
Windows 10
Host (Plex Server/Crashplan): 2x2TB, 2x3TB, 1x4TB using DriveBender, Samsung 850 evo 512 GB SSD, Hyper-V Server with 1xW10, 1xW2k8, 2xUbuntu 16.04 LTS, Crashplan, NextPVR channel for Plex,NextPVR Metadata Agent and Scanner for Plex


1073 posts

Uber Geek
+1 received by user: 88

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

 
 
 
 


1073 posts

Uber Geek
+1 received by user: 88

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

69 posts

Master Geek
+1 received by user: 4

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!

245 posts

Master Geek
+1 received by user: 4

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);
}
}

2119 posts

Uber Geek
+1 received by user: 1200


  # 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æ&*#∆~




Location: Dunedin

 


1073 posts

Uber Geek
+1 received by user: 88

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


 
 
 
 


4452 posts

Uber Geek
+1 received by user: 685

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

OpenHAB: Gigabyte AMD A8 BrixOpenHAB with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Xiaomi Humidity and Temperature sensors and Bluetooth LE Sensors
Media:Chromecast v2, ATV4, Roku3, HDHomeRun Dual
Windows 10
Host (Plex Server/Crashplan): 2x2TB, 2x3TB, 1x4TB using DriveBender, Samsung 850 evo 512 GB SSD, Hyper-V Server with 1xW10, 1xW2k8, 2xUbuntu 16.04 LTS, Crashplan, NextPVR channel for Plex,NextPVR Metadata Agent and Scanner for Plex


2119 posts

Uber Geek
+1 received by user: 1200


  # 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();





Location: Dunedin

 


1073 posts

Uber Geek
+1 received by user: 88

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


2119 posts

Uber Geek
+1 received by user: 1200


  # 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
}




Location: Dunedin

 


1073 posts

Uber Geek
+1 received by user: 88

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


2119 posts

Uber Geek
+1 received by user: 1200


  # 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?




Location: Dunedin

 


1073 posts

Uber Geek
+1 received by user: 88

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


2119 posts

Uber Geek
+1 received by user: 1200


  # 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.




Location: Dunedin

 


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



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Huawei's scholarship programme showcases international business to Kiwi undergrads
Posted 22-Jul-2019 17:53


Spark Sport launches across a range of new devices
Posted 22-Jul-2019 13:19


Dunedin selects Telensa to deliver smart street lighting for 15,000 LEDs
Posted 18-Jul-2019 10:21


Sprint announces a connected wallet card with built-in IoT support
Posted 18-Jul-2019 08:36


Educational tool developed at Otago makes international launch
Posted 17-Jul-2019 21:57


Symantec introduces cloud access security solution
Posted 17-Jul-2019 21:48


New Zealand government unveils new digital service to make business easier
Posted 16-Jul-2019 17:35


Scientists unveil image of quantum entanglement
Posted 13-Jul-2019 06:00


Hackers to be challenged at University of Waikato
Posted 12-Jul-2019 21:34


OPPO Reno Z now available in New Zealand
Posted 12-Jul-2019 21:28


Sony introduces WF-1000XM3 wireless headphones with noise cancellation
Posted 8-Jul-2019 16:56


Xero announces new smarter tools, push into the North American market
Posted 19-Jun-2019 17:20


New report by Unisys shows New Zealanders want action by social platform companies and police to monitor social media sites
Posted 19-Jun-2019 17:09


ASB adds Google Pay option to contactless payments
Posted 19-Jun-2019 17:05


New Zealand PC Market declines on the back of high channel inventory, IDC reports
Posted 18-Jun-2019 17:35



Geekzone Live »

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


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



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.

Alternatively, you can receive a daily email with Geekzone updates.