An IoT engine with a client and a server component used to handle server communication to set the states of IoT devices
- Save & manipulate custom JSON's for client states
- Connect to Wifi to access the server
- Listen to state changes in the server
- Parse JSON data from the server
- OnCall and OnUpdate for ease of hardware control
My goal is to have a gyro sensor on my curtain and a stepper motor turning the curtain to match the rotation I want being kept on the server
- Node JS for the server
- PlatformIO on VSCode for building to Arduino
- An ESP8266 board for wifi connectivity on client hardware
- Create data for your client in storage.js
var storage = function() { this.data = { "rgbLight": {"red": 0, "green": 0, "blue": 255}, "stepperMotor": {"direction": 1}, }; this.functions = { "testFunction": testFunction, }; }; function testFunction() { console.log("test function called"); }
- run server.js with
node server.js
- Use PlatformIO documentation to install PlatformIO for VSCode to build C++ files on your ESP8266
- Edit Constants.cpp for Wifi Connection
// =========== WIFI Details ============== const char* Constants::ssid = "your-wifi-name"; const char* Constants::password = "your-wifi=password"; // =========== Server Details ============== const String Constants::host = "your-server-IP"; const int Constants::port = 8080;
- Code custom IOT functinoality
Base a class off of the IOT class. Chech LightLED.cpp for an example
LightLED::LightLED(String _nameTag, uint8_t _pin) : IOT(_nameTag) { this->pin = _pin; } void LightLED::OnStart() { pinMode(pin, OUTPUT); } void LightLED::OnCall(JSONVar inp) { bool status = inp["status"]; if(status == true) digitalWrite(pin, HIGH); else digitalWrite(pin, LOW); }
- Create an IOT device in Constructor.cpp
const int Constructer::thingCount = 1; // Amount of internet connected proccess run in code IOT** Constructer::allThings = new IOT*[thingCount]; void Constructer::ConstructThings() { // === construct all internet connected things === // things array = thing constructor ( name, pins to use ) allThings[0] = new LightLED("blueLight", 4); }
- Build with PlatformIO
Still working on the gyro and the stepper motor component for the mentioned project in the Example Use section