[EDIT] I created a forum to collaborate on gateway code.


A few years ago, I became a dog owner for the first time. I didn't like leaving Cody in the kennel alone all day. I had a webcam on him, but I couldn't watch it all day long. What if he was in some kind of distress? What if there was a emergency at the house, like a fire?

I wanted some way of getting an immediate email notification when he barks, or when something bad happens. So reading lead to tinkering, and tinkering eventually lead to making this full blown home automation system based on open source hardware (Arduino) and open source software (OpenHAB). I know I know, yet another "Arduino Home Automation" project, right? But I promise I'm not going to turn on a light from a smart phone. I'm more focused on extensive networked sensors, timely alerts, and aesthetically appealing presentation of events.

Here's the basic idea. With Arduino, it's really easy to connect boatloads of cheap sensors. Using this setup, that boatload of cheap sensors can now be on the internets. They can email you when things get too hot, too cold, too smokie, too gassy, or too bright. And your dog can email you by barking. You can also view the status of sensors on your smart phone. These sensor nodes are wireless, so you're not constrained by the location of ethernet ports.

Here's how it's put together.

This Instructable will be a tutorial for how to build a variety of long range wireless sensors, and how to integrate these sensors into a sophisticated open source home automation server. Aside from looking at a mobile app to see what's happening, you'll also receive timely email and audio notifications. This is a long Instructable, but you can jump to the sensor you're interested in building.

These elements are the focus of the design:

  • Low Cost. Each sensor node costs less than $20 to make, so you can inexpensively scale up.
  • Flexibility. Arduino based nodes allow anyone to extend the system to their particular sensing needs. You're not tied to only the examples I'm providing, even though I strive to provide many examples.
  • Very good reliability, up-time, and wireless sensor range.
  • I'm providing both a battery powered and wall-power sensor node design

So, here's the list of sensors in this Instructable. I want to provide a home with the full range of human senses. Your home should be smart and sensitive.

Dog Bark (Any Loud Noise) Sensor
Get email notifications of loud noise. I use it to get an email if my dog barks in the kennel, so that I can open up my kennel webcam and see why he barked. There is also a counter to try to quantify how much he has been barking.

Washer-Dryer Sensor
Get an audio reminder when washer/dryer cycle completes - something like a "Washer Complete" announcement in the living room. No more forgetting laundry in the washer or wondering if it's done yet. Use the smart phone app to check if the cycle is complete or if the load has been picked up.

Light Sensor
Detect whether the light got left on or not. Displays the status of light on the smart phone app.

Area Intrusion Monitor
A PIR sensor monitors a room and sets off audio alarm / email notification when it senses a moving body.

Dog Tracker
Get notified if your dog runs away, track he's GPS location on google maps, and also map where he poops.

Gas/Fire/Smoke Sensor
Although this should not be the primary fire alarm, it can be used to send an email notification to you when the sensor senses smoke, fire, or LP gas commonly used in gas-powered stoves.

Temperature / Humidity Sensor
Temperature and humidity is reported to the mobile app. Optionally, you can enable email notifications when temperature dips below/above some preset value. Helpful for detecting furnace or air conditioner failures. You can also view a historical chart of temperature data using OpenHAB.

Water Leak Sensor
Get an email notification and audio alarm when a water leak is detected.

Just kidding, I got nothing for taste. I just like that picture. A couple more sensors that don't fit in neat categories.

Security - Door / Window / Drawer / Mailbox sensor
A battery powered reed-switch sensor that can set off an audible alarm, or send an email notification to your smart phone. Can be used to monitor doors, windows, mailboxes, or drawers. It also logs the time the event happened, as well as the remaining battery capacity on the sensor.

Garage Door Monitor
This is handy if you can't see your garage door from the house. Use a smart phone to check whether your garage door is opened or closed. You can also set it to play an audio reminder at, say 10PM, if the garage door is still opened.

With these sensors, everything from your dog to your washer & dryer can be part of the Internet of Things in a practical and useful way.

If there is any other home sensing thing you'd like an example of, add a comment and I'll try to get a sensor for it or use an existing sensor to fill the need. I'm trying to make a collection of sensors for most situations. It's only in the aggregate that this system makes sense - a bunch of one-off sensors don't really create a coherent home automation project.

Thanks for visiting my Instructable!

Step 1: Usage & Explaination

I'll start off with some videos explaining how this system works and how it can be used. If this is still interesting, the rest of the steps detail how to build it. You'll see these videos repeated on the steps for the individual sensors. The home automation and "IoT" space is so fragmented right now that there's a lot of cynicism about whether or not the smart home can work or is actually useful. Besides showing you how the system works, the videos help lend some credibility to the project.

1. Detailed Video Explaination

2. Wireless Laundry Room Sensor

3. Wireless Garage Door Monitor

4. Wireless Uber Sensor

5. Security - Wireless Door Sensor or Mailbox Sensor

