MySensors Library

created by hek , updated

Here you can find the revision history and downloads for the MySensors Arduino library.

We keep the source code on github publicly available.

NOTE: The latest released version of the library is always available in the Arduino IDE Library Manager. Have a look at installing MySensors library for more help on how to use it.

If you need help getting started, have a look at the using Arduino section here on MySensors.

2.0 - Latest Release

Download GitHub API Serial Protocol

This is the latest stable release. Normally the best version to use for your project. It should be fully backward compatible with your controller (serial api hasn't been changed since 1.5). We recommend updating both gateway and sensors to the the latest release.

  • Library size reduced ~20% by removing a lot of C++ overhead.
  • Full configuration of library behaviours and features directly from sketch code. Makes codebender builds much easier and allows you to make configuration without editing MyConfig.h.
  • No more MySensors constructor mess with radio drivers and signing backends. All setup and initialization is handled “behind-the-scene”.
  • Calls to process() is handled in the background automatically.
  • Structural change: Embedding of drivers and libraries in a structured way instead of using the weird arduino-build-system util-folder which includes everything when building.
  • All gateway variants available as examples without any need for re-configuration (E.g. SOFT-SPI automatically enabled for W5100).
  • Gateway just another sensor node! So now you can have wired ethernet sensors and wireless ESP8266 sensors without any radio attach if you want.
  • AES encryption (RF24)
  • Introducing a presentation() function in sketch - This allows controller to re-request presentation and do re-configuring node after startup.
  • Optional receive() function in sketch replaces begin(callback).
  • sendHeartbeat() - Allows node to send heartbeat and controller to ping nodes.
  • Ethernet/ESP8266 gateway supports setting static ip and using dhcp
  • Ethernet/ESP8266 gateway allowing communication using UDP.
  • Ethernet/ESP8266 gateway can now act as a client which opens a socket to controller at startup. NOTE: This has to be supported by controller.
  • MQTT client gateway on ESP8266 or Arduino+W5100 Ethernet adapter
  • ESP8266 stability improvements
  • Serial transport layer (RS232/RS485) with dePin management.
  • Added variable V_CUSTOM - For sending/requesting custom data to/from controller and between nodes. Preferable using S_CUSTOM device. This variable-type is controller specific so use it with care in the officially provided examples.
  • New sensors types and variables: S_INFO, S_GAS, S_GPS, V_TEXT, V_CUSTOM, V_POSITION, V_VAR, V_VA, V_POWER_FACTOR
  • Deprecated sensors: S_LIGHT (use S_BINARY)
  • Deprecated variables: V_DIMMER (use V_PERCENTAGE), V_HEATER (use V_HVAC_FLOW_STATE), V_LIGHT (use V_STATUS)
  • New command I_DISCOVER - retrieve active nodes and topology.
  • Detection of mis-wired RFM69 radios.
  • MyMessage:getCommand()
  • Cleanup Github Repo:
    • Moved MYSBootloader to separate Github repository.
    • Moved NodeJsController to separate Github repository.
  • “Smart sleep” variants of all sleep methods that allows nodes to receive buffered messages/commands from controller that was issued while node was sleeping. When calling the smartSleep() variant, the goes to sleep and sends a heartbeat message after waking up (informing controller that node is awake) and waits MY_SMART_SLEEP_WAIT_DURATION to process any incoming buffered messages from the controller. NOTE: Controller must support this feature.
  • Optional before() method in sketch - for initialisations that needs to take place before radio has been setup (using SPI).
  • New conditional parameters to wait(unsigned long ms, uint8_t cmd, uint8_t msgtype) loops until time passed or specified command received.
  • New RF24 driver by @tekka007. Stripped C++ code, 2-fold speed increase, Radio code reduced about 2kb, Eliminate non-essential register polling/writing, Uses 2 RX pipes
  • Possible to re-assign/reallocate node ids by sending I_ID_RESPOSE to a node.
  • AVR/SAMD hardware moded to separate GitHub repository and accessible using board manager by adding
  • Support SAMD architecture (Arduino Zero, MySensors Gateway Hardware)
  • transportInit()-method used to reinitialize radio after full power-down of radio. Useful when using one of the GPIOs to power radio (or via MOSFET).
  • Move OTA FW update code to MyOTAFirmwareUpdate
  • Implement I_DEBUG to report various parameters such as CPU frequency, CPU voltage, free mem, routing info and function to do a “factory reset” by clearing the MySensors EEPROM area
  • Added library status indication callback. User can install callback to handle status & error information from the library.
  • Improved error LED feedback. A 'headless' sensor can report error codes by counting the number of blinks of the error led.
  • Overhauled transport with focus on reliability and stability (most important changes/enhancements):
    • state machine for transport-related tasks
    • node checks connection to GW during transport initialisation
    • parent node assignments are handled as preferred parent with fallback mechanism
    • regular transport sanity checks for GW and repeater nodes
    • repeater node checks uplink connection to GW before advertising as repeater during find parent state
    • in case of transport failure (HW or link): power-down (PDT) for a defined time and re-initialisation
  • Node registration: node has to register to the GW/controller in order to send sensor data (default state configurable)
  • For maintenance reasons, examples depending on external libraries have been removed, to be placed in a separate repository (work in progress).


Download GitHub

The latest development branch contains our work-in-progress and should only be used if you like living on the edge and is prepared to update sensor/gateway code frequently.


Download GitHub

  • Message signing using ATSHA204 hardware or software driver
  • Multiple radio transport driver architecture
  • RFM69 radio support
  • Support for multiple hardware layers (ATMega328 default implementation)
  • New sensors: RGB, RGBW, Color, Multimeter, HVAC, Sprinkler, Water leak, Sound, Vibration, Moisture
  • New variables: Voltage, Current, RGB RGBW, Id, Unit prefix, Setpoint, Level
  • Allow indication LEDs (tx,rx,err) on sensors
  • Sensor presentation description message
  • OTA updates using on-board flash (and DualOptiboot bootloader)
  • Allow SOFTSPI configuration from MyConfig.h
  • Bugfixes!


Download GitHub

  • Improved communication reliability (now uses hardware acks and resend functionality).
  • Simplified sketches (only one include needed).
  • Most common sleep scenarios build in.
  • Helper for permanently storing values in the Arduinos EEPROM.
  • Acknowledgments can now be requested from gateway and other sensors in network.
  • Smaller footprint.
  • The message structure has been adopted to work better on RPi platform.
  • Binary payloads supported and used for integers between sensors.
  • Configuration message (only metric setting in it today).
  • Allow static parent (no dynamic lookups)
  • Callbacks for incoming messages and time. No synchronous waiting methods any more -> no missed messages.
  • Lots of new examples: Knock, gas, ir, dust, display & time, uv, rfid.


Download GitHub

  • New software ack mechanism. HW acks was very unreliable and generated trash messages.
  • Messages is now directed directly to children (fixed previous bug in routing algorithm).
  • Sensors now only has one pipe open (self) and gw/repeater nodes two (broadcast, self). Previously it also listened to relay node. This means no more overhearing of messages directed for other nodes.
  • Higher radio transmit speed 1->2mbps.
  • Energy Pulse meter example added.
  • Energy Water meter example added.
  • Fixed bug when sending battery level from sensor.
  • LAST_UPDATE is set on node-device when any variable update is coming in for children.
  • Fixed truncation of debug messages.
  • Updated humidity sensor to fetch unit settings from vera.
  • Fixed bug with "SendNodeCommand?" from vera side.
  • New servo-actuator example.
  • Store relay-node in EEPROM.
  • More debug info is printed to serial monitor in sensors (can be turned off).
  • Nodes that receive messages from vera don't need to busy wait. New API methods. See new example code in RelayActuator sketch.
  • Increased transfer speed (1MBPS) between radios.
  • Sent time to sensors uses vera configured timezone.
  • Radio protocol updated. from/to/version/crc/binary added in message header. This change requires sensors to update their (1.2) library version.
  • Variables in vera only gets updated if changed.
  • Increased baud rate between vera gateway and vera.
  • Message can be sent between sensors without being processed by vera.
  • Vera library is now a subclass of RF24.
  • Remove gateway specific code from vera library. New class hierarchy RF24->Node->Relay->Gateway.
  • Preserve memory by placing static strings in PROGMEM.
  • Inclusion mode. Can be started from the Arduino Vera plugin or by using digital input pin on vera gateway (inclusion button). All found devices during inclusion time will be created at once (no multi vera reload/restart cycle needed anymore).
  • The ArduinoGateway support blinking LEDs for RX/TX/ERR and a special blink when inclusion mode is activated.
  • Dimmer support.
  • Lastupdate-variable is set in vera for all changes.
  • A new device is created in vera for each physical arduino/radio This device will hold info about node, such as library version, battery info and relay information.
  • Support for message relaying. All nodes can act as relay. This functionality can be used for communicating with sensors far away. An relay node forwards messages between sensors and vera gateway. Multiple relays (message hops) is also supported. See RelayActuator sketch for an example how to create an relay node.
  • Relay node for a sensor (could be GW) is dynamically located each time a sensor is losing connection. This information is also sent to vera and can be seen in radio node device.
  • Unit system can be configured in vera plugin (metric/imperial). Sensors can fetch this setting (isMetricSystem()) and send in data in the correct unit.


  • Added possibility to request time from vera.
  • Support for 5 custom variables (can be stored in any sensor device). Note that chixxis variable container is still not supported. But the functionality is similar.
  • Sensors reports their library version to Vera.
  • New example sketch showing time and variable functionality.
  • SendCommand action added in vera plugin which makes it possible to send data to sensors from scenes (advanced-section) or via luup-calls.
  • Auto-id added. A sensor can now request id from vera at first start. The id gets stored in the sensors EEPROM. All example sketches now uses auto-id functionality. You can still use static ids if that is preferred.
  • Automatically sets LAST_TRIP and BATTERY_DATE.
  • Fixed "No Implementation" message when pressing Armed/Bypassed on security sensors.
  • Cleaned up plugin code


Never released