GithubHelp home page GithubHelp logo

romeocovaci / relayshieldmqttcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from greenthegarden/relayshieldmqttcontroller

0.0 1.0 0.0 683 KB

Arduino project to control a Seeedstudio Relayshield via MQTT

C++ 20.50% C 14.05% Objective-C 25.83% Shell 27.02% Python 12.60%

relayshieldmqttcontroller's Introduction

RelayshieldMqttController

An Arduino project to control a Seeedstudio Relay shield V1.0 via MQTT.

Requirements

An Arduino UNO compatible board with ethernet, for example a Freetronics EtherTen, or a UNO board along with an ethernet shield, is required to host the code.

In addition, an MQTT broker is required to running and accessible from the Arduino.

Example code is included in extras, for openHAB and Python, to generate the required MQTT messages to control the relays.

Configuration

The code makes use of the NetEEPROM library to configure the MAC address of the Ethernet hardware. See the examples that accompany the library for how to set a MAC address. Utilising the library means the MAC address does not need to be defined in the code, allowing an IP address to be assigned automatically without code changes to multiple boards (assuming a DHCP server is available on network).

The MQTT broker address is required to be defined within the source code. Set the address on line 8 of file mqttConfig.h.

Compiling code

The project is structured for use with PlatformIO. If using PlatformIO, the external libraries used in the project will be automatically added.

To compile the code using the Arduino IDE the following additional libraries are required

Using the program

In order to make use of the program, MQTT structured messages must be generated.

To control each relay a messaged is required with the topic

relayshield/control/relay

and payload x,y, where

  • x is the relay number (1 to 4)
  • y is either 0 or 1 to switch the relay off or on, respectively.

For example to swich relay 2 on, a message in the following form is used

relayshield/control/relay 2,1

On the change of state of a relay, a status message is generated by the Arduino, with the topic

relayshield/status/relay

and payload, in the format x,y, where

  • x is the relay number (1 to 4)
  • y is either 0 or 1 to signifity whether the relay is off or on, respectively.

Other status messages are generated for reliability. See the file mqttConfig.h for details.

Contact

Please let me know if you have any comments or suggesions.

relayshieldmqttcontroller's People

Contributors

greenthegarden avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.