There are a lot of "Arduino Home Automation" projects out there. My project is unique for the following reasons:

    • Cheap - each sensor node is less than $20, including the wireless transceiver.
    • Flexible - I'm providing the design for wall-powered sensors as well as energy efficient battery powered sensors that can run for a year on 4xAA batteries.
    • Best wireless solution - the RFM69HW in this project is energy efficient and has great range. Many other wireless solutions make compromises. Bluetooth is energy efficient, but poor range. Wifi has ok range, but can't be battery powered for a year.
    • Attractive and secure user interface - the OpenHAB UI is available as a mobile app (Android and iPhone), but is also accessible through any web browser. And the communication between the display device and the Raspberry Pi is done using encryption and authentication. So your home automation system stays private. It's also pretty easy to use considering the sophistication and features.
    • Controls commercial products: If you happen to have Sonos speakers, Insteon lights/plugs, or z-wave at home, you can use OpenHAB to control those devices too. OpenHAB isn't just for this Arduino project.
    • Allows you to integrate any sensor to your automation needs. Commercial home automation system might not provide the niche sensing "thing" for which you have a need, maybe because your needs are unique.

    The heat map below shows the range of the RFM69HW wireless transceiver used in this project. I produced the map using a GPS module connected to an Arduino with a RFM69HW transmitting the coordinate. I walked around outside with this GPS Arduino while another Arduino sitting inside my house received the GPS coordinate every few seconds. I then mapped the GPS points. I'm able to send data 7 houses away, through many walls. Zigbee, bluetooth, Z-wave, and wifi can't do this for just $4. The 915MHz frequency used by the RFM69 has better range and wall penetration than 2.4GHz wireless modules. This is one of the reasons I'm using it instead of the nRF24L01+ transceiver that is popular in the Arduino community.

    This is an example page from the OpenHAB user interface.

    This project doesn't require hugely expensive equipment. The technical challenges are surmountable. And the results are pretty cool.

    <p>In step 5, if I'm reading the schematic correctly, there's a 1M resistor going from (unregulated) power to A3, and there's another 1M resistor going from A3 to Ground. Admittedly, I'm very noob to circuits and such, but wouldn't this cause a short? I'm not really following the logic here, and how this allows us to monitor for anything on A3.</p>
    <p>I should've pointed that out specifically, it's a common question. Schematically, it looks like this: Battery_Voltage----R1----R2---GND. There's two resistors in series between the battery voltage and GND, so it's not a short. A3 is placed between R1 and R2. They form a voltage divider (google this term). A3 measures the battery voltage at the point between R1 and R2, which is half the battery voltage if R1=R2.</p>
    <p>Oh, and the two resistors are always consuming current, and are a total waste of power. You can make them 10Mohms if you want, which would decrease current consumption to 1/10th. But high resistances also lower current flow into A3, which prevents accurate voltage readings on the analog pin. The capacitor is there to keep the reading accurate when higher value resistors are used. In the spec for the ATMEGA328, there's some mention of max impedance that you can use without the capacitor. I'm not sure what it is, I just used what I had.</p>
    <p>Thank you for the great explanation! Makes perfect sense. </p><p>I wanted to also throw out there to the crowd that I do now have a working version of the RFM69 chip directly connected to the Raspberry Pi! I was able to use the information located here:</p><p><a href="https://github.com/abouillot/HomeAutomation/tree/master/piGateway" rel="nofollow">https://github.com/abouillot/HomeAutomation/tree/m...</a></p><p>I'm getting really low RSSI right now that I can't quite figure out (Typically around -100db when the two chips are only 3ft apart), but it's working! My antenna wire is about 3 inches on both, so thinking I need to give them larger antennas. Just need a minute to do some resoldering...</p>
    <p>Hi, I got it working too (yay!) but the same low signal strength as you report, did you get it higher? by resoldering?</p>
    <p>if you have the RFM69 at 433 MHz, you may want to use this antenna. Made a big difference for me: </p><p><a href="https://arduinodiy.wordpress.com/2015/07/25/coil-loaded-433-mhz-antenna/" rel="nofollow">https://arduinodiy.wordpress.com/2015/07/25/coil-l...</a></p>
    <p>I did finally get my RSSI higher, but I'm not completely sure what the reason is yet. I have done two things - I updated the Gateway code for the raspberry pi and I purchased a mini wireless module from anarduino. I'm now getting around -25 to -30 RSSI. I purchased the new wireless module to help isolate the issue, since I then don't have to worry about soldering issues. I updated the Gateway code on the raspberry pi before I bought the module.</p><p>My goal is to move back to my pro micro module prior to putting this solution into production, but I'm planning on perfecting my code first so that I can focus later on just fixing the hardware.</p>
    <p>Hi, Im trying the RF on Pi as well, first got stuck on installing the MQTT, but now on the Gateway install. Instruxtion says &quot;cd ~/piGateway&quot;, while I have no such folder, should I copy all files from the GIT into a that folder?</p><p>thanks</p>
    <p>The piGateway directory will be located whereever you completed your download at. My guess is that your files are actually located in:<br>~/HomeAutomation-master/piGateway. It really doesn't matter where the files are located - You can just go to the directory containing the files and continue on with the instructions. </p><p>Keep in mind that wherever you compile the piGateway program (the &quot;sudo ./Gateway&quot; command) is where the program will be located. Feel free to copy or move the program wherever is handy. And personally, I've called the program from rc.local so that Gateway starts when the raspberry pi is started. That way I don't have to open a terminal window every time the pi is power cycled. </p><p>Good luck!</p>
    <p>thanks for your quick response! I actually never downloaded the files from GIT &lt;ahem&gt;, so copied those by hand in the ./piGateway folder. Had to reinstall MQTT for the 3rd time, now from a package (see here: </p><p>http://www.xappsoftware.com/wordpress/2014/10/27/installing-mosquitto-on-raspberry-pi/ )</p><p>AND had to enable SPI pins with help of Rpi-config... Now I'm looking at the msg </p><p>Listening at 915 Mhz...setup complete<br>connection refused</p><p>Not sure if the latter is because I don't have another RF69HW in place or something else, but slowly making progress :)</p>
    <p>Not sure... Looking at the Gateway.c code, it definitely looks to be an issue with Mosquitto, but I'm somewhat of a beginner myself in all this. Sounds like you've removed the blacklisting for SPI... Outside of that, I'm not sure what to tell you. </p><p>All I can suggest is to keep looking into your mosquitto setup. Now that you've un-blacklisted your SPI, maybe you could try installing MQTT via apt-get. </p><p>Btw, I'm actually having some problems myself with the RFM69HW chip. I don't think it's related to any of this software, but thought I'd throw it out there. I can't seem to get more than a -90 RSSI. I'm sure that my issue is unrelated to yours, but wanted you to know that my installation isn't running totally perfect either.</p>
    <p>And this is probably going to come up. You can't put the battery voltage directly on A3. Well, you can, but it wont help you measure low battery situation. Your Vin is the 3.3V from the regulator. So the A3 pin will read saturation (vin=255) until the battery voltage drops below 3.3 volts. By that time, you're already 0.7V below when your regulator can stably regulate the 3.3V output (because of regulator drop-down voltage). You need to be able to measure when battery reaches 4.0V.</p><p>Hence the need to divide the battery voltage.</p>
    <p>Hi, Can I use (Arduino Pro Mini 3.3V) instead of Buono R3 ?</p><p>Thanks</p>
    <p>Kind of. The Pro mini probably can't supply the current needed for the RFM69 chip. Might need an off-board voltage regulator.</p>
    <p>this is an awesome instructable! I'm working on something similar to this now, thanks for your info and perspective!!!</p>
    <p>Can I use a non-switchable Arduino so long as I am careful to attach RFM69 to 3.3V?</p>
    <p>No, your I/O would still be at 5V. It's not just the 3.3V power to the RFM69 that you need to worry about.</p>
    <p>I was not paying attention when buying the arduino boards (...) and bought non switchable ones, it seems you need something like a level sifter to change the 5v voltage of the board to 3.3v, I bought the one below and hope it will solve that problem so I can hook up the RFM69HW</p><p><a href="http://rover.ebay.com/rover/0/e11400.m1842.l3160/7?euid=df6f828d63b64eb8ac435b0e9f351890&loc=http%3A%2F%2Fcgi.ebay.com%2Fws%2FeBayISAPI.dll%3FViewItem%26item%3D310965629892%26ssPageName%3DADME%3AL%3AOC%3ANL%3A3160" rel="nofollow">New IIC I2C Logic Level Converter Bi-Directional Module 5V to 3.3V For Arduino</a></p>
    <p>First of all: thanks for the great project and all the work that you've done! I've bought all the stuff needed and will try to start building as soon as possible. However, when experimenting with the uber sensor and the arduino hooked up to my pc I cannot seem to get any response via the serial monitor. I didn't change anything in the code so far and I am only using the light sensor at the moment but the serial monitor remains empty. The selected baud rate is 9600 which is the same as in the sketch. The serial monitor works fine in other sketches. Do you have any idea what this might be?</p><p>Thanks!</p>
    <p>Hi,</p><p>Try taking everything off, and running the RFM69 demo that's part of the RFM69 Arduino library? It sounds you're not even making it through setup.</p>
    <p>Hi,</p><p>Indeed there was an issue with the RFM69 transceiver so the problem with the serial monitor is solved now. I've tried the setup with the RFM69 directly connected to the raspberry pi as described by Alexander Bouillot but now I've come to the point where it should all be working. However, when testing nothing is happening. When I've time later this week I will continue searching. Thanks for your response!</p>
    <p>For those of you looking for an easier wifi version of this project, you can use this Smart Mouse Trap project:</p><p><a href="http://www.instructables.com/id/Better-Smarter-Mousetrap/" rel="nofollow">http://www.instructables.com/id/Better-Smarter-Mou...</a></p>
    <p>i just dont want to use respi i just want to do this through hive mq and mosquitto ,</p><p>i want whole project step by step please help me </p>
    <p>hello dear i seriously need you.. please help me </p><p>i have arduino board and also a shield .</p><p>i want to perform a experiment that i just want to connect arduino to senser and i want the data of sensor in cloud .. and also i need nee to trace that packet send can please help me ,.. to do this its really important to me .. thanks</p>
    <p>Hello, first of all, congrats, this is amazing work and im, planning on doing it, just i have a little question, i hope someone can explain it to me, im a little confused about the comunication nodes, &iquest;are the sensors conected in the same arduino where the rfm module is conected? thats what i understand from text and videos, but, it also shows that the two arduinos are conected by two cables via i2c, while it says the module makes the conection btewen arduinos &quot;wireless&quot; &iquest;could somemone explain this to me? &iquest;how come it says you only need two arduinos when diagrams show one for sensors one for wireless and one for ethernet?</p>
    <p>Was there any reason why you didn't use the wifi connection to network all nodes mainly in the scenario where we use a PC/laptop as the host?</p>
    <p>What are all things the raspberry do here? I'm planning doing something like this and maybe use https://dl.dropboxusercontent.com/u/993383/Cosa/doc/html/index.html Cosa libraries with arduinos. The thing is do I need raspberry? If I'm able to install OpenHAB or dometicz on QNAP (NAS), maybe rasp is not needed? Then Id only need arduino gateway that is connected to the QNAP and some &quot;slave&quot; arduinos. QNAP doesn't have any sensors in it but USB devices can be connected to it.</p>
    After I went through lots of tutorial this one remain still one of the most complete and great. Old but gold.<br>Is it really necessary the use of two arduinos for gateway purposes? And how would you structure it in case of Bluetooth as communication technology?
    <p>Fantastic article and much appreciated hard work -</p><p>If you, or other makers of this have a minute, I have a few questions:</p><p>1) As I have read, Anarduino is an option to have it already integrated for a few dollars more. Sounds worth it, any downside to that? What is the DO output on the other pins 3.3, or 5v?</p><p>2) I am really curious if I can combine the RF gateway and the ethernet gateway into one unit successfully. I have seen some comments, but haven't heard of any success stories.</p><p>3) Is there a limit to how many devices/sensors can communicate over one RFM69HW - similar to the your UBER box with a variety of sensors.</p><p>4) Any code snippets on handling ACK? I would like to see that for devices of longer distances to ensure the base picked up the message.</p><p>Thanks, in advance - Cheers!</p>
    <p>This is a great instrucable and I plan on using some things I learned here in my project, but I just have to point out that this is not strictly home automation because you have really only talked about monitoring in this instructable. There are no actuators in your system. </p>
    <p>Hi, Eric Tsai? Nice<br>to meet you.</p><p>My name is<br>Robert, at WIZnet in Korea. </p><p>We have been<br>searching some application references in which WIZnet solution is applied, and<br>found your project &ldquo;Uber Home Automation W/ Arduino &amp;Pi&ldquo; using Ethernet Shield. In the<br>Ethernet Shield WZnet&rsquo;s W5100 chip is embedded. Your development looks very<br>cool &amp; smart. </p><p>Recently we<br>opened WIZnet Museum (<a href="http://wiznetmuseum.com/" rel="nofollow"><strong>http://wiznetmuseum.com</strong></a>) site. This is<br>a academic-purposed collection of open projects, tutorials, articles and etc<br>from our global customers. </p><p>If you are O.K.<br>we would like to introduce your projects in here. Hopefully, you will allow<br>this.</p><p>Hopefully, keep<br>contacting us for the friendship.</p><p>Thank you very<br>much</p>
    <p>Hi, Eric Tsai? Nice<br>to meet you.</p><p>My name is<br>Robert, at WIZnet in Korea. </p><p>We have been<br>searching some application references in which WIZnet solution is applied, and<br>found your project &ldquo;Uber Home Automation W/ Arduino &amp;Pi&ldquo; using Ethernet Shield. In the<br>Ethernet Shield WZnet&rsquo;s W5100 chip is embedded. Your development looks very<br>cool &amp; smart. </p><p>Recently we<br>opened WIZnet Museum (<a href="http://wiznetmuseum.com/" rel="nofollow"><strong>http://wiznetmuseum.com</strong></a>) site. This is<br>a academic-purposed collection of open projects, tutorials, articles and etc<br>from our global customers. </p><p>If you are O.K.<br>we would like to introduce your projects in here. Hopefully, you will allow<br>this.</p><p>Hopefully, keep<br>contacting us for the friendship.</p><p>Thank you very<br>much</p>
    <p>Great instructable, Eric. Need you help with this question. Does the UNO board to which the Ethernet shield is attached, have to be at 3.3V or 5V. I understand that the other two UNOs have to be at 3.3V. Thanks.</p>
    <p>Very interesting project! Nicely done.</p>
    <p>Great instructable, Eric. Need you help with this question. Does the UNO board to which the Ethernet shield is attached, have to be at 3.3V or 5V. I understand that the other two UNOs have to be at 3.3V. Thanks.</p>
    <p>Great work sir. I want to use nrf24l01 for this project. I have completed one project with a two nrf modules but now i want to transmit data from 4 different nrf24l01 to a master node but know how to do it. Could you give a hint how to do it ?</p>
    <p>Hello all,</p><p>I've installed the gateway on the raspberry, </p><p>I'm trying to send some packets from arduino to the gateway (raspberry), but it doesn't work. The execution of the sketch on ARDUINO stop at the command:</p><p>&quot;radio.sendWithRetry(GATEWAYID, (const void*)(&amp;theData), sizeof(theData));&quot;</p><p>Looking at the serial monitor I've noted that if I turn OFF the RFM69HW (433MHz) detaching the power from the 3.3 pin (on Arduino), the execution code goes on.</p><p>The radio module is good.</p><p>Someone had this problem?</p><p>Thankyou</p>
    <p>Hi all,</p><p>First, let me say this is an awesome project. The level of detail and clarity is great. Kudos to the author.</p><p>I recently completed the project (only two of the sensors for now) using the combined ethernet gateway method and everything was working fine using an Arduino, a generic Ethernet shield with an RFM69HW 915Mhz module piggybacked on it as the gateway (see pic). The various sensors are using RFM69W 915Mhz modules to communicate with the gateway and they work fine.</p><p>I just upgraded my internet service and decided to upgrade my router from a DLink to a Motorola SBG6580 at the same time. After doing this the gatway will no longer get the DHCP address from the router as long as the RFM69W module is attached. The com port on my Arduino IDE shows the message &quot;Error getting IP address via DHCP, trying again...&quot; repeatedly forever and never gets the IP. If I remove the RF module only then the gateway will connect to the router just fine and returns the IP address. This issue can be reproduced at will simply by removing and replacing the RF module.</p><p>Any thoughts as to why it worked ok with the DLink router but not the Motorola? Because it worked previously I'm doubtful that there is a conflict with the h/w. </p><p>Any input would be appreciated.</p>
    <p>Hi Bruster!</p><p>My code works with the ethernetshield2. But only a fiew times...after some loops, the arduino hang it up and nothing will be delivered anymore. Have you an idea what happened?</p><p>http://forum.arduino.cc/index.php?topic=375936.0</p>
    Hi Ron,<br>I had the same problem. I was using RFM69 radios and it turned out that the both the Ethernet shield and the radio modules needed access to pin 10 on the Arduino controller. Several posts suggested changing the pin requirements in the sketch but I could never get it to work consistently. It would work sometimes and then sometimes not. The original method of having a separate radio and Ethernet gateway seemed to be fairly stable though.<br>Bruce
    <p>Hi Bruce</p><p>Thanks for your reply! It's a bit strange. Because the ethernetshield2 should handle multiple SPI. But it seems that it could not. Or i made something wrong. That made me a little bit angry :) My thought was, that you could configure your arduino by buying multiple shields, plug them in and write the code. I feel like a little dreamer :)<br>Ordering a third Arduino is not my prefered solution...but when it is the only solution, i have to buy one again....<br>Thanks, Dino</p>
    <p>Hi Bruster</p><p>Could you post your Arduino Project please? This project is the reason why i bought two Arduinos :) Two UNO and one with the Ethernet Shield on top. My setup looks like yours. ;) I'm a &quot;greenhorn&quot; on Arduino programming. I't would be nice, if i could get your code to learn from.</p><p>Thanks for your help!</p>
    Hi ronmueller,<br> Here is the code I used. Let me know if you have any questions and I will be happy to help if I can.<br> Bruster<br> <br> /*<br> Based on work from author:&nbsp; Eric Tsai<br> Gateway ncorporating both the RFM69 and the ethernet part<br> Revised by Alexandre Bouillot<br> <br> License:&nbsp; CC-BY-SA, https://creativecommons.org/licenses/by-sa/2.0/<br> Date:&nbsp; 10-23-2014<br> File: Gateway.ino<br> This sketch receives RFM wireless data and forwards it to Mosquitto relay<br> <br> Modifications Needed:<br> 1)&nbsp; Update encryption string &quot;ENCRYPTKEY&quot;<br> 2)&nbsp; Adjust SS - Chip Select - for RFM69<br> 3)&nbsp; Adjust MQTT server address<br> */<br> <br> /*<br> RFM69 Pinout:<br> MOSI = 11<br> MISO = 12 &lt;&lt;&lt;&lt;<br> SCK = 13<br> SS = 8<br> */<br> <br> /*<br> Ethernet Pinout:<br> MOSI = 11<br> MISO = 12<br> SCK = 13<br> SS = 10<br> DI00 to Pin 2 (interrupt)<br> */<br> <br> //general --------------------------------<br> #define SERIAL_BAUD&nbsp;&nbsp; 115200<br> #if 0<br> #define DEBUG1(expression)&nbsp; Serial.print(expression)<br> #define DEBUG2(expression, arg)&nbsp; Serial.print(expression, arg)<br> #define DEBUGLN1(expression)&nbsp; Serial.println(expression)<br> #else<br> #define DEBUG1(expression)<br> #define DEBUG2(expression, arg)<br> #define DEBUGLN1(expression)<br> #endif<br> //RFM69&nbsp; ----------------------------------<br> #include &lt;RFM69.h&gt;<br> #include &lt;SPI.h&gt;<br> #define NODEID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp; //unique for each node on same network<br> #define NETWORKID&nbsp;&nbsp;&nbsp;&nbsp; 100&nbsp; //the same on all nodes that talk to each other<br> //#define FREQUENCY&nbsp;&nbsp; RF69_433MHZ<br> //#define FREQUENCY&nbsp;&nbsp; RF69_868MHZ<br> #define FREQUENCY&nbsp;&nbsp;&nbsp;&nbsp; RF69_915MHZ<br> #define ENCRYPTKEY&nbsp;&nbsp;&nbsp; &quot;MysampleEncryptKey&quot; //exactly the same 16 characters/bytes on all nodes!<br> #define IS_RFM69HW&nbsp;&nbsp;&nbsp; //uncomment only for RFM69HW! Leave out if you have RFM69W!<br> #define ACK_TIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 30 // max # of ms to wait for an ack<br> #define RFM69_SS&nbsp; 8<br> RFM69 radio(RFM69_SS);<br> bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network<br> <br> #include &lt;Ethernet.h&gt;<br> bool conn_ok;<br> bool mydebug = true;<br> <br> //Ethernet<br> byte mac[]&nbsp;&nbsp;&nbsp; = {<br> &nbsp; 0x90, 0xA2, 0xDA, 0x0D, 0x11, 0x11<br> };<br> byte server[] = {192, 168, 0, 134 }; //Linux server address<br> <br> IPAddress ip(192, 168, 0, 4); //address of gateway device<br> EthernetClient ethClient;<br> #define DHCP_RETRY 500<br> <br> // Mosquitto---------------<br> #include &lt;PubSubClient.h&gt;<br> PubSubClient client(server, 1883, callback, ethClient);<br> #define MQTT_CLIENT_ID &quot;arduinoClient&quot;<br> #define MQTT_RETRY 500<br> int sendMQTT = 0;<br> unsigned long MQTT_reconnect = 0;<br> <br> <br> void MQTTSendInt(PubSubClient* _client, int node, int sensor, int var, int val);<br> void MQTTSendULong(PubSubClient* _client, int node, int sensor, int var, unsigned long val);<br> void MQTTSendFloat(PubSubClient* _client, int node, int sensor, int var, float val);<br> <br> //use LED for indicating MQTT connection status.<br> int led = 13;<br> <br> typedef struct {<br> &nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nodeID;<br> &nbsp; int&nbsp;&nbsp; sensorID;<br> &nbsp; unsigned long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var1_usl;<br> &nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var2_float;<br> &nbsp; float&nbsp;&nbsp; var3_float;<br> }<br> Payload;<br> Payload theData;<br> <br> volatile struct<br> {<br> &nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nodeID;<br> &nbsp; int&nbsp;&nbsp; sensorID;<br> &nbsp; unsigned long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var1_usl;<br> &nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var2_float;<br> &nbsp; float&nbsp;&nbsp; var3_float;&nbsp; //<br> &nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var4_int;<br> }<br> SensorNode;<br> <br> void setup()<br> {<br> &nbsp; Serial.begin(SERIAL_BAUD);<br> &nbsp; Serial.println(&quot;Rebooting Ethernet_RFM_Gateways_Combinedv1.1&quot;);<br> <br> &nbsp; //Ethernet -------------------------<br> &nbsp; //Ethernet.begin(mac, ip);<br> <br> &nbsp; //&nbsp; //wait for IP address<br> &nbsp; while (Ethernet.begin(mac) != 1) {<br> &nbsp;&nbsp;&nbsp; Serial.println(&quot;Error getting IP address via DHCP, trying again...&quot;);<br> &nbsp;&nbsp;&nbsp; delay(DHCP_RETRY);<br> &nbsp; }<br> <br> &nbsp; Serial.println(&quot;ethernet OK&quot;);<br> &nbsp; // print your local IP address:<br> &nbsp; Serial.println(&quot;My IP address: &quot;);<br> &nbsp; for (byte thisByte = 0; thisByte &lt; 4; thisByte++) {<br> &nbsp;&nbsp;&nbsp; // print the value of each byte of the IP address:<br> &nbsp;&nbsp;&nbsp; Serial.print(Ethernet.localIP()[thisByte], DEC);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;.&quot;);<br> &nbsp; }<br> &nbsp; Serial.println();<br> &nbsp; Serial.println(&quot;Connecting to MQTT via ethernet: &quot;);<br> &nbsp; // Mosquitto ------------------------------<br> &nbsp; while (client.connect(MQTT_CLIENT_ID) != 1) {<br> &nbsp;&nbsp;&nbsp; DEBUGLN1(&quot;Error connecting to MQTT&quot;);<br> &nbsp;&nbsp;&nbsp; delay(MQTT_RETRY);<br> &nbsp; }<br> &nbsp; Serial.println(&quot;Connected... &quot;);<br> <br> &nbsp; //RFM69 ---------------------------<br> &nbsp; Serial.println(&quot;Initializing radio&quot;);<br> &nbsp; radio.initialize(FREQUENCY, NODEID, NETWORKID);<br> #ifdef IS_RFM69HW<br> &nbsp; radio.setHighPower(); //uncomment only for RFM69HW!<br> &nbsp; Serial.println(&quot;setHighPower ok &quot;);<br> #endif<br> &nbsp; radio.encrypt(ENCRYPTKEY);<br> &nbsp; radio.promiscuous(promiscuousMode);<br> &nbsp; Serial.println(&quot;Radio initialized&quot;);<br> &nbsp; char buff[50];<br> &nbsp; sprintf(buff, &quot;\nListening at %d Mhz...&quot;, FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);<br> &nbsp; Serial.println(buff);<br> <br> &nbsp; Serial.println(&quot;setup complete&quot;);<br> }&nbsp; // end of setup<br> <br> byte ackCount = 0;<br> long watchdogInterval = 2000;<br> long watchdog = 0;<br> <br> void loop() {<br> <br> &nbsp; // calling client.loop too often block the system at some point quite early (~up to 5 loop)<br> &nbsp; // Here is a temporized call to it on a regular interval<br> &nbsp; // This need to be as fast as the fastest sensor received<br> &nbsp; //&nbsp; if (millis() &gt; watchdog) {<br> &nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.print(&quot;loop &quot;);<br> &nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(millis());<br> &nbsp; //&nbsp;&nbsp;&nbsp; watchdog += watchdogInterval;<br> &nbsp; //&nbsp;&nbsp;&nbsp; //client.loop needs to run every iteration.&nbsp; Previous version did not.&nbsp; Big opps.<br> &nbsp; //&nbsp;&nbsp;&nbsp; client.loop();<br> &nbsp; //&nbsp; }<br> &nbsp; //Serial.println(&quot;Other loop&quot;);<br> &nbsp; if (radio.receiveDone()) {<br> &nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.print('[');<br> &nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.print(radio.SENDERID, DEC);<br> &nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.print(&quot;] &quot;);<br> &nbsp;&nbsp;&nbsp; if (promiscuousMode) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp;&nbsp;&nbsp;&nbsp; Serial.print(&quot;to [&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp;&nbsp;&nbsp; Serial.print(radio.TARGETID, DEC);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp;&nbsp;&nbsp; Serial.print(&quot;] &quot;);<br> &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.println();<br> <br> &nbsp;&nbsp;&nbsp; if (mydebug) Serial.println(&quot;before checking payload&quot;);<br> <br> &nbsp;&nbsp;&nbsp; if (radio.DATALEN != sizeof(Payload))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(F(&quot;Invalid payload received, not matching Payload struct!&quot;));<br> &nbsp;&nbsp;&nbsp; else {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.println(&quot;payload is valid&quot;);<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //save it for i2c:<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.nodeID = theData.nodeID;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.sensorID = theData.sensorID;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.var1_usl = theData.var1_usl;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.var2_float = theData.var2_float;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.var3_float = theData.var3_float;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SensorNode.var4_int = radio.RSSI;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendMQTT = 1;<br> &nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp; if (radio.ACK_REQUESTED)<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.println(&quot;ACK Requested&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte theNodeID = radio.SENDERID;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; radio.sendACK();<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // When a node requests an ACK, respond to the ACK<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and also send a packet requesting an ACK (every 3rd one only)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ackCount++ % 3 == 0)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Serial.print(&quot; Pinging node &quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Serial.print(theNodeID);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Serial.print(&quot; - ACK...&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //delay(3); //need this when sending right after reception .. ?<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //if (radio.sendWithRetry(theNodeID, &quot;ACK TEST&quot;, 8, 0))&nbsp; // 0 = only 1 attempt, no retries<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Serial.print(&quot;ok!&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //else Serial.print(&quot;nothing&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; }//end if radio.ACK_REQESTED<br> &nbsp; } //end if radio.receive<br> <br> <br> &nbsp; if (sendMQTT == 1)<br> &nbsp; {<br> <br> &nbsp;&nbsp;&nbsp; if (mydebug) Serial.println(&quot;starting MQTT send&quot;);<br> &nbsp;&nbsp;&nbsp; conn_ok = client.connected();<br> &nbsp;&nbsp;&nbsp; if (conn_ok == 1)<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(led, HIGH);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp; Serial.println(&quot;MQTT connected OK from MQTT Send&quot;);<br> &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; else<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(led, LOW);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mydebug)&nbsp;&nbsp; Serial.println(&quot;MQTT NOT connected OK from MQTT Send&quot;);<br> &nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp; //no connection, reconnect<br> &nbsp;&nbsp;&nbsp; if (conn_ok == 0)<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.disconnect();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(5000);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (client.connect(&quot;arduinoClient&quot;) != 1)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(led, LOW);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(&quot;Error connecting to MQTT&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(4000);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(led, HIGH);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(led, HIGH);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(&quot;reconnected to MQTT&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MQTT_reconnect = millis();<br> &nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp; int varnum;<br> &nbsp;&nbsp;&nbsp; char buff_topic[6];<br> &nbsp;&nbsp;&nbsp; char buff_message[12];<br> <br> &nbsp;&nbsp;&nbsp; Serial.println(&quot;******************************&quot;);<br> <br> &nbsp;&nbsp;&nbsp; //send var1_usl<br> &nbsp;&nbsp;&nbsp; varnum = 1;<br> &nbsp;&nbsp;&nbsp; buff_topic[6];<br> &nbsp;&nbsp;&nbsp; buff_message[12];<br> &nbsp;&nbsp;&nbsp; //sprintf creates buff_topic by combining SensorNode.nodeID, SensorNode.sensorID, varnum<br> &nbsp;&nbsp;&nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, SensorNode.nodeID, SensorNode.sensorID, varnum);<br> &nbsp;&nbsp;&nbsp; dtostrf (SensorNode.var1_usl, 10, 1, buff_message);<br> &nbsp;&nbsp;&nbsp; client.publish(buff_topic, buff_message);<br> &nbsp;&nbsp;&nbsp; Serial.println(&quot;Publishing&quot;);<br> <br> &nbsp;&nbsp;&nbsp; decodeBuffTopic(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;buff_topic: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.print(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot; varnum 1: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.println(buff_message);<br> <br> &nbsp;&nbsp;&nbsp; //%02d means format the integer with 2 digits, left padding with zeros<br> &nbsp;&nbsp;&nbsp; //send var2_float<br> &nbsp;&nbsp;&nbsp; varnum = 2;<br> &nbsp;&nbsp;&nbsp; buff_topic[6];<br> &nbsp;&nbsp;&nbsp; buff_message[7];<br> &nbsp;&nbsp;&nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, SensorNode.nodeID, SensorNode.sensorID, varnum);<br> &nbsp;&nbsp;&nbsp; dtostrf (SensorNode.var2_float, 2, 1, buff_message);<br> &nbsp;&nbsp;&nbsp; client.publish(buff_topic, buff_message);<br> <br> &nbsp;&nbsp;&nbsp; decodeBuffTopic(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;buff_topic: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.print(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot; varnum 2: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.println(buff_message);<br> &nbsp;&nbsp;&nbsp; delay(200);<br> <br> &nbsp;&nbsp;&nbsp; //send var3_float<br> &nbsp;&nbsp;&nbsp; varnum = 3;<br> &nbsp;&nbsp;&nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, SensorNode.nodeID, SensorNode.sensorID, varnum);<br> &nbsp;&nbsp;&nbsp; dtostrf (SensorNode.var3_float, 2, 2, buff_message);<br> &nbsp;&nbsp;&nbsp; client.publish(buff_topic, buff_message);<br> &nbsp;&nbsp;&nbsp; decodeBuffTopic(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;buff_topic: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.print(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot; varnum 3: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.println(buff_message);<br> &nbsp;&nbsp;&nbsp; delay(200);<br> <br> &nbsp;&nbsp;&nbsp; //send var4_int, RSSI<br> &nbsp;&nbsp;&nbsp; varnum = 4;<br> &nbsp;&nbsp;&nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, SensorNode.nodeID, SensorNode.sensorID, varnum);<br> &nbsp;&nbsp;&nbsp; sprintf(buff_message, &quot;%04d%&quot;, SensorNode.var4_int);<br> &nbsp;&nbsp;&nbsp; client.publish(buff_topic, buff_message);<br> &nbsp;&nbsp;&nbsp; decodeBuffTopic(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;buff_topic: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.print(buff_topic);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot; varnum 4: &quot;);<br> &nbsp;&nbsp;&nbsp; Serial.println(buff_message);<br> &nbsp;&nbsp;&nbsp; Serial.println(&quot;******************************&quot;);<br> &nbsp;&nbsp;&nbsp; sendMQTT = 0;<br> &nbsp;&nbsp; // Serial.println(&quot;finished MQTT send&quot;);<br> &nbsp; }//end if sendMQTT<br> <br> }//end loop<br> <br> void MQTTSendInt(PubSubClient* _client, int node, int sensor, int var, int val) {<br> &nbsp; char buff_topic[6];<br> &nbsp; char buff_message[7];<br> <br> &nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, node, sensor, var);<br> &nbsp; sprintf(buff_message, &quot;%04d%&quot;, val);<br> &nbsp; _client-&gt;publish(buff_topic, buff_message);<br> }<br> <br> void MQTTSendULong(PubSubClient* _client, int node, int sensor, int var, unsigned long val) {<br> &nbsp; char buff_topic[6];<br> &nbsp; char buff_message[12];<br> <br> &nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, node, sensor, var);<br> &nbsp; sprintf(buff_message, &quot;%u&quot;, val);<br> &nbsp; _client-&gt;publish(buff_topic, buff_message);<br> }<br> <br> void MQTTSendFloat(PubSubClient* _client, int node, int sensor, int var, float val) {<br> &nbsp; char buff_topic[6];<br> &nbsp; char buff_message[12];<br> <br> &nbsp; sprintf(buff_topic, &quot;%02d%01d%01d&quot;, node, sensor, var);<br> &nbsp; dtostrf (val, 2, 1, buff_message);<br> &nbsp; _client-&gt;publish(buff_topic, buff_message);<br> }<br> <br> // Handing of Mosquitto messages<br> void callback(char* topic, byte* payload, unsigned int length) {<br> &nbsp; // handle message arrived<br> &nbsp; Serial.println(F(&quot;Mosquitto Callback&quot;));<br> }<br> <br> void decodeBuffTopic (char mybufftopic[6])<br> {<br> &nbsp; //print the OpenHAB Items value<br> &nbsp; int myInt;<br> &nbsp; myInt = atoi(mybufftopic);<br> <br> &nbsp; if (myInt == 4032)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Garage Distance: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4122)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Mailbox count: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4124)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Mailbox RSSI: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4123)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Mailbox battery: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4022)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Garage light: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4042)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Garage temp: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 4043)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Garage humidity: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 3042)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Dryer: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 3052)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Washer: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 3032)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Water leak: &quot;);<br> &nbsp; }<br> &nbsp; else if (myInt == 3062)<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;Laundry light: &quot;);<br> &nbsp; }<br> &nbsp; else<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;unknown: &quot;);<br> }
    <p>Wow thanks a lot! I will check it on the weekend!</p>
    <p>To be honest, I gave up trying because of this but if you are dedicated to this project you could try separating the RFM69 and the Ethernet shield onto different shields. I am currently trying to do a similar project using Lowpowerlab.com Moteino Framework Gateway (http://lowpowerlab.com/gateway/). It doesn't use OpenHab but has similar functionality. This project uses the LowpowerLab hardware and a RasPi so I'm not sure if it will work with standard Uno hw. There's no need for an ethernet shield in this project.</p><p>If you want to take this conversation off-line you can email me at bruce calder at outlook dot com (no spaces).</p><p>Bruster999</p>
    <p>Hi Bruster</p><p>I checked your code an i have the same problem as you with SPI! How do you solve de problem? I connected the RF69 (433mHz) SS port to pin 8. But i can't get an IP.</p><p>Thanks a lot for your reply<br>Ronald</p>
    <p>Hi, bruster999. Yes this Uber Home Automation is inspiring. The documentation is detailed, but that version has self-admitted limitations, maybe addressed in the comments, but I found all that hard to follow.</p><p> Near the top of Uber..., notice what the author put: </p><p>&quot;[EDIT] I created a forum to collaborate on gateway code. </p><p></p><p><a href="http://homeautomation.proboards.com/board/2/openhab-rfm69-based-arduino" rel="nofollow">http://homeautomation.proboards.com/board/2/openha...</a></p><p> &quot;</p><p>I believe you'll find more reliable info there, including references to CompuTourist's STABLE work on Gateway &amp; nodes which he has provided at</p><p><a href="https://github.com/computourist/RFM69-MQTT-client/archive/master.zip" rel="nofollow">https://github.com/computourist/RFM69-MQTT-client/...</a></p><p>I have provided some detailed documentation on using Buono Uno Arduino compatibles to build a version of CompuTourist's design at</p><p><a href="http://homeautomation.proboards.com/thread/62/success-home-automation-arduinos-rfm69s?page=2" rel="nofollow">http://homeautomation.proboards.com/thread/62/succ...</a></p><p>Besides more recent &amp; reliable information on this project, I believe you'll also find more help (if you supply us with enough info on how you've done things &amp; the results you are getting.)</p><p></p>
    <p>Thanks for the feedback. I'll check out your links. </p><p>I think I have narrowed it down to being a library issue as there are a number of threads out there discussing the same issue. </p>
    <p>Hi there! Thanks for this awesome instructable, so helpful. </p><p>I've been wanting to create a similar home automation/monitoring system using Arduino and RPi on my dad's liveaboard yacht! I hope to monitor, battery levels, fuel and water tanks levels (using a voltmeter to measure the signals from existing dials) and the temperature and humidity. I would also like to be able to control some plugs (store bought remote plugs) and use these to turn on and off fans (cruises around southeast aisa) with temperature and then to turn off power outlets (using relays?) when the batteries are running low. It's all quiet ambitious but I hope with my knowledge of RPis and Python that it is all achievable.</p><p>However, I've never used arduinos before and so your instructable has been incredibly helpful! I'm wondering if I would be able to use an Arduino nano for the sensors? This would make them smaller in size and would help increase battery life of the sensors. If I can, how similar would it be to your sensors (ie, would I still be able to roughly follow your instructions!?? :P) and would they use the same sketches?</p><p>Also not directly about the instructable but maybe you could be able to help, my dad uses an external antenna to gain Mobile Data signal and I was wondering if I could somehow use the SMA connection from this to use as the wifi antenna. Hopefully enabling us to use distant wifi hotspots when in a marina. And in an ideal world, use some sort of splitter and a Pi as a controller to choose to use mobile data for the hotspot (via a Telstra mobile hotspot router attacted via Ethernet to a Pi, creating a hotspot) or when a wifi connection is connected, to use that for all the boat network traffic! Quite aspirational but I have 2 months this summer to install it all! :D</p><p>Thanks again for the tutorial, and for any help you can give me! </p>
    <p>Hi, wanna get started on this project. </p><p>but could arduino nano's be used as nodes? maybe if I wont have as mush sensors attached to each one?</p><p>I already have a rpi with openhab, so just have to get the gateways and nodes up and running.</p>

    About This Instructable




    Bio: I'm a dog owner. I like to make useful gadgets.
    More by electronichamsters:Tweeting Pregnancy TestPhysical Home Automation InterfaceBetter Smarter Mousetrap
    Add instructable to: