MySensors devices


Level:
Beginner
Author:
published:
Modified:

How to create custom devices based on your 100% custom hardware and how to use the device support.


[EDIT]

If you have read this article before be noticed that we have made some changes in the server system and this page has been updated as such and we will keep updating this post until integration is to it’s full potential and create a dedicated one.

PLEASE READ THIS:

The method for adding new nodes has been changed! The server now has a “Device discovery” page which is available by browsing to: “Device/Driver management > Device discovery”. Here you can select the MySensors driver and press enable discovery. Every MySensors device that is discovered will be shown on this page. So it will not be shown any more on the driver page as stated below. The routines stay the same, only the page has been changed.

[/EDIT]

We would like to announce that we have added basic support for MySensors devices. MySensors has a setup which exists of one main central transceiver which you connect to your Raspberry Pi with USB and wireless devices. The power of the implementation done by these guys is that you can create almost any imaginable sensor and/or actuators and even combine these. The transceiver is an Arduino Nano with a NRF24L01+ 2.4Ghz wireless transceiver which is widely available. The wireless nodes can be Arduino Mini’s and/or Uno’s. For more information of the possible used remote devices I suggest you go to the MySensors website at http://mysensors.org.

How to add the devices in the server

We support both the serial and MQTT gateways. Below is shown how they are added/activated. You should make a choice which one you are going to use. The serial one connects to the usb of the raspberry pi, the MQTT version is connected to your network.

Connect the transceiver serial version

Please follow the instructions at the mysensors.org website on how to connect a NRF24L01+ 2.4Ghz transceiver to an Arduino Nano. We currently only support the serial interface which means you need to follow the instructions at: http://www.mysensors.org/build/connect_radio

When you plug in the USB version to the pi’s USB port you need to go to the Peripheral page like shown below. When you are on this page, plugin the Arduino Nano and you will see the device available in a couple of moments. When the device is available click on it and set the driver options as shown below (Click on the image for higher detail).

mysensors-driver-add

If you are planning to continuously use MySensor devices click on “Set, Save and start” This will store the connect settings but you have to be sure that the Arduino Nano is always connected to the same port, otherwise you will lose these settings. When the server restarts or you unplug and plug in the Nano again the settings will automatically be applied. With the above two steps done you will be able to start using the MySensor devices.

Connect to the MySensors MQTT gateway

First build the MQTT gateway: http://www.mysensors.org/build/mqtt_gateway . When build you can in the server activate the MySensors MQTT plugin. Go to “Plugin management > Device plugins” and click “Add new plugin”. From the dropdownlist select “MySensors MQTT Bridge”. After refresh you can enter the following information as shown below

mysensors-mqtt

Give it a name and description so you can identify it yourself.

The ip address is the ip address and port the MQTT gateway uses and the given prefix. The default port and prefix are already filled in. Press save devices plugin and you are done.

Add MySensors node/sensor devices

You can create devices to be used in the server by using the visual device editor. This editor can be found in the left menu at: “Device/Drivers management” > “Custom devices”. The reason for naming custom devices is just because you are creating a custom device. A custom device is in fact a device skeleton. This means create once and then reuse. Click the button “Add new device”.

You will start with an empty canvas with some explaining predefined values you have to change in something more meaningful for yourself. When you have entered the name and description etc.. it is time to create the device:

Check the device type used, when creating a device make sure you use the appropriate “MySensors serial” or “MyseSensors MQTT” device! 

Each MySensors node consist of two main variables, one used to identify the sensor/actuator, the S-Type, and one used to identify the data, the V-Type. So an example would be to describe an light switch is using the S-type “S_LIGHT” and the variable type “V_LIGHT”.

The mapping in the PiDome Server used is simple, you need to add a group to the Device structure. This is done with drag the group button and drop it on the “Device structure” field. A popup will open which asks to give this group a name. To follow the example enter “0” (zero without the quotes) like in the screenshot below. P.S. When creating a new device one standard group is already added, click the wrench to edit the group. The popup will still be the same. The Zero entered is the sensor number you use in the gw.present code. So to follow the example, gw.present(0,S_LIGHT); would then be your presentation code.

editgroupnew

 

Click OK to save the group. You now have created the sensor of a device node.

Every sensor has it’s variables. The above example uses the V_LIGHT variable which is stated on the MySensors website as a switch. To create a switch on the server you need to use a Toggle button. A Toggle button switches between two states.

Drag and drop the “Add toggle button” on the group “Light control”. You will now get a popup which shows the possible options to be used with this toggle button. Like the text to be displayed when true, which will be “On” and for false, will be “Off” in this example. If you take a look in the screenshot below i think you will get the point. Make sure that if you use the toggle button, the button values are always 1 for true and 0 for false.

mysensors_edit_control

Press Ok and you have created the variable V_LIGHT to be used with sensor S_LIGHT. This screenshot shows also a

Scroll down to the page. And this part is also quite important. SKIP THE DEVICE OPTIONS SECTION. You won’t be needing this. At the bottom of the page are the device’s address options. Because in PiDome created devices are reusable you now only are going to define the address construction.

Fill in the information you think you will be needing to remind yourself on how the MySensors addressing works or something else. Keep the Address datatype as string.

mysensors_device_address

Click on “Save new device” and you are done. You can now start adding this device to the server as being used. You have not yet added the device itself you now have created the device’s structure. This means if you have created 10 mysensor hardware devices which are exactly the same, you only have to create the structure once. To start using the device (if you have created one like this), please keep on reading.

These devices can be added by two methods, one convenience method (semi automatic) by using the driver or with the normal procedure.

The semi automatic way

When a device is added to the MySensors network it has the possibility to present itself.

Both the serial driver and MQTT plugin work the same way. Only to add serial devices go to “Drivers”, when using the MQTT plugin go to “Device Plugins”. The screenshots show the serial version.

When you have added the sensor node go to the below shown page in the servers interface (Drivers Management -> Drivers) and click on the MySensors driver. Some driver details will be shown and you will see a new node below the “New nodes presentation” header. If not wait a couple of seconds after turned off and on your MySensors node device and click the driver name again. The list is based on the MySensors device node address.

You will see a button which says “Select from device list” You will get a popup where you can select the device which this node represents. But, before you can do this, you will need to have to create the structure for this device. When you have created this structure your device will be shown in the drop down. By default only the device PiDome temperature,light,user status device is available, which is hardware we will publish asap. Click “Select and start” to add and start the device.

automatic-mysensors-device-add

 

When you are using the AUTO mode to add your devices you can only add one sensor node at a time. The display will look like the below one where it also shows the possible new address. When you have added the node, you MUST restart your sensor node so it can present itself.

add255node

 

If you have multiple devices to be added the list will show more devices. By the way, when you have multiple of the same type devices (but on other locations for example) you only have to create the XML once.

If you have the latest version of the server this will also include the latest functionality as showing the last 20 messages being recorded by the driver (as requested by the gateway). This means the above page does now look like the below screenshot.

mysensors_driver_overview

Also automatic device assignments have been added. This works as follows (This only applies to sensors with the node address set to AUTO):

  • Turn on your sensor node. It will send a request to the server.
  • It will show up in the driver display. Press the “Add sensor node” button
  • The server will send a signal to the Node.
  • When this is done, you need to restart the sensor node so it can be added to the server like stated earlier.

[/EDIT]

The non semi automatic way

When you do not present a device to the gateway, use this method, all though it is not advised to use these devices this way. Go to “Devices (Add/Remove/Settings)”  and click on “Add a new device”. The display will split up like shown below and select your created MySensor device.

select_new_device

You will then be presented with your own created MySensors device enter the used address and you can start using the device.

Known issues

  • Metrics are not yet correctly reported back.

Latest news/blog

Friends of PiDome

RFXCOM
Affordable 433Mhz RF transceivers
Atlassian
Products for teams, from startup to enterprise
UniPi.technology
Home-automation hardware manufacturer
Hubbit.nl
Webshop of the most prominent dutch tech magazines

Latest added technology

  • SMS
  • Z-Wave
  • PushBullet
  • PlugWise
  • MQTT

Some project stats

Open Hub project report for PiDome Platform

Other

Official NLJUG Member