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

Uber Geek
+1 received by user: 513

Trusted

  Reply # 1987254 2-Apr-2018 18:42
Send private message quote this post

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

NextPVR/OpenHAB: 
Gigabyte AMD A8 Brix --> Samsung LA46A650D via HDMI, NextPVR,OpenHAB with Aeotech ZWave Controller
Media:Chromecast v2, ATV4, Roku3, Raspberry PI temperature Sensors and Bluetooth LE Sensors,HDHomeRun Dual
Windows 2012 
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


1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 1987288 2-Apr-2018 20:02
Send private message quote this post

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

1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 1987290 2-Apr-2018 20:07
Send private message quote this post

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

60 posts

Master Geek
+1 received by user: 4

Trusted

  Reply # 1998781 18-Apr-2018 17:09
Send private message quote this post

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!

243 posts

Master Geek
+1 received by user: 4

Trusted

  Reply # 1998965 18-Apr-2018 20:43
Send private message quote this post

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

1904 posts

Uber Geek
+1 received by user: 1051


  Reply # 1999004 18-Apr-2018 22:53
Send private message quote this post

@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

1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 2001813 24-Apr-2018 17:33
Send private message quote this post

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


3983 posts

Uber Geek
+1 received by user: 513

Trusted

  Reply # 2001857 24-Apr-2018 18:13
Send private message quote this post

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

NextPVR/OpenHAB: 
Gigabyte AMD A8 Brix --> Samsung LA46A650D via HDMI, NextPVR,OpenHAB with Aeotech ZWave Controller
Media:Chromecast v2, ATV4, Roku3, Raspberry PI temperature Sensors and Bluetooth LE Sensors,HDHomeRun Dual
Windows 2012 
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


1904 posts

Uber Geek
+1 received by user: 1051


  Reply # 2001864 24-Apr-2018 18:38
Send private message quote this post

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

1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 2001868 24-Apr-2018 18:53
Send private message quote this post

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


1904 posts

Uber Geek
+1 received by user: 1051


  Reply # 2001870 24-Apr-2018 19:08
Send private message quote this post

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

1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 2001877 24-Apr-2018 19:32
Send private message quote this post

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


1904 posts

Uber Geek
+1 received by user: 1051


  Reply # 2001878 24-Apr-2018 19:38
Send private message quote this post

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




Location: Dunedin

1014 posts

Uber Geek
+1 received by user: 71

Subscriber

  Reply # 2001880 24-Apr-2018 19:45
Send private message quote this post

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


1904 posts

Uber Geek
+1 received by user: 1051


  Reply # 2001887 24-Apr-2018 19:51
Send private message quote this post

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 »

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 »

Intel introduces new NUC kits and NUC mini PCs
Posted 16-Aug-2018 11:03


The Warehouse leaps into the AI future with Google
Posted 15-Aug-2018 17:56


Targus set sights on enterprise and consumer growth in New Zealand
Posted 13-Aug-2018 13:47


Huawei to distribute nova 3i in New Zealand
Posted 9-Aug-2018 16:23


Home robot Vector to be available in New Zealand stores
Posted 9-Aug-2018 14:47


Panasonic announces new 2018 OLED TV line up
Posted 7-Aug-2018 16:38


Kordia completes first live 4K TV broadcast
Posted 1-Aug-2018 13:00


Schools get safer and smarter internet with Managed Network Upgrade
Posted 30-Jul-2018 20:01


DNC wants a safer .nz in the coming year
Posted 26-Jul-2018 16:08


Auldhouse becomes an AWS Authorised Training Delivery Partner in New Zealand
Posted 26-Jul-2018 15:55


Rakuten Kobo launches Kobo Clara HD entry level reader
Posted 26-Jul-2018 15:44


Kiwi team reaches semi-finals at the Microsoft Imagine Cup
Posted 26-Jul-2018 15:38


KidsCan App to Help Kiwi Children in Need
Posted 26-Jul-2018 15:32


FUJIFILM announces new high-performance lenses
Posted 24-Jul-2018 14:57


New FUJIFILM XF10 introduces square mode for Instagram sharing
Posted 24-Jul-2018 14:44



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.

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