more G-Labs products

Author Topic: MySensors via MQTT  (Read 14605 times)

February 22, 2015, 08:40:58 PM
Read 14605 times

CptJack

  • **
  • Information
  • Jr. Member
  • Posts: 30
Backstory: MySensors is a reliable and cheap network of DIY sensors and actuators which can be produced for a fraction of what traditional HA sensors cost, provided you have a little programming and soldering skill. Here's a quick overview of how I got started with them.

Using the great example already in HG, I've created a way to communicate with the MySensors MQTT gateway. It auto-generates modules for any discovered sensors and stores the values in the appropriate slots. I'm currently only setup for temperature, humidity and light, but additional options can easily be added. I've attached a picture of the resultant module, and the app.

I don't have any actuators in my network, but I have a couple of servos I'd like to turn into shutter closers, so once I get those working, I'll post updated code.
« Last Edit: June 24, 2015, 12:16:15 AM by CptJack »

February 22, 2015, 10:18:10 PM
Reply #1

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
I have 4 shutters in my HVAC system that I control using servo's (just basic servo's, the type they use for RC car/boat/plane). At the moment I control them with an Arduino Mega. The servo's change the air flow from more air to the living area during day time and more air to the master bedroom at night time. Had not thought of hooking these up to HG, sounds like a good plan to go forward.
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

February 26, 2015, 07:07:09 PM
Reply #2

StatX

  • **
  • Information
  • Jr. Member
  • Posts: 30
Hello there,

In the beginning i would like to say that Your project is great!

I have a question You wroted that:
Quote
I'm currently only setup for temperature, humidity and light ...

but on the screenschot i see that there is 4th value is it some kind of signal streanght meter for NRF24L01 modues ?

February 27, 2015, 12:09:58 AM
Reply #3

CptJack

  • **
  • Information
  • Jr. Member
  • Posts: 30
The fourth value is Status.Level, which is automatically updated by HG with the last value sent from the sensor (regardless of the parameter I update). I'm not sure why, and I haven't investigated it very much.

March 19, 2015, 01:48:53 PM
Reply #4

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
What type of devices are you using?  Arduino pro minis for sensors, RPi as mysensor gateway and home genie?  Does RPi have an arduino/nrf2401 attached like Eden board?  I am wanting to move HG off to a RPi because laptop fan are too loud to keep running.  MySensors.org seems to have a cool setup, cheap sensors.

March 24, 2015, 11:53:19 PM
Reply #5

CptJack

  • **
  • Information
  • Jr. Member
  • Posts: 30
Pro Minis for the sensors, but an Uno for the gateway. The gateway runs MQTT which I use to communicate with HG, which could be on a Pi (though I'm on Windows).

June 12, 2015, 08:28:10 AM
Reply #6

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Thanks for this. I built the MQTT gateway yesterday and this morning built a simple Binary switch works perfectly!

June 12, 2015, 07:37:32 PM
Reply #7

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
The fourth value is Status.Level, which is automatically updated by HG with the last value sent from the sensor (regardless of the parameter I update). I'm not sure why, and I haven't investigated it very much.

By removing (or commenting out) the following lines Status.Level won't be shown anymore:
Code: [Select]
        module.Parameter("Status.Level").Value = mpayload;
        Program.RaiseEvent(module, "Status.Level", mpayload, "");

June 13, 2015, 06:30:07 PM
Reply #8

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
Mvdarend, for your MQTT gateway, could you please share some details on which hardware you went with and how your gateway is connected?

It would be interesting to use an RPi as the gateway as well as the HG server, then just one box.  I found some info on connecting the radio to RPi here (http://iot-playground.com/2-uncategorised/3-easyiot-server-installation).

Thanks for this. I built the MQTT gateway yesterday and this morning built a simple Binary switch works perfectly!

June 13, 2015, 06:59:22 PM
Reply #9

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Mvdarend, for your MQTT gateway, could you please share some details on which hardware you went with and how your gateway is connected?


I built the MQTT Gateway as it seemed the safest track for me to take. I'd also come across the info you mentioned, but my experience with electronics is too basic to try that.

June 14, 2015, 01:54:53 AM
Reply #10

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
Did you use an Arduino Nano?  For MQTT, did you connect it (via Ethernet) to your router?

From this post (http://www.homegenie.it/forum/index.php?topic=418.msg4982#msg4982) it seems one can build a serial/usb MySensors gateway and HG will communicate with it.  This would allow the gateway to be located with HG on RPi, connected through USB, so probably a Nano would be best.

Sorry for all the questions, MQTT and MySensors is very new to me, so I'm trying to gather information.  Any help is very much appreciated.

June 14, 2015, 08:32:19 PM
Reply #11

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Quote
Did you use an Arduino Nano?  For MQTT, did you connect it (via Ethernet) to your router?
I forgot to add that, I'm using an Arduino Uno I had left over. For the sensors I am using Nanos, I still have quite a few of those lying around. They seem to prefer Minis though as they're more efficient if I remember correctly.

I decided on an Ethernet/MQTT gateway as I had no USB ports left on my BananaPi.

We seem to be hijacking this thread, might be an idea for an admin to split the thread.

June 15, 2015, 05:16:50 PM
Reply #12

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I played with using Nano's as the receiver intending to hook it up to the RPi serial.  But, for some reason the radio traffic on my Nano's was garbage.  I tried Pro Mini's next and while they would connect to the RPi great, they were 3v3 devices and I couldn't find 433MHz radios that would work with them.  I even tried shifting the logic level with different methods (resistors, IC, diode) but they all failed.  I eventually gave up and am just using an Uno I had sitting around with an Ethernet shield that I had.  It's working great but will require a second box rather than being connected right to the RPi.

You are looking at the MySensors stuff which uses 2.4GHz, but the concept is the same.

June 21, 2015, 09:11:49 AM
Reply #13

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I connected a MySensor device to my Washing Machine! In HomeGenie I created a custom widget with the widget editor, and also enabled PushBullet notifications.

Thanks again for making this CptJack  ;D

June 22, 2015, 07:36:35 PM
Reply #14

CptJack

  • **
  • Information
  • Jr. Member
  • Posts: 30
That's really cool! I especially like the custom widget. I might have to give that one a try someday.