loading

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

http://homeautomation.proboards.com/board/2/openha...

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.

    Step 2: Parts List and Initial Prep

    Parts List

    I'll try to point you to the cheapest versions of the components I used, so most of these links will be to good old ebay.


    Once you get the parts, you're pretty much ready to start building. The only mandatory soldering step is for the RFM69HW transceiver. They arrive as a bare chip, and require that you solder 22-gauge hookup wire to the pads. Follow this wiring diagram to solder wires to the RFM69HW and you should get something that looks like the following series of pictures.








    Step 3: Create Arduino gateway and OpenHAB

    Once you have at least two RFM69 chips soldered with wires, we need to make the wireless gateway and setup the Raspberry Pi with OpenHAB. It's basically two Arduinos connected together using I2C. See the wiring diagram above and the instructions below. The communications path looks like this.

    The wireless data is sent from the sensor node to the RFM gateway in the form of a struct. The struct data is then passed from the RFM gateway to the ethernet gateway using I2C (those two pairs of wires on pins A4 & A5). The ethernet gateway takes each individual piece of data from the structure and post it to the MQTT broker. The MQTT broker (Mosquitto) on the Raspberry Pi picks up this sensor data, and sends it to the OpenHAB program also sitting on the same Raspberry Pi.

    Here's what the gateway looks like when you've got 22 gauge hookup wires connecting the two Arduinos. You can see the RFM Gateway Arduino on the bottom. It has the wireless transceiver mounted on it. On the top is the Ethernet Gateway with the ethernet cable connected.







    Create Arduino Gateways

    Components Needed:

    1. Two Arduino Uno Clones with 3.3V/5V switch set to 3.3V.
    2. One Wiznet 5100 ethernet shield
    3. One RFM69HW w/ wires soldered on

    One Arduino will be designated the "RFM Gateway" and the other is the "Ethernet Gateway". On the RFM Gateway Arduino, wire up the RFM69HW like you see in the wiring diagram at the top of this step.

    RFM69HW To Arduino

    • NSS to Pin 10
    • MOSI to Pin 11
    • MISO to Pin 12
    • SCK to Pin 13
    • GND to Ground
    • 3.3V to the 3.3V header
    • DI00 to Pin 2 (interrupt)

    Plug the ethernet shield on the "Ethernet Gateway". Hook together these two gateway Arduinos for I2C using male-male dupont cables, or just hookup wire if you have some around:

    • Ground to Ground
    • Analog Pin 4 to Analog Pin 4
    • Analog Pin 5 to Analog Pin 5

    Download the two gateway Arduino sketches above.


    Prepare The Host Computer

    Next, we need to install OpenHAB on the host computer. The host computer in my case is a Raspberry Pi. It's nice to use the Pi or similar single board computer because of the low power consumption. But if you'd rather use a Windows or Apple computer, that's fine too. OpenHAB works on all of those machines.

    Follow the wiki article on the OpenHAB site to install it on a Raspberry Pi or PC/Mac.

    https://github.com/openhab/openhab/wiki/Quick-Setup-an-openHAB-Server

    And the final thing we need on the host computer is to install the MQTT broker called "Mosquitto". If using Raspberry Pi running Raspbian, use apt-get like this:

    sudo apt-get install mosquitto mosquitto-clients python-mosquitto

    If you're not using a Raspberry Pi as the server, download the Mosquitto install for a Windows or Mac. It's very easy to say in a tutorial "install this". But let's face it, for new Linux users, there will be problems that aren't covered in the tutorials. Just being honest here. Things like permissions (sudo), start up issues (chmod on the init.d file), or just transferring files to the Raspberry Pi ("mount" USB drive). Just don't expect to be able to finish the installation quickly if you're new to Linux, and be prepare to google. Feel free to ask questions in the comments, I know how frustrating Linux can be. If all else fails, there's always the option of using the Windows version of OpenHAB and Mosquitto. The great thing about OpenHAB is that the operating system doesn't matter - you can start on Windows and move to Linux at a later date and all the configuration files can just be moved over and it'll work.

    Once you've gotten this far, you can move on to creating the individual sensors. Each of the next steps of the tutorial covers a single sensor, so you can jump around to the sensor you want to build.

    Step 4: Garage Door Monitor

    Use this ultrasonic sensor setup to do things like tell if a garage door is closed, or if there is a car in a spot. Basically, anything you can sense with a distance sensor. The sensor is reading the distance from the sensor to the object in front of the sensor. It then sends that distance data wirelessly to the gateway and that data is processed by OpenHAB to evaluate to "open" or "closed".

    The ultrasonic distance sensors can be found on ebay for about $3 each. Hook it up according to the wiring diagram above. See youtube video for how it works.

    Install it above the garage door when the door is opened. My installation looks like this.


    The two files attached to this step are the Arduino sketch for the garage door monitor and the OpenHAB configuration file. The Arduino sketch includes code for a temperature/humidity as well as a light sensor, but you don't have to use it if you don't want to. The sketch will work without the sensor. More details on the light sensor and temperature/humidity sensor later on in the Uber sensor section.

    Step 5: Battery Powered Reed Switch - Door / Window / Drawer / Mailbox Sensor

    This battery-powered wireless Arduino sensor can be used in a number of ways - pretty much anywhere a magnet could be attached to a moving part. It can be used as a security sensor by enabling the audio alarming and email notification, or maybe you simply want to see the window/door status on your smart phone.

    Here's the basics of how this battery powered unit works. You can mount it under your mailbox to get notification when the mailbox gets opened.


    You can also mount it on top of a door or window like this. This one has been mounted on the side door to my garage for a while.


    Here's two youtube videos that show you how this can be used for notification and security. The first one shows how to use this to be notified when a door is opened/closed. I neglected to include in the video a clip of the Raspberry Pi playing an alarm sound. But any event can be associated with a unique MP3 file, so you can play a loud audio alarm as a deterrent, just like a real burglar system.

    This video was from a previous Instructable I made of a mailbox notifier. It's here only for completeness and to show how flexible the system is.

    To build this sensor, follow this stripboard wiring diagram.

    (1) A blank ATMEGA328P-PU
    (1) HopeRF RFM69HW 915MHz transceiver (North America) Use this 868MHz version for Europe / Asia
    (1) screw terminalfor battery connection
    (2) 1MOhm resistor for voltage divider and pull down resistor on reed switch
    (3) 0.1uF ceramic capacitor for voltage divider , and supply capacitors
    (1) 10uF tantalum capacitor(for output)
    (1) Oscillator: 8MHz oscillator preferred
    (2) 22pF capacitors for oscillator
    (1) one LED, I used red
    (1) 220 ohm resistor for current limiting LED
    (1) 10k ohm pull-up resistor for reset line
    (1) Reed switch
    (1) strip board about 3x6 inch
    (1) 28 Pin socket to mount the ATMEGA328 on
    (1) AA battery box, could be 3xAA or 4xAA

    If you're new to Arduino, I recommend some research on how to make a bread-board Arduino, since this is what it is. Do a search on putting Arduino onto a bare bones ATMEGA328P-PU. Notice that the Arduino is running on the Pro/Mini 8MHz bootloader in my build. You can use either 8MHz or 16MHz, but 8MHz conforms to the Atmel specification for 3.3V operation.

    The two files attached are the mailbox Arduino sketch and the OpenHAB configuration file. You'll have to download the Arduino sketch onto the ATMega microcontroller. Follow along with the OpenHAB configuration file to make the necessary changes on the Raspberry Pi (or PC/Mac if you're using a computer instead).

    On the Raspberry Pi (or PC/Mac), place the MP3 file for the audio under the folder for any audio alert you want to play. Look for this code snippet in the configuration file.

    rule "send email and talk"
    when
    Item itm_mailbox changed from OFF to ON
    then
    playSound("aolmail.mp3")
    sendMail("myemailaddress@gmail.com", "subject line here" , "email body text")
    end

    I had a hard time measuring the battery current consumption. My general use Radio Shack multimeter might not be able to measure small amounts of current very reliably. I think it consumes about 0.1mA in sleep mode. Since the microcontroller sleeps most of the time and only wakes up to transmit when the door opens or closes, I estimate a 4xAA battery pack will last 1.5 years. The one I have mounted over the side door to the garage has been there for about a month, so time will tell.



    Step 6: Uber Sensor - General Build Instructions

    Here's a video demonstration of each element in the Uber Sensor. I'm not great with youtube, so please excuse the amateur effort here. Hopefully it's enough to show you what the setup is capable of.


    I combined several sensors into this wireless Uber Sensor node. This sensor is powered via USB adapter, but it communicates wirelessly to the gateway, so you can place this where ever it has access to a power outlet. And you don't have to build the whole thing, you can pick and choose which sensors you actually want.

    • Bark / Noise Sensor: Pretty sensitive when pointed in the right direction, and includes a sensitivity pot for adjustment. I'm using it to notify me if the dog barks. The system emails me when sound sensor goes off, as well as turning on an indicator on the OpenHAB display.
    • Temperature / Humidity: Displays the temperature and humidity on the smart phone interface.
    • PIR Presence Sensor: Used as a security sensor to email you when movement is detected.
    • Smoke / Gas: Detects explosive gas (propane, methane, natural gas), as well as smoke. Sends an email notification when these are present.
    • Flame Sensor: Detects a flame, and sends email notification.
    • Light Sensor: For detecting if a room light is left on

    This single sensor node covers about half of the home automation sensors I set out at the beginning.

    The OpenHAB user interface looks like this. You use your smartphone to access the user interface, where you can enable email notifications and alarming for the sensors you want. Once the alarm is enabled, you'll get an email the moment that sensor detects something.

    Let's say you had the dog bark alarm enabled, and your dog barks. You'll get ONE email notification of that event, and the alarm status for "bark" will light up. You will not receive more email if your dog keeps barking. You can use your smart phone to acknowledge the alarm by hitting the "off" button next to the alarm status. It's only if your dog barks again after this manual acknowledgment that you'll receive an additional email notification for barking.

    You can use whatever container you want for the sensor. I used a cheap food container and poked holes through it for the sensors.

    The next six steps of the Instructable cover the hardware wiring of each of these sensors and some tips for using each sensor.

    The two files attached above are the OpenHAB configuration file and the Arduino sketch for the Uber sensor. For the Arduino sketch, you can use the code as is even if you don't use all the sensors. You just won't get valid data for the sensors you don't wire up.

    Step 7: Uber Sensor - Security / Area Presence Sensor

    This Arduino sensor can be used as a security sensor for detecting intrusion, or as part of the home automation system to sense when a room is occupied. The idea is to use your smart phone to enable the alarm notification when you're out of the house. Then, if the sensor gets tripped, you'll get an email, as well as an indicator on your OpenHAB smart phone app.

    The PIR (passive infrared) sensor costs less than $3 each from everyone's favorite online sensor store, ebay. Just do a search for PIR sensor and look for something that resembles the pictures here. Note that the sensors have a sensitivity pot and a hold-time pot. The hold time isn't very important for our use, but you should adjust the sensitivity to something reasonable. You can set the sensor to ignore a dog in a kennel for example, but still catch an intruder. If you have a free-range dog or cat, it's a bit trickier to set the sensitivity. You can use black electrical tape to cover up part of the globe if you want to narrow down the monitoring area.

    Like the rest of the Uber sensors, the programming (Arduino sketch and OpenHAB config) is in Step 6.





    Step 8: Uber Sensor - Dog Bark / Noise Sensor

    I'm using the sound sensor to send me email notifications if my dog barks. But this can easily be used for other purposes - like monitoring if an alarm is going off inside the house. The sensitivity of the sensor is easily adjustable.

    The sound sensors can be found on ebay for about $3 each. There's not really a model number for the sensor, just look for one with a pot for you to adjust the sensitivity. When it's hooked up, there's a red LED that turns on when you speak loudly into the microphone, indicating that the sensor output is high. If the LED is on even when the sensor is in total silence, adjust the pot until it turns off. Then make some noise to see how loud a sound level is needed to make the LED turn on.

    Like the rest of the Uber sensors, the programming (Arduino sketch and OpenHAB config) is in Step 6.

    If you use this as a bark sensor rather than a sound sensor, it might be nice to add a counter to get a gauge of how much the dog is barking. Here's the code for adding this counter. You'll want to add this counter code to the configuration provided for the Uber Sensor in Step 6. The rule resets the counter when the bark alarm is turned off. When it's turned on, the bark counter will increment as the dog barks. It's not quite a super accurate count because the sound sensor only sends updates every 20 seconds. So, interpret this counter to mean "how many times did the dog bark in 20-second intervals".




    Item Definition

    Number itm_uber1_bark_cnt "Bark count [%.0f]"

    Sitemap
    Frame label="Uber Sensor Alarm Status" {
    Switch item=itm_uber1_gas_alm_sta mappings=[OFF="Off"]
    Switch item=itm_uber1_flame_alm_sta mappings=[OFF="Off"]
    Switch item=itm_uber1_bark_alm_sta mappings=[OFF="Off"]
    Text item=itm_uber1_bark_cnt
    Switch item=itm_uber1_pir_alm_sta mappings=[OFF="Off"]
    
    Rule
    //place this at be top of the rules file
    var Number bark_counter = 0
    
    
    //rules for bark sensor
    rule "Uber bark threshold"
    when
    Item itm_uber1_bark_mqtt received update
    then
    if(itm_uber1_bark_alm_enb.state == ON)
    {
    sendCommand(itm_uber1_bark_alm_sta, ON)
    bark_counter = bark_counter + 1
    itm_uber1_bark_cnt.postUpdate(bark_counter.toString)
    }
    end
    
    rule "Uber bark response"
    when
    Item itm_uber1_bark_alm_sta changed from OFF to ON
    then
    sendMail("ArduinoHomeAutomationOpenHAB@gmail.com", "bark detected" , "dog barked!!!")
    //playSound("ding.mp3")
    postUpdate(itm_uber1_bark_time, new DateTimeType())
    end
    
    rule "deactivate bark sensor"
    when
    Item itm_uber1_bark_alm_enb received update
    then
    bark_counter = 0
    itm_uber1_bark_cnt.postUpdate(bark_counter.toString)
    end
    

    Here's how it looks assembled, followed by the video demo.


    Step 9: Uber Sensor - Light Sensor

    Above is the wiring diagram for the light sensor. The resistor is a 10k Ohm resistor. Search online for "photo resistor". The photo-resistor is a very common components, and you can usually get a pack of ten for just a couple bucks. When putting this together, the photo-resistor tends to fall out of the dupont cables. It helps to put a few bends into the wire before inserting them.

    In the OpenHAB configuration, look for this line:

    if(itm_uber1_light_mqtt.state < 350)

    Adjust this number to change the sensitivity of the sensor to your needs.

    Refer to Step 6 for the Arduino code and OpenHAB configuration.



    Youtube video demonstration


    Step 10: Uber Sensor - Temperature / Humidity

    The temperature/humidity sensor I'm using is a digital sensor, model number DHT11. It's a common sensor, and costs about $3. It's usually blue. There is a slightly more accurate version of the sensor, the DHT22, that's usually white. If you want to use that one instead, make sure you uncomment the define statement found in the Uber Sensor Arduino sketch.


    //#define DHTTYPE DHT11
    #define DHTTYPE DHT21
    

    Other than that caveat, this sensor is pretty easy to set up. Wire up like the diagram above, using a 10k resistor. Just like all the other sensors, simply download the UberSensor Arduino sketch and it should work.

    The Uber sketch updates the sensor data every 6 minutes (360000 ms). You can edit this update rate by changing this line.


    if (time_passed > 360000)
    {
    float h = dht.readHumidity();
    // Read temperature as Celsius
    float t = dht.readTemperature();
    .....
    

    Here's the sensor to look for.

    .



    Step 11: Uber Sensor - Flame Sensor

    Safety Note: This sensor is not meant to replace local fire code mandated fire protection.

    There's nothing tricky about this sensor. There's no model number for the flame sensor, but if you search on online for "flame sensor", you'll see lots of buying options. Each flame sensor should cost about $3 each, and look like this. I'm using the analog output of the sensor to register a flame, so the pot is irrelevant. That's why the digital output pin is not used in the wiring diagram.

    Similar setup as all the other Uber sensors. Wire according to the diagram above, and download the UberSensor.ino sketch. When you get to setting up the OpenHAB configuration on the Raspberry Pi, you can adjust the analog value that constitutes flame.


     if((itm_uber1_flame_mqtt.state < 900) && (itm_uber1_flame_alm_enb.state == ON))
    {
    sendCommand(itm_uber1_flame_alm_sta, ON)
    }
    

    If you're trying to use this in a kitchen you may need to adjust the sensitivity. I've found that a fairly large flame is required to set these off...so they're not for early detection.

    Sensor sitting in box:

    Step 12: Uber Sensor - Smoke / Flammable Gas

    Safety Note: This sensor is not meant to replace local fire code mandated fire protection.

    I'm using a MQ2 sensor to detect smoke and flammable gas like propane, methane, and natural gas from cooking stove. You can find it online for about $5. It uses a heating element inside as part of the detection sensor, so it'll feel very warm when in use. Look for a sensor that has the analog circuity built in, like this picture.


    Just like all the other Uber sensors, download the Arduino sketch and follow the OpenHAB configuration file.

    The sensor is pretty sensitive. You can adjust the analog value that constitutes a detection alarm by changing this line in the OpenHAB configuration:


    if((itm_uber1_gas_mqtt.state > 220) && (itm_uber1_gas_alm_enb.state == ON))
    {
    sendCommand(itm_uber1_gas_alm_sta, ON)
    }
    

    I've found the value "220" was good enough to not get any false alarms.


    Youtube video demonstration.

    Step 13: Washer-Dryer Smartifier & Water Leak Sensor


    These nice Victorian gentlemen will show you how they're using the Laundry Sensor.



    If your house is like mine, you have the laundry room in the basement. When I was single, I only went down to the basement once a week, so problems went unnoticed. Forgetting a load of wet laundry was really disgusting. The laundry room light sometimes got left on the entire week. And I couldn't tell if the washer/dryer was still running without going down stairs. Only the dryer buzzes, and sometimes I'd miss it. Now that we have a baby, we're doing laundry every other day it seems, so it'd be nice to have a dashboard view to tell us if the washer/dryer is running. And instead of having a dryer buzzer down stairs, I wanted the audible signal for both washer and dryer up stairs. This sensor is designed to solve all of these problems.

    The schematic above is a great combination of sensors for a laundry room.

    • Sound Sensor determines when washer or dryer cycle starts and completes
    • PIR Presence Sensor used to determine when a completed load is picked up
    • Water Detection circuit senses if there is a water leak or overflow, or a flood in the basement.
    • light sensor circuit from the Uber sensor is used to determine if the laundry room light is left on.
    • Temperature/Humidity sensor - because it's so cheap to add another sensor

    The intention is to display the washer and dryer status on a smart phone or tablet in the kitchen or living room - somewhere that you can easily glance at. Similarly, the Raspberry Pi and speaker would also be sitting in the living room so that the audio announcements are more likely to be heard. The audio signal for washer completion or dryer completion can be a friendly sounding MP3 file. Heck, you can record your own voice saying "get the laundry!" and use that sound file if you want. In the demo, I used the ugly robot voice to say "washer complete" or "dryer complete" because the text to voice feature is available by default in any OpenHAB installation.

    The PIR sensor should be positioned so that the sensor would naturally sense you as you're moving around getting the clothes out of the machine. My awkwardness in live video doesn't demonstrate this point well, and I was trying to not set off the sensor prematurely. You shouldn't have to purposely wave your hand at the sensor.

    If your laundry room is in the main part of the house where people walk through, the PIR sensor would not work for you as a way of indicating the load has been picked up. You can replace the PIR sensor with individual magnet and reed switches on the washer and dryer doors. It's a simple substitution, so I won't detail the circuit. With the reed switch wires going to the washer/dryer door, the installation is a bit more invasive, but it has the benefit of being a more positive indicator of laundry pickup.

    --Hardware--

    I split up the schematic into two for clarity, but my demo actually has both circuits and the light sensor circuit from the Uber sensor all integrated into one wireless Laundry Room sensor. The attached Arduino sketch will work regardless of whether or not you include the optional light and temperature sensor.

    By now, you'll have already gotten the pattern for these sensors. Assemble the sensor on the Arduino using the schematic and the photos. Download the sketch to the Arduino. Configure the OpenHAB using the configuration text file attached. Test.

    The water probe can just be wires coming from the prototype shield. You can use any long wire needed to reach from the sensor assembly to the floor of the laundry room. I stripped ethernet cables and made use of the inner conductor pairs. My assembly looks like this. Amazed I actually remember to take progress photos this time.




    Assemble the sensor into a tupperware container. I used a screw to hold the ends of the water sensor probe apart. The weight also helped keep the probes on the ground.








    Once the circuit has been assembled, you have to calibrate the sound sensor pot. This is pretty easy to do. Adjust the pot until the sensitivity is such that placing the sensor against the dryer or washer (while running) sets off the output LED. This youtube video demonstrates what it should look like.

    --Software--

    The OpenHAB screen looks like this. It will indicate whether the machine is off, running, or finished running (but hasn't been emptied). Once the machine has been emptied (an assumption made by the PIR sensor), the state of the machine returns to off.


    The OpenHAB configuration file needed to create this page is attached.

    If you have the alarm notifier enabled, a water leak alarm will email you when it goes off. A water leak alarm will also constantly sound the alarm sound.

    You will want to edit the Arduino code a little bit depending on your washer or dryer. I put in some constants to decide how many noise detections indicate the machine is running, and how it determines the machine stopped running, and also how frequent to examine the sound sensor. For the majority of dryers this should work. But your washer has some cycles where it's adding water which may not set off the sensor as consistently, so you may want to extend the time or reduce the counts for the washer. Download the .ino file and change the relevant lines of code:

      if ((millis() - sound_time_1)>500)
      {
        sound_time_1 = millis();    //reset sound_time_1 to wait for next Xms
    ...
    


      //after X number of sound checks...
      if (sound_count_1 >= 40)
      {
        //sound_count_1 = number of times sensor listened
    


    if ((sound_detected_count_1 >= 8) && ((sound_1_device_state == 0) || (sound_1_device_state == 2)))  //number of times sensor registered sound
        {
    

    Whew, that should do it for this sensor.

    Step 14: Charts! Visualize your data.

    Charts are really easy to do. You can add charts for any data you have coming in, even digital data (like garage door open/close). It makes the most sense for analog data like temperatures and energy consumption. Do the following to add charts to your sitemap.

    1. From the OpenHAB website, download and unzip the addon files:

      http://www.openhab.org/downloads.html

    2. Grab the file name "persistence.rrd4j-1.5.0.jar" and put it into the folder.
    3. Open up the <

      \OpenHAB15\configurations\openhab.cfg> file, and add "rrd4j" to the end of this line, like this:

      persistence:default=rrd4j

    Now we need to tell OpenHAB which data items we want to collect data on and how often. Create a file name "rrd4j.persist" in the folder <\OpenHAB\configurations\persistence>. Add the following configuration text to that file. I've included my copy of rrd4j.persist if you'd rather use that.


    // persistence strategies have a name and a definition and are referred to in the "Items" section
    Strategies {
    	// for rrd charts, we need a cron strategy
    	everyMinute : "0 * * * * ?"
    }
    
    Items {
    
      //list the items you want to trend and store
      itm_garage_temp : strategy = everyChange, everyMinute
    }
    

    Now we just need to decide what page we want to add the chart to. Going to the sitemap file, pick any location you want (you can experiment, no big deal), and add this line to .

    Frame label="Charts"
    {
    	//change period to 4h for 4 hours, D for 1 day, 3D for 3 days, W for 1 Week, 3W for 3 weeks...
    	Chart item=itm_garage_temp period=h  refresh=10000
    }
    

    For any other data item you want to chart, just add that item into the rrd4j.persist file, and put it in the sitemap in the same way.

    .

    Step 15: Dog Tracker


    Video



    This last example will be different from all the other sensor projects so far. I’ve been kicking around this dog tracker idea for a while. Recently, there was an “Internet of Things Hack Day” competition held by the local Arduino group here in the Twin Cities (Minnesota, USA). I took this opportunity to form a team to work on this dog tracker idea. This is what my teammates (Wolf Loescher, Russ Terrell, and Patrick Delaney) and I managed to make on competition day.


    I’m presenting this idea mainly to highlight how flexible Arduino and DIY automation can be. You can make your own niche sensor. The prototype we made is fully functional, but the electronics needs to be shrunk down in order for it to be worn on the dog. I hope to keep working on it when I have more time. For now, I’ll just post the code and video demo without the fancy wiring diagram found in previous steps. You can pretty much figure out the wiring diagram from the Arduino sketch, so I hope that’s ok.


    Motivation
    Lots of people let their dog out to poop in the morning. It’s tempting to just let them out the yard by themselves and give them time to sniff around while you stay warm and cozy inside and finish your coffee. But there’s two problems with that.

    1. The dog might run away (if you don’t have a fenced yard).
    2. You don’t know if they poop, or where they poop, and end up spending more time looking for the poop. Neglecting to pick up the poop is NOT an option!


    This dog wearables project aims to solve these problems. As seen in the diagram, the idea is to have a dog wear a collar box. The collar box contains a GPS module, tilt switch, and a RFM69 transceiver.

    Dog Escape Alarm and Tracking
    The GPS location is constantly being sent from the dog unit to the OpenHAB Raspberry Pi at home, via the same gateway previously detailed. The moment the GPS signal strays beyond a virtual boundary defined in OpenHAB, the Raspberry Pi speakers play an audible alarm to alert the dog owner they need to go out and fetch the dog. The owner can look at the OpenHAB screen to see a google map of where their dog currently is (or at least the last GPS signal received). Armed with the initial direction the dog went, he can then use a handheld unit to locate the dog outside. With the great range of the RFM69, the system should be able to locate the dog more than 900 feet away with the hand-held unit, or 700 feet with building obstruction. The range is good enough to be very helpful when locating a lost dog, even if you have no clue where it might have gone. You can drive around waiting for a ping from the handheld unit.




    Actually, even without the Arduino hand-held unit, as long as your dog isn’t hell bent on running away, you’ll probably be able to find him just from the google map shown on the OpenHAB screen. You can use your smart phone OpenHAB app, connected to the home OpenHAB server, and see in real time where your dog is wondering off to as you go after him. With such good range, you’re likely to catch him before he goes too far.

    Dog Poop Tracking
    The system also tells you when your dog poops, and shows a google map of where the poop is. We use the tilt switch signal to tell us when the dog is holding the “poop” position for several seconds. When this happens, the dog Arduino flags a GPS location. The OpenHAB Raspberry Pi plays an audio alert to let you know that the dog has done its business. You then check the map to see where to pick up the poop. The timestamp is there to tell other family members later in the day whether the poop location is current or from the morning bathroom break, in case they miss the audio alert. Family members can use the alarm “OFF” button to clear the alarm and indicate to other family members that this morning’s poop has been picked up.




    We’re also using the built-in temperature sensor in the RFM69 to get the ambient temperature of the dog unit. We can send audio alerts if the environment gets too hot or cold. For all of these audio alerts, it’s trivial to also add in email alerts, as seen in the other project examples.

    The following demo video is taken in front of my house. Here’s what to look for in the video and screen shots. I wanted to demonstrate the accuracy of the GPS unit. It seems to be good to within 5 feet. I’m able to set the unit at the end of my driveway, right on the grass line. The GPS map shows that location almost exactly. I purposely chose the light post as the poop location to give a sense of how accurate the GPS module is. Pretty impressive for a $15 device.





    This is the dog unit placed at the end of the driveway, right on the grass line.


    GPS track of me walking around the yard.


    Video


    Unresolved Issues
    We originally planned on putting a magnetometer in both the dog unit and the person unit. Unfortunately, the magnetometer library we wanted to use didn’t play nice with the RFM library. So we had to just skip that functionality. It would’ve been cool to get that working. The OpenHAB was setup to record and chart the direction the dog was facing each time it poops, so that we can determine whether or not dogs really face North when they go.

    ...

    Step 16: Not So Uber


    Perhaps "uber" is too bombastic a title. No project is perfect. Here's the list of deficiencies, from the most to the least glaring. I hope to address these some day.



    1) The Dual-Gateway Dumpling Conjecture

    The RFM and Ethernet Arduino gateways should be able to be combined into one Arduino. When I was making the gateway, I had some poorly soldered transceivers and lead to making me think there was a library conflict. I haven't gone back to fix the problem...because I've been too busy working on this Instructable :). It is sloppy claptrap programming on my part. [EDIT] Thanks to Alexandre Bouillot for taking the two gateways and combining them. I haven't had time to try it out myself, but if you're interested, here's his Github


    2) The RFM-RaspberryPi Integration Hypothesis

    There is a Python port in the works for the RFM69 by a coder name Eric Trombly. I haven't tried it yet. If it works, it means you can skip the Arduino gateways altogether. I would be very interested if someone does try it. His Github: https://github.com/etrombly.

    Of course, that jerk chose to start his project after I went through the trouble of making the gateways. Darn him!


    3) The Uni-Directional Communications Field Problem

    I don't actually talk to my field nodes - the field node to base communication is single-direction only. All of my sensor demos can be done with uni-directional wireless comms, but admittedly bi-directional communications would be more efficient for the security sensors. There's no technical reason why the RFM gateway can't talk to the RFM nodes...other than it requires a more thoughtful approach to the communication scheme...you know, the actual difficult part.


    4) The Lack-Of-Ack Conundrum

    I also don't acknowledge the wireless transmissions from the field nodes. No reason why not to ack, since it's actually built into the RFM69 library, and not acknowledging actually wastes wireless transmissions because I transmit-with-retry on most nodes. It would make the sensors more robust. The fix would require a bit more code on the transmitter end, but shouldn't be too bad.

    If someone wants to improve on the gateway, please fork my Github! I would welcome the improvements. That said, I've had the garage door monitor for months, and the battery powered security door since mid-August, and both have been working great. The system works well for the current group of sensors I've made.

    Step 17: What is Home Automation?

    This is just the beginning of home automation. A truly uber home automation system should have available many different types of inputs, and be able to affect many types of outputs. OpenHAB is the logic engine that connects inputs (situations) to outputs (actions).


    --Inputs--
    OpenHAB natively supports a set of commercially available sensors. The goal of this Instructable has been to dramatically enhance this set of inputs by giving Arduino users a way to integrate DIY wireless sensor nodes into the system.


    --Outputs--
    OpenHAB also natively supports control of many different types of commercial products (outputs like lights and thermostats). I want to enhance this set of outputs with a series of Instructables for using Arduino to do physical computing. The first of these is this basic relay actuator, from which users can open and close garage doors or operate remote outlets.

    Step 18: Conclusion

    I tried as much as possible to make this tutorial accessible to most people. This isn't one of those projects that require a 3D printer, a CNC machine, and hundreds of dollars. Nor is it a project that makes use of one-off items that others can't replicate. It's totally achievable. I've tried to point out workable alternatives to some of the more technically difficult portions. I think Arduino users would have no problems making the wall-powered wireless sensors work. For the few places you might get hung up, here's what you can do.

    • Linux. The Raspberry Pi is a good, cheap, lower powered option for the web server. But if you don't want to use Linux and just want to get this home automation project off the ground, no problem! Both OpenHAB and Mosquitto can be installed on a PC or Mac. So the host machine doesn't have to be a Raspberry Pi. The configuration files work on any OS without change.
    • Soldering. It takes me quite a while to solder the battery-powered Arduino sensor. If you want to get started quickly, just stick with the wall-powered Arduino sensors first. You'll still have to solder wires to the wireless transceiver, but that part is pretty doable. For a battery-powered option, you can also use an Anarduino wireless mini (Mini-WirelessHW-915Mhz) or a Low Power Lab's Moteino. These are basically Arduinos with the transceiver built in. The sketches in this Instructable can be downloaded as is.
    • Serial monitor is your friend! On the Arduino sketches, I kept the useful troubleshooting printout statements in the code. If you're having trouble, just connect the sensor node Arduino to your computer and view the output on the Arduino serial monitor.
    • Not interested in the wireless setup? Here's a simplified wired ethernet version.

    This project has taught me a lot. At first, I just wanted to solve the practical problem of monitoring my dog. Then it became "hey look at all these other sensors I can use". In the end, it made me think more deeply about connected devices and how to meaningfully present all the information coming from DIY "internet of things".

    I can take credit (and blame) for the Arduino sketches that form the gateways for this project. As far as I know, no one has published a way for translating RFM69 wireless data into something that OpenHAB understands. All the rest of the software in this project are open source software. Thanks to OpenHAB, Mosquitto, and Low Power Lab for making their projects available. Open hardware and open software do amazing things.

    Also, thanks to Instructable member makendo.

    Any questions, feel free to ask it in the comments.





    The following wall of text is placed at the end so I don't put off anyone interested in making this setup. This is optional reading. I'm not going to tell you when the zombie apocalypse will happen, and really don't have anything new to say. I just want to provide some context for Arduino based home automation systems. Here's some stuff that I've learned.

    • Wireless transceiver selection is pretty important. I did quite a bit of testing with nRF24L01's before deciding that RFM69's are better. It was a hard decision because everyone and their grandma uses nRF24's.
    • There are a lot of Arduino users out there like me. I came across many forum posts of people discussing how to do wireless Arduino sensors and how to build the web server and associated mobile app. Those two design problems appeared over and over again, and they're my major motivation for making this instructable.
    • Writing your own server is hard. A few Arduino smart home examples I came across involved writing your own node.js application, doing socket.io connection between the mobile browser and the server, doing basic_auth, and then interfacing the node app with an Arduino. That required way too much hard programming and difficult socket setup. I opted to go the OpenHAB route. Experienced programmers put time and effort into making OpenHAB. There's no need for every Arduino user to start from scratch. We can just stick with the easy Arduino programming.
    • It might not be obvious, but OpenHAB was not developed to talk to Arduinos. It was developed as the brains to control commercial products like Sonos speakers, Insteon lights and outlets, Phillips Hue (super fancy lights), Withings health gadgets, and a bunch of other things. Over time, people wrote "bindings", or plugins, to make OpenHAB more flexible. When I found OpenHAB, I liked the interface and the capabilities, but there was no good way for it to talk to wireless Arduino nodes. It took some time to figure out how to use OpenHAB's MQTT binding and come up with a scheme to translate the wireless data into MQTT data. So that's how my Arduino gateways came about. To be honest, it's not perfect, nor is it sophisticated. But it works well for what I'm doing. One of the commenters told me he is using this setup, so that's nice to hear.
    • Gateways are dry stuff to have to explain, but they enable all kinds of awesome sensors to talk to OpenHAB. I started this instructable with lots of details on how the gateway works, but it seem out of place here. I ended up taking the less functional paragraphs out. If you want to dig into the weeds of how it works, check out this blog post
    • There are other systems like OpenHAB out there. Some with fewer capabilities, and some with different set of capabilities. I'm really happy with OpenHAB. Part of the challenge with DIY home automation is that the field is saturated with many platforms, similar to how commercial home automation is flooded with different brands. It's nice to have options. But it's difficult to know which ones will work for you until you've put in the time to dig into a particular system. It's not like you could just google "home automation platform" and simply pick one from the list. Deciding on OpenHAB represents a large chunk of time spent on research and testing.
    • Commercial home automation products have their place. Check out the cool video demos of Kai, the OpenHAB founder, controlling Phillips Hue lights and plant watering systems. I can't make something as fancy as the Phillips Hue bulb. And I don't want to make a DIY remote control outlet. For "outputs" that use high voltage, commercial solutions are more appropriate; they're compact, aesthetically pleasing, and most importantly UL approved. I wish I had Hue bulbs or Sonos speakers to combine with my house of sensors to do some cool automation/notification. It would really show off OpenHAB.
    • Outputs are difficult to DIY, but inputs (sensors) are not. With low voltage sensors, Arduino users have a unique advantage. We can make all sorts of crazy sensors to fit niche sensing situations that aren't common enough to spawn commercial products. Maybe you want to chart how often your dog's tail is up vs. down? Or you want a google map of where your dog poops? It's hard to imagine a company would make a sensor for that and sell it for $30 at retail. I also think it's satisfying to make sensors that mimic what's commercially available. It's like going to Lowe's webpage for Iris products and clicking "I Made It!"
    • Speaking of commercially available home automation systems, I think it would be cool if a company offers a desktop size model house with their smart home system. The model house would be something that the consumer custom designs online to look like their own house. It would be 3D printed, and come with servos, LEDs, and working doors and windows. The (Arduino?) controller for this model house would mimic the door, window, and light sensors that come with the home automation system. So when the real garage door opens, the model house's garage door also opens. When the garage light is turned on, the LED on the model house's garage also lights up. And maybe the house would have avatars, via OLED displays, that turn on when a family member is home. Maybe this model house can sit at your desk at work, mimicking your house miles away via VPN connection. Or if you're a mid-westerner with a cabin "up north", it could act as the security and status display for a cabin that's a hundred miles away. Seeing a video feed or a virtual dashboard on your phone is nice...but being able to look up from your chair and "see" what happening miles away on a physical three dimensional object - that would be really neat. It would be a cool 3D printer project.




    Thanks for reading the whole thing :)

    Step 19: Year and a half later...

    Hey, so it's been a year and a half since I wrote about this project. In that time, there's been lots of changes in the world of wireless development boards. Wi-Fi has become a lot cheaper and easier. You might want to consider using the Particle Photon ($20) or the ESP8266 ($6). Or maybe even Bluetooth for low power applications. For long range wireless applications, you might try LoRa.

    A lot of the sensor ideas and OpenHAB configuration detailed in this post can still be used, but there are easier wireless solutions out there.

    <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>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>You could easily simplify lots of connections using this board: <a href="https://talk2.wisen.com.au/product-talk2-whisper-node-avr/" rel="nofollow">https://talk2.wisen.com.au/product-talk2-whisper-n...</a></p><p>It's an Arduino compatible board with RFM69 and is designed to run on AA batteries.</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>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>Hello Uber , a qestion .I would use a system like yours to build Home Automation , control heating, lights ... My first think was KNX but I am considering a solution like yours.Then the question is : how I can connect sensor and module to arduino considering the distance between the arduino board and the devices controlled ? </p><p>In a knx system we have a certidied twist bus cable but in your images I see just some very thick cables. thanks</p>
    If you have an OpenHAB server (not raspberryPi) that handles all IoT things do you need the gateway? Can the sensor go directly to the MQTT on server?
    <p>hi, i dont have a RFM69HW chip. I want to use this one instead: <a href="https://www.amazon.com/UCEC-XY-MK-5V-Transmitter-Receiver-Raspberry/dp/B017AYH5G0/ref=sr_1_1?ie=UTF8&qid=1476469297&sr=8-1&keywords=rf+433." rel="nofollow">https://www.amazon.com/UCEC-XY-MK-5V-Transmitter-R...</a></p><p>How to cahnge the sketch? 433MhZ communication between 2 Arduinos is working perfect. But i dont know, how to tell my arduino to send the received Data to my ethernet gateway</p>
    thank you very much!<br><br>does anyone have a simple sketch to connect all the sensors to the protoshield?
    <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, 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>Can't get my transcievers to communicate with each other. Any advice?</p>
    <p>I have provided detailed documentation on using Buono Uno Arduino <br>compatibles to build a version of CompuTourist's design AND troubleshooting at</p><p>http://homeautomation.proboards.com/thread/62/success-home-automation-arduinos-rfm69s?page=2</p>
    <p>How can I find the mqtt broke ip address?</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>Can't get my transceivers to communicate. Any suggestions? Could it be because I haven't soldered the wires to the board yet?</p>
    <p>I can't get any communication. Nothing communicates with openhab and I've followed the instructions over and over</p>
    Nice instructable, however I would skip the arduino gateway (i2c to mqtt) and take the i2c directly from the RF gateway to Raspi, then mqtt it.
    <p>Can you tell me how I can find the mqtt broker ip address to place in my arduino code</p>
    <p>having trouble locating the MQTT broker ip address...can someone help me with that? I'm new to automation and brokers</p>
    <p>In the code water sensor is used, but it's not in the parts list. Which water sensor do you recommend? Thanks</p>
    <p>This is all fantastic stuff and right up my alley. I am not only an IT Analyst by trade, but also have been a developer by hobby (as well as some freelancing) for more than a decade..finally I LOVE DIY, so openHAB, Arduino, and RPi are basically a match made in heaven. I just started on an automation learning project, so to speak, and have an android app I built that uses PubNub DSN and python on my RPi to control some 433 outlets in my house. Didn't take me long to get this far, and of course ideas are coming faster than I can get them done. Problem I soon realized, though, was that I wanted to automate things that are not just RF, like WiFi bulbs, light switches etc. So many commercial automation is very closed source and proprietary. Fine for most people, I guess, but not me. So I stumbled upon openHAB and it is great. I look forward to getting started on some of these projects. </p><p>One question for anyone though - I assume I can build my own custom app, or modify the existing one, to better suit my needs and style? (I would share, of course :) ) Thanks!</p><p>Mike</p>
    <p>What is the range on the mailbox sensor? Just curious since I have some distance to get to it everyday so it would be nice to be notified of delivery. Thanks</p>
    <p>Very cool project. Made the mailbox alarm plus a couple of sensors for my garage. OpenHAB was a bit convoluted and not documented as well as I would like but I got it working. Thanks for the great Instructable!</p>

    About This Instructable

    1,159,755views

    4,178favorites

    License:

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