|
Post by keshin on Jan 8, 2018 9:06:26 GMT
upon further research i came across this, i am unsure as i am still learning but if anyone has a moment to spare and can look into it and let me know if this is what im looking for (for the hard wired ethernet portion) this code is for a garage remote control and other things i dont need but it does control a relay. i know its a big ask but if this is the code that would work could anyone possible remove the everything other than the relay control part. i might be able to get my head around that for starters. this is the page it is on (sorry if im not allowed to tag pages) www.instructables.com/id/Garage-Genie-Parking-Remote-Control/i noticed the code is from 2015 FUPAWPMI98BNFT3.ino (2.95 KB). i have opened up the following arduino code and attempted to verify it and get the error "exit status 1'callback' was not declared in this scope" which then highlights this portion of the code, PubSubClient client(server, 1883, callback, ethClient); // mqtt clientunsigned long keepalivetime=0; i am also unable to get these two libraries to turn orange to indicate it has recognized them #include <stdio.h> #include <stdlib.h> attached is the code if anyone has time or can help it is greatly appreciated
|
|
|
Post by papa on Jan 8, 2018 14:38:05 GMT
About the Instructables' Garage-Genie-Parking-Remote-Control ... Yes, I remembered that & was going to look for it when I had a chance.
That Instructable was by Eric Tsai, the founder of this forum. Eric has moved on to other things.
The Garage Genie Instructable & Eric's Uber Home Automation Instructable have some similarities to this forum's current code, but are from 2015, before our current coding here.
Since those instructables, forum members (especially computourist) have made the communication more reliable, but not compatible with the earlier instructables.
I have found a Gateway sketch that I experimented with that communicated with OpenHAB (a little bit) like a node. As I said, I've got a time crunch currently, but hope within a few weeks to look at that with you in mind.
I still believe you will build a better foundation for your system & knowledge if you start with the ESP8266 & RFM69 projects that are already documented here. Unlike the instructable sketch, our sketches are ready for current Arduino IDE standards which helps avoid compiling errors.
Experimenting now with the Garage Genie Instructable on mega & relay board may eat productive time & confuse you with its similarities & differences from our forum code.
One of us might talk you through the compiling errors you got, but the sketch would still be trying to communicate with OpenHAB differently than how our forum does it now. Sorry, I just don't have the time to figure out the previous method & how to explain it to you & then risk more time to convert you over to our current approach.
Again, I think a better use of time (yours & ours) is for you to make our initial ESP8266 & RFM69 projects work. I'm pretty sure that we could adapt the Ethernet cabled mega into the system later.
|
|
|
Post by papa on Jan 10, 2018 22:37:30 GMT
keshin: "i have an Arduino mega with Ethernet shield ... Does anyone have a basic sketch or notes that would allow the Arduino to communicate with openhab (over Ethernet) and make a switch for led pin 13 to turn on, from that i think i would be able to understand what parts identify the arduino to openhab and what parts identify a switch and output in Arduino."
papa: I believe the following will answer your request. (But please, keep working on ESP8266 & RFM69 projects because this Ethernet node will work along side those projects.)
An Ethernet Node, HardwareI don't have an Arduino Mega. This worked on a Buono Uno with Ethernet Shield so I assume it's workable or adaptable to the Mega. In the wiring (& programming sketch), you can change the pin assignments as long as you avoid the pin reserved for the Ethernet Shield & probably should avoid the pins that could later be used for an RFM69 radio & add a Gateway function to this node. (These "reserved" pins' locations on a Mega might be different than for a Buono Uno.) ^^ Click on image for larger view of schematic Next, An Ethernet Node, Software
|
|
|
Post by papa on Jan 10, 2018 22:44:27 GMT
An Ethernet Node, SoftwareI based the programming of this node on computourist's ESP_SONOFF_12.ino & RFM_MQTT_GW_25.ino (Gateway). I applied the Ethernet aspects of the Gateway to replace the WiFi connections of the ESP8266 node & added some tweaking of my own. Ethernet_Node_04_pub.ino (19.21 KB) << Download the programming sketch here, but be aware of needed customizing described below. Next, Customizing the Ethernet Node Software
|
|
|
Post by papa on Jan 10, 2018 23:12:11 GMT
Customizing the Ethernet Node Software
Check the customizing in lines 44-66
As downloaded, the sketch matches the schematic: INOUT & SWITCH1 are defined so that closing a switch or jumper between D5 & GND will light an LED on D9.
To change pin assignments, see line 470 for SWITCH1 & line 79 for the ACT1 (actuator) pin that can power an LED or relay
For the first node, you can leave as is: mac & nodeId, but will need to change them for additional Ethernet nodes. nodeId is a number with no more than 2 digits.
For the mqtt_server variable, replace x & y with the rest of the IP address of the computer hosting your MQTT server.
For ipDefault, use the same x value as for MQTT server & replace z with a permitted & available address number in your local network.
Match SERIAL_BAUD with data rate of your Arduino IDE's Serial Monitor & (with DEBUG defined & the node connected to USB) the Serial Monitor will display debugging info.
After the node is programmed, it should restart, the D7 LED flashes once to indicate connection to Ethernet, & then lights steady to indicate connection to Ethernet & MQTT. The IDE Serial Monitor should show some start up messages about connecting & the Ethernet Shields assigned IP address.
Then periodically the Serial Monitor will display current values of the devices that represent SWITCH1 (device 43) & the ACT1 actuator (device 16). Another push BUTTON device (40) can be defined & can be linked to the ACT1 actuator.
Once you understand how the above works, you can use other pins & devices.
Next, OpenHAB Entries to Communicate with the Ethernet Node
|
|
|
Post by papa on Jan 11, 2018 0:12:06 GMT
OpenHAB Entries to Communicate with the Ethernet Node
The following assumes: you have a computer successfully running OpenHAB 2 & Mosquitto (MQTT) & have chosen an OpenHAB User Interface, you built the hardware above & connected an Ethernet Cable between your local network router & the Ethernet port on the Ethernet Node's Ethernet Shield, & you customized the above programming (including defining the nodeId as 50) & uploaded it to the node.
There's probably a way do the following configuration entries via OpenHAB2's PaperUI. However, I'll use the method of adding text entries to OpenHAB configuration files. In each case, I name a files that starts with "My", but your file can have a different name as long as it has the tag (like .items or .sitemap) after "My".
add to My.items Switch Act_Node50 { mqtt="<[mosquitto:home/eth_gw/nb/node50/dev16:state:default::]", mqtt=">[mosquitto:home/eth_gw/sb/node50/dev16:command:*:default]" }
String IPnode50 "Node50 IP: [%s]" <networking> {mqtt="<[mosquitto:home/eth_gw/nb/node50/dev10:state:default]" } ================================ add to My.sitemap Switch item=Act_Node50 Text item=IPnode50 =============================== Via the hardware, closing SWITCH1 will toggle the power for the LED or relay on D9
Via the first item & first sitemap entry, an OpenHAB User Interface virtual switch will display the ON or OFF status of D9. One can use the physical SWITCH1 or virtual switch to change the status of what's on D9.
Via the second item & second sitemap entry, the Ethernet node's IP Address is obtained & displayed on the OpenHAB User Interface.
========================================
Much more can be done with this (some already provided for in the programming), but I believe this will answer keshin's request & give a good start on making & using an Ethernet Node. OpenHAB entries for this node follow the same structure as for the ESP8266 & RFM69 nodes so you can learn from & adapt those. You just need to make sure that "mosquitto:home/" is followed by "eth_gw" This type of node should also operate just fine alongside the ESP8266 & RFM69 nodes.
Enjoy. How will you use this Ethernet Node?
|
|
|
Post by billgrubbs on Jan 19, 2018 23:52:41 GMT
I followed your instructions for the Ethernet node and I am getting 60 second updates on the serial monitor. The two things show up on the basic UI, but I am unable to control the LED from the UI. When I remove the ground from d5 the led goes off and it also indicates it in the monitor. I must have something wired wrong since I can't control the led from the UI. Any suggestions? I am definitely getting close and that is exciting.
|
|
|
Post by papa on Jan 20, 2018 1:57:53 GMT
billgrubbs, can you control the LED from the User Interface (UI) virtual switch when D5 is NOT connected to GND via switch or jumper? The UI virtual switch may only work with D5 is not grounded. In that case, a normally open push button would work better there, because it only momentarily grounds D5.
I don't have my Ethernet node with me, but I tried the code on another node. A change on either the D5 jumper or the User Interface virtual switch should make the LED the opposite state, that is, ON becomes OFF & vice versa.
Also one thing I notice with the current OpenHAB2: sometimes items do not always seem to link immediately to the User Interface. What I've done that seems to help is to stop & start OpenHAB running a time or two & maybe close & reopen the browser window that holds the User Interface.
|
|
|
Post by papa on Jan 20, 2018 18:35:33 GMT
The above thread started as part of Complete Beginner Help. It documents a node that uses our forum's software & approach to communicate with OpenHAB over an Ethernet Cable. As was done with the choices RFM69 node sketch, other functions could be added to this type of node.
Like the ESP8266 WiFi nodes, this Ethernet type of node does not need a gateway device to communicate with OpenHAB. It might be another good project for beginners to try. RFM69 nodes, ESP8266 nodes, & this Ethernet Node can work side by side with the same OpenHAB home automation network.
One can only place this node where an Ethernet network connection is available. (Being wireless, RFM69 & ESP8266 nodes can be placed any where they can receive a wireless signal.
|
|
|
Post by Bill G on Jan 24, 2018 14:45:30 GMT
I am not able to control the LED from the UI virtual switch when D5 is not connected to ground via jumper. I get immediate response on the serial monitor when I attach and remove the jumper to D5, but the UI does not do anything. On the UI I show Act_Node50 with a switch I can turn off and on, but it doesn't do anything. On the UI I also show Node50 IP: that just has a -. Not sure what that is supposed to do. I have turned the browser and the Arduino off and on and no change. Not sure what else I can do.
|
|
|
Post by papa on Jan 24, 2018 21:02:54 GMT
Bill G, I sympathize that you are having trouble with this. Over my two plus years with this project (including recently), I, too, have had some LONG frustrating times.
You wrote: "On the UI I also show Node50 IP: that just has a -" On the node's serial monitor output, what does it show for dev10, that is device 10, IP address? I suspect device 10 shows little on the serial monitor.
Device 10 & Node50 IP are supposed to show the IP address that your router's DHCP assigns to the node's Ethernet Shield. It should say something like 192.168.xx.zz with other numbers instead of xx & zz. This probably means that your Ethernet Node is NOT getting an IP address from your router & therefore cannot connect to Mosquitto (MQTT) message broker nor to OpenHAB. If so, no wonder OpenHAB UI & your node are not communicating.
Forgive me if this is obvious to you: Into the largest port on the W5100 Ethernet Shield, did you connect an Ethernet cable that would link the Shield (directly or through another device) to your local network router? If "no", then connect a cable & try again.
If your node's Ethernet Shield already has a physical cable that should link it to the router (& OpenHAB / node communication is still not working), you may need to reboot the router & the Arduino a time or two. For some reason, routers don't always assign IP addresses to Shields when they are first used.
(Again forgive what may seem obvious ...) If your router does not have its own battery backup, you can reboot it by unplugging its power for 30 seconds & then plug it back in. If your router does have its own battery backup, find its small reset hole (probably on the back). Use a small wire like the end of partly straightened paper clip to BRIEFLY click the switch at the bottom of that reset hole. Caution: Do NOT hold down on that reset switch because that could erase important settings in your router.
After rebooting the router, wait long enough for the LED lights to return to normal status. Then check your node's communication. Does IP address display with dev10 on the serial monitor? Does IP address show on the UI at Node50 IP? Try the Act_Node50 & jumper communication.
|
|
|
Post by billgrubbs on Jan 26, 2018 3:48:00 GMT
Device 10 shows 192.168.1.101 I do have the ethernet cable connected to the ethernet shield I rebooted the router and now Device 10 shows 192.168.1.10 At the beginning it also shows Ethernet connected. IP address: 192.168.1.10 Every minute I get the following: topic home/eth_gw/nb/node50/dev16 value:ON when D5 is plugged in and value:Off when it is unplugged topic home/eth_gw/nb/node50/dev43 value:ON when D5 is plugged in and value:Off when it is unplugged Still nothing showing on the UI at Node50 IP Still nothing happens wen I click the button on Act_Node50 on the UI Any other suggestions?
|
|
|
Post by papa on Jan 26, 2018 16:42:10 GMT
billgrubbs, from what you report in your last post, it appears that your Ethernet node is probably working properly, but for some reason, the node & OpenHAB are not communicating. When the node boots up, the Serial Monitor output should display " Connect to MQTT broker..." What does Serial Monitor say after that? ("Connected ..." or "Failed ..." ? If you installed the LEDs on the node does the D7 LED (MQTT indicator) blink then stay on? If the MQTT LED stays on, then the node is connected to the computers Mosquitto (MQTT) message broker service. Along with installing OpenHAB on your computer, did you install Mosquitto, the MQTT message broker? If you installed Mosquitto, have you confirmed that Mosquitto service is working? If Mosquitto is installed & working on the computer, did you also install the MQTT Binding within the OpenHAB configurations (PaperUI / Addons / Bindings)? << All this related to MQTT is necessary in order for the node & OpenHAB to communicate about the Act_Node50 & IPnode50 items in this post. Note "mqtt" in both those items. Have you checked the OpenHAB logs (events.log, openhab.log) for error messages that might tell us what's going wrong? If so, what errors did you find related to the Act_Node50 & IPnode50 items? What is the operating system of the computer that is hosting your OpenHAB: Windows, MAC OS, or Linux. If Linux ( see here), what method did you use for OpenHAB installation (apt-get,Yum / Dnf Based Systems, OpenHABian on a Raspberry PI)? << Your answers may help us know where to have you look further.
|
|
|
Post by keshin on Jan 27, 2018 3:04:00 GMT
I am using windows 7 and this is what worked for me i had the same issue, with much trial and error i discovered that openhab was not binding with mqqt (mosquitto) attached below is a word document with the instructions that solved my issue, please make sure you have port forwarded :1883 and have installed the openhab2 addons found below bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab-addons%2F2.2.0%2Fopenhab-addons-2.2.0.karI am currently working on an in depth how to guide on how to install bind and run openhab on a windows based machine as it seems to be uncommon and i feel it may help people bring people to the forum when they google how to do this. here is the instructions to bind mosquitto correctly (i have had to compress file with 7 zip due to attachment size as the document consists of screenshots) Windows 7 mqqt binding openhab.7z (551.47 KB) EDIT: i have added a note to the above document at the very bottom that i have found to also be an issue. Edit: Papa thanks heaps the coding worked and have successfully run it on my mega with ethernet shield. Now im getting my head around the meaning behind each line of code to learn how to utilize all more of the available i/o pins and bind them to their respective switch/sensor etc in open hab
|
|
|
Post by papa on Jan 27, 2018 14:29:55 GMT
Thanks, keshin, for offering help for billgrubbs' issues & for your feedback on having a working Ethernet Node that communicates with OpenHAB. Thanks for the Windows MQTT documentation that you offered in your last post & the other documentation you will provide later. I don't believe we know yet that billgrubbs is using OpenHAB on a Windows computer, but your document should be useful for those that do use Windows. One suggestion about your mqqt binding openhab.7z: perhaps include "Windows" in its title & in the document itself. I've done an earlier post on installing Mosquitto / MQTT on Windows computers which is probably stale. To that post, I'll add a link to your post just above. I hope our offered assistance helps billgrubbs. First experiences with getting a working node that also communicates with OpenHAB can be discouraging.
|
|
|
Post by keshin on Jan 31, 2018 7:26:21 GMT
my apologies ... your code worked fine im still learning alot and am still at the very basic stages, patience vs excitement to get a node running is a challenge i am struggling with. now that i have the relays working and basic functionality in my openhab i will get to learning more about coding and your script as i do wish to include sensors and more. Would you like to know my results here so far or in pm? At this stage i have only gotten the one output to work (i need to learn how to code in more outputs)
keshin: "Would you like to know my results here so far or in pm?"
papa: Generally, post in the public forum notes so all can benefit from what is learned or confirmed (positive or negative). Use personal messages for personal communication or information that has security concerns.
keshin: "your code worked fine im still learning alot and am still at the very basic stages, patience vs excitement to get a node running is a challenge i am struggling with. now that i have the relays working and basic functionality in my openhab i will get to learning more about coding and your script as i do wish to include sensors and more. ... at this stage i have only gotten the one output to work (i need to learn how to code in more outputs)"
papa: When I have more time, I can give some hints on cloning relay outputs in the choices sketch.
|
|
|
Post by billgrubbs on Feb 3, 2018 5:15:04 GMT
Well, I disappeared, but am back. I have read all of the recent posts and think I am more confused. Perhaps I have done this all wrong. My computer is a mac, but I have OpenHap2 and MQTT on a Raspberry Pi. I use SSH to upload to the Raspberry and the Arduino Bruno. Do I start over and use Keshin's recommendations?
|
|
|
Post by keshin on Feb 3, 2018 11:32:06 GMT
Well, I disappeared, but am back. I have read all of the recent posts and think I am more confused. Perhaps I have done this all wrong. My computer is a mac, but I have OpenHap2 and MQTT on a Raspberry Pi. I use SSH to upload to the Raspberry and the Arduino Bruno. Do I start over and use Keshin's recommendations? sorry bill im only a beginner aswell however i am running on windows 7 purely, that includes my openhab install and mqqt, im also running a arduino mega so im unsure if any of my recommendations will help, however when i was having trouble this is what i found my arduino connect to the lan correctly through serial monitor i could see the commands being sent but for some reason it would not respond through openhab, that turned out to be my fault and i hadnt binded my mqqt to openhab (i had missed steps) again this was my issues through windows, im unsure but if you can see your aduino is connecting to your network and sending commands (in serial monitor) i can only suggest checking you have got openhab binded with your mqqt server/broker correctly
|
|
|
Post by papa on Feb 3, 2018 14:59:00 GMT
billgrubbs, keshin makes a good point: Make sure that you installed the MQTT binding in OpenHAB. This is in addition to installing the Mosquitto (MQTT) broker on the computer.
You can install the MQTT binding via OpenHAB's Paper UI / Addons / Bindings
|
|
|
Post by billgrubbs on Feb 6, 2018 3:01:47 GMT
When you say install MQTT on the computer, do you mean on the Raspberry Pi or my MAC? I have already set the binding in Openhab for MQTT.
|
|
|
Post by papa on Feb 6, 2018 16:18:58 GMT
billgrubbs, "I have read all of the recent posts and think I am more confused. Perhaps I have done this all wrong. My computer is a mac, but I have OpenHap2 and MQTT on a Raspberry Pi. I use SSH to upload to the Raspberry and the Arduino Bruno. Do I start over and use Keshin's recommendations on the Alternate Ethernet Node? ... When you say install MQTT on the computer, do you mean on the Raspberry Pi or my MAC? I have already set the binding in Openhab for MQTT." papa: I'm having trouble myself keeping straight two interlinking conversations & two versions of an Ethernet Node. I suggest we stay with the Ethernet Node you started with & do not go to the working_simple_ethernet.ino node that keshin introduced. If you change to the Alternate Ethernet Node, I suspect you'll have the same trouble you're having now & get even more confused. I've reviewed your & my conversation about the 1st type of Ethernet Node. You've answered some of my troubleshooting questions, but some remain. So far I believe we've confirmed the following: On a Raspberry Pi, you are running OpenHAB2 with the MQTT binding installed. Your node seems to generate good output on the Arduino IDE Serial Monitor, but the node & OpenHAB UI are not communicating. Please respond to these other questions I asked earlier:When the node boots up, the Serial Monitor output should display "Connect to MQTT broker..." What does Serial Monitor say after that? ("Connected ..." or "Failed ..." ? If you installed the LEDs on the node does the D7 LED (MQTT indicator) blink then stay on? If the MQTT LED stays on, then the node is connected to the computers Mosquitto (MQTT) message broker service. Along with installing OpenHAB 2 (& MQTT binding) on your Raspberry Pi, did you install (on the Pi) Mosquitto, the MQTT message broker? If you installed Mosquitto, have you confirmed that the Mosquitto service is working? (Note: Having Mosquitto installed is related to the MQTT binding, but is a separate, necessary step.) PS I moved the Alternate Ethernet Node's posts to another thread. I agree it's confusing to have them both in the same thread.
|
|
|
Post by papa on Feb 7, 2018 15:06:06 GMT
billgrubbs, towards troubleshooting your problems, please respond to the requests I made in the last post.
From what you said, you have added the MQTT binding to OpenHAB. As I asked in the last post, did you install Mosquitto on the Raspberry Pi?One more troubleshooting question, in OpenHAB's configuration folder, did you edit the services/mqtt.cfg file to tell the MQTT binding to communicate with Mosquitto. This official documentation talks about that in the sections Transport Configuration & Example Configurations. However, at most basic, one adds these two lines to mqtt.cfg: mosquitto.url=tcp://localhost:1883 mosquitto.clientId=openhab I just installed OpenHAB 2 on a new Raspberry Pi. Before I edited mqtt.cfg, (like yours) my Ethernet Node & OpenHAB were not communicating even though I installed Mosquitto on the Pi & added MQTT binding to OpenHAB. For MQTT communication to work, one needs 1) OpenHAB plus MQTT binding installed on a computer (like a Pi) 2) Mosquitto also installed on the same computer 3) OpenHAB's mqtt.cfg edited as above to include mosquitto references 4) .items file entries that use the mqtt binding 5) .sitemap file entries to include the mqtt item entries from 4)
|
|
|
Post by papa on Feb 7, 2018 21:39:26 GMT
|
|