Giter VIP home page Giter VIP logo

smartcurtain-curtain's Introduction

~/SmartCurtain/Node/


Description

This folder is what goes on the Arduino.

Contents

  • ./Node.ino The main Arduino program file.
  • ./Headers/ The header files for the Arduino program.
  • ./src/ The .cpp files for the Arduino program.

Installation

  • Open ~/Node/Node.ino into Arduino IDE (or equivalent).
  • Install ESP32 board library https://dl.espressif.com/dl/package_esp32_index.json
  • Install ArduinoJson library.
  • Install ArduinoMQTTClient library.
  • Edit ./src/Config.cpp.template adding your values for,
    • The pins as they are attached to the stepper driver.
    • The pulse wait time in coordination to the stepper driver settings.
    • The MQTT broker domain & port.
    • The MAC address of the device as needed.
    • Your WiFi login.
  • Save your edited ./src/Config.cpp.template as ./src/Config.cpp.
  • Compile the project to the ESP32.

Communication

The hub and curtain do a shout out to the other when they turn on. This way if the hub is already running and a curtain powers on, the hub will know, and vice versa. image

Commands

There are 3 basenames that describe a type of action:

  • ../move Command to move a curtain or set of curtains to a position.
  • ../status Command to request the status of a curtain or set of curtains.
    • Publishing to a status topic is the request for the state of the topic's subscriber.
  • ../update Command to update a curtain.
    • Publishing to an update topic is the posting of the state of the topic's publisher.
    • IE. The subscriber's known information will be updated.

Grouping

The move and status commands can be grouped on a home or room level. The curtains under either the home or room (indicated by the topic) will pickup the commands by subscribing to that topic.

Path formatting is as follows:

  • SmartCurtain/all/<command>
  • SmartCurtain/hub/<command>
  • SmartCurtain/<home_id>/<command>
  • SmartCurtain/-/<room_id>/<command>
  • SmartCurtain/-/-/<curtain_id>/<command>

Noteably, because the id for a home regardless of the home or curtain, the room regardless of the home or curtain and the curtain regardless of the home or room are unique to their respective areas, the above paths allow for easy grouping.

image

Subscribing

The Curtain automatically subscribes to

  • SmartCurtain/all/move
  • SmartCurtain/all/status
  • SmartCurtain/-/-/<curtain_id>/move
  • SmartCurtain/-/-/<curtain_id>/status
  • SmartCurtain/-/-/<curtain_id>/update

When the hub updates the curtain, it will then subscribe to

  • SmartCurtain/<home_id>/move
  • SmartCurtain/<home_id>/status
  • SmartCurtain/-/<room_id>/move
  • SmartCurtain/-/<room_id>/status

../move

Request

On a move command, a event JSON is sent

{
	"percentage": 100  // (0-100)
}

Response

Upon starting and completion of a move command, the curtain updates the hub with its status

{
	"id": 1,  // Curtain's ID (1-4294967295)
	"Home.id": 0,  // Curtain's Home's ID (1-4294967295)
	"Room.id": 0,  // Curtain's Room's ID (1-4294967295)
	// ———— HUB CAN SET CURTAIN ———— //
	"Auto Correct": false,  // Whether the Curtain is allowed to Auto Correct
	"length": 32000,  // The allowed length of the Curtain (Sets to minimum of Hub's length & Curtain's length)
	// ———— CURTAIN CAN SET HUB ———— //
	"percentage": 100,  // The current percentage of the Curtain
	"is_moving": true  // Whether the Curtain is moving
}

../status

Request

No message is sent on a status request

Response

On a status command, the curtain updates the hub with its status

{
	"id": 1,  // Curtain's ID (1-4294967295)
	// ———— HUB CAN SET CURTAIN ———— //
	"Home.id": 0,  // Curtain's Home's ID (0-4294967295)
	"Room.id": 0,  // Curtain's Room's ID (0-4294967295)
	"Auto Correct": false,  // Whether the Curtain is allowed to Auto Correct
	"length": 32000,  // The allowed length of the Curtain (Sets to minimum of Hub's length & Curtain's length)
	// ———— CURTAIN CAN SET HUB ———— //
	"percentage": 100,  // The current percentage of the Curtain
	"is_moving": true  // Whether the Curtain is moving
}

../update

Request

On an update request, the known information is received and updated where allowed if it is does not match

{
	"id": 1,  // Curtain's ID (1-4294967295)
	// ———— HUB CAN SET CURTAIN ———— //
	"Home.id": 1,  // Curtain's Home's ID (1-4294967295)
	"Room.id": 1,  // Curtain's Room's ID (1-4294967295)
	"Auto Correct": false,  // Whether the Curtain is allowed to Auto Correct
	"length": 32000,  // The allowed length of the Curtain (Sets to minimum of Hub's length & Curtain's length)
	// ———— CURTAIN CAN SET HUB ———— //
	"percentage": 0,  // The current percentage of the Curtain
	"is_moving": false  // Whether the Curtain is moving
}

Response

On an update command, the curtain does not update the Hub, as not doing so give the Curtain the power to choose what to update about itself. This also prevents possible infinite looping.


Software

Architecture

image

Sequencing

image

Hardware

image

smartcurtain-curtain's People

Contributors

mpzinke avatar

Watchers

 avatar

smartcurtain-curtain's Issues

Dynamic WiFi Setup

Description

As a SmartCurtain user,
I want to be able to connect my Curtain to a WiFi network without reflashing it,
So that I can more seamlessly integrate curtains with my home network.

Context

Currently, the SSID and Password for WiFi networks are hardcoded into the flashed program. This prevents the curtain from being setup in a new home without being reflashed. As such, the curtain needs to be able to save new network properties while running.

Acceptance Criteria

  • Curtain boots as an access point if unable to connect to a WiFi network
  • Curtain can receive & save network credentials
  • Curtain reboots where necessary

Implementation

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.