Giter Site home page Giter Site logo

arduinored's Introduction

ArduinoRed

control arduino (ESP32/ESP8266) from Node-Red

main.cpp

#include <Arduino.h>

//Configure ArduinoRed

const char *deviceName="ESP32D1";

const char *arduinoRedCode="passkey";

const char *nodeRedURL="...noderedurl..."; //(without http/s)

//WiFi

const char *wifiSSID = "ssid";

const char *wifiPassword = "pass";

//DHT

#define DHTfunctionality //comment if functionality is not needed

extern const uint8_t DHTPin = 17;

//IR

#define IRfunctionality //comment if functionality is not needed

extern const uint16_t irTransmiterPin = 4;

extern const uint16_t irReciverPin = 14;

#include <ArduinoRed.h>

void setup()

{

Serial.begin(115200);

arduinoRed.setup();

}

void loop()

{

arduinoRed.loop();

}

Node-Red

The ESP devices needs to get the mqttbroker parameters from node-red,

(you have to set node-red before turning on the ESP)

instructions:

create "http in" node with url "/getArduinoRedConfiguration"

and respond with json object:

"{

"server":

{

  "url":"mqtt broker url",
  
 "port":mqtt port,
 
 "user":"mqtt user",
 
 "password":"mqtt password"
 
 },

"dht":

{

  "refreshLag":5,         //dht refresh time in seconds
  
  "diffTemperature":0.2,  //min delta temperature to update thermostat data
  
  "diffHumidity":0.5      //min delta humidity to update thermostat data
  
},

"topics": //optional - you can define multiple topics for the ESP to subscribe

  [{"topic":"test","qos":1,"subscribe":true}],

"client":

{

"name":"ESP32D1"

}

}"

the device name should match the one typed in the main.cpp.

send the json object to "http response" node.

Device status

recive device status on topic ["device name"/status]

send device status quary to topic ["device name"/status] payload ["sync"]

Device debug

control debug messages broadcasting by sending ["startDebug"] or ["stopDebug"] to topic ["device name"/status]

recive debug messages on ["device name"/debug]

DHT

recive dht data as json object on topic ["device name"/thermostat/status]

IR

recive IR data on topic ["device name"/remote/recivedCode]

send IR command (prontocode style as string) to topic ["device name"/remote/transmitCode]

change mode (learn/normal) by sending ["mode:learn"] or ["mode:normal"] to topic ["device name"/remote]

Control the board

send json object to control the board to topic ["device name"/board]

i.e. msg.payload={"pin":12,"state":"LOW","mode":"OUTPUT"}

//state: "LOW"/"HIGH"

//mode: "INPUT"/"OUTPUT"/"INPUT_PULLUP"/"INPUT_PULLUP_16"

subscribe to topic ["device name"/board/pinValues] to get pins values (which you previously set to input)

arduinored's People

Contributors

freman9 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.