Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

dj-d/NodeMCU-SmartPowerStrip-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeMCU-SmartPowerStrip-v2

NodeMCU sketch to control a power strip

Startup

  • Change pins and modify status_relay variable with same number of pins
  int relay[] = {0, 4, 5, 16};
  bool status_relay[] = {false, false, false, false};

Using

  • To connect the device to the network visit: tzapu/WiFIManager

  • API

    Description Method Endpoint Body elements
    To start the action described in the body POST /ps "action" and "pin"
    To receive the status of the relays GET /ps/status -
    To receive the number of the relays GET /ps/get_relay_number -
    To receive the type of device GET /get_type -
  • Supported actions

    Action Description
    on Turn on relay
    off Turn off relay
  • Examples

    • Request body for "/ps":

          {
            "action": "YOUT_ACTION",
            "pin": 2
          }
    • Response body for "/ps":

          {
            "msg": "SOME_MESSAGE"
          }
    • Response body for "/ps/status" (with 4 relays):

          {
            "relay_1": false,
            "relay_2": true,
            "relay_3": true,
            "relay_4": false
          }
      • true indicates that the relay is turned on, false indicates that the relay is turned off
    • Response body for "/ps/get_relay_number" (with 4 relays):

          {
            "number": 4
          }
    • Response body for "/get_type":

          {
            "type": "power_strip"
          }

Development

  • Button to reset wifi

Notes

It is possible to use any relay module (1, 2, ..., n) only by changing the pins, adding or removing them, and the whole system will adapt automatically

About

NodeMCU sketch to control a power strip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages