Integrate Tasmota based ESP32-CAM with Node-Red and Home Assistant

 Tasmota

Tasmota is a opensource platform.The Tasmota created the readymade binary files or firmware for the ESP based products like sonoff devices. The Tasmota is very easy to operate. If someone does not have any experience of coding, he can also create the Esp chip Based product very easily. The pre-compiled and pre-built code can be flashed into ESP device.The device can be configured using webUI.The tasmota has support for various sensor like temperature sensor like DH11 or humidity sensors etc. Further the device can be controlled through HTTP,MQTT,Webui and serially.So creating the product for the Home Automation is very easy. To start working with it ,visit Tasmota Getting started webpage.


Node-Red

Node-Red is a open source platform. It is based on node.js. It is a web based visual application which uses the nodes palette. It is very easy to use. The user has to drag the nodes from the nodes pallete and place it in the editor window  and wire them and put some logic to implement the functionality of the project With this the IOT based project UI can be easily created.


ESP32-Cam

ESP32 cam is a ESP32-S2 series based camera supporting module.Generally the ESP32-Cam modules available modules are developed by I-Thinker which is china based company. The ESP32-Cam module comes with camera OV2640 module which is 2Mpixel resolution.The board comes with connector to the camera. The board has some free IO ports which are mode available for the user on the headers lying on the either side.The Board has LED which is very bright and connected GPIO pin 4.It has got the SD card slot which is provision for SD card for saving the captured images.


                                         ESP32-CAM Module



Flash the code in ESP32-CAM with Tasmota Web Installer

To know in detail how to Setup Tasmota on ESP32-CAM then visit this blog.

As it can be seen from the images above, the ESP32-Cam board does not have any usb port to flash the code.So flash the code or hex file is flashed using the serial port. The image given below shows the connections for putting ESP32-Cam board into programming mode..Note that, for programming mode, the GPIO0 pin of ESP32 is connected to the Ground pin. After flashing of the code is over, the GPIO0 pin should be disconnected from the Ground pin.

Visit the Tasmota Getting Started Page, Select the Appropriate Binary file and flash it using the Tasmota Web Installer.


                            Webinstaller tool


 After the installation is complete remove jumper between GND pin ,

The ESP32-cam will act as tasmota server ,Check the wifi network of your PC to check tasmota device is available for connecting. Connect with the Tasmota device.

Enter the IP  192.168.4.1 in the browser to get the page as shown below. Set the wi-fi SSID and password of your network and click on save..

After this visit the main menu page of the Tasmota. The Camerra streaming input is available on Main Menu Page

        

                                      TasmotaMainMenuPage


Configure the LED pin(GPIO 4) of ESP32-CAM as Relay by entering configure module sub menu of Tasmota Menu Page.


Configure Node-Red 

Start the Node-Red from the command prompt(windows) or terminal(Ubuntu). When Editor window is opened then drag the Template node from Dashboard into editor.


Node-red editor



Click on the template node and do the following settings.

1. Create new Dash board Group


                               Template Node Config



2. Keep the name as default. Add new Dashboard tab.



Add tab



3. Set the name as Node-RedCam and click Add  Button again cilck on Add Button.


Add tab name


  
4. Add some code as shown in the figure below. I have used IP assigned to ESP32-CAM .You use the IP of your network.



add code


Add code as

                     <div>
                      <img src="http://IP of your network:81/stream" width = "600"  height ="400">
                     </div>


Click on Done Button. The template node is configured. Click on Deploy Button and then go to the Dashboard.



Dash board entry



Now the ESP32-CAM image stream is available on the Dashboard.

 

node-red gui



If  the image stream  is not available on dashboard. then try the following steps.

1. Go to the console Menu on Tasmota Menu Page. and type the following command as shown in the image and press Enter

Rule1 ON System#Boot DO Wcinit ENDON

tasmota console


2. By setting the rule1.Run this Rule1 by typing the command Rule1 1  and press Enter.

3.Reboot the Tasmota Device by running the command Restart.

When the device gets restarted, check the image available on the Node-Red Dashboard
.

The Flow for the integrating Tasmota Based  ESP32-Cam with Node- Red is as given below.



Node-red wire



Please set the IP of your network in Template and Function Nodes.


The JSON for the above flow is as given below.


[
    {
        "id": "3ffe22899be4bb98",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "58ea179e1629c85b",
        "type": "ui_template",
        "z": "3ffe22899be4bb98",
        "group": "65dc5732224e06bb",
        "name": "",
        "order": 6,
        "width": 0,
        "height": 0,
        "format": "<div >\n    \n<img src=\"http://192.168.1.100:81/stream\" width=\"600\" height=\"400\">\n\n</div>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "",
        "x": 160,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "2be6e12a7aa2424c",
        "type": "http request",
        "z": "3ffe22899be4bb98",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 710,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "22dabd331ce695cc",
        "type": "ui_slider",
        "z": "3ffe22899be4bb98",
        "name": "",
        "label": "Brightness",
        "tooltip": "",
        "group": "65dc5732224e06bb",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "msg",
        "min": "-2",
        "max": "2",
        "step": "1",
        "className": "",
        "x": 170,
        "y": 240,
        "wires": [
            [
                "b944dd01793ba9fb"
            ]
        ]
    },
    {
        "id": "4c5b51d665208e9d",
        "type": "change",
        "z": "3ffe22899be4bb98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 240,
        "wires": [
            [
                "2be6e12a7aa2424c"
            ]
        ]
    },
    {
        "id": "b944dd01793ba9fb",
        "type": "function",
        "z": "3ffe22899be4bb98",
        "name": "",
        "func": "\nmsg.payload = \"http://192.168.1.100:80/control?var=brightness&val=\"+msg.payload\n\n//http://DEVICE_IP/cm?cmnd=WcBrightness%\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 240,
        "wires": [
            [
                "4c5b51d665208e9d"
            ]
        ]
    },
    {
        "id": "b694e2436bf0dfab",
        "type": "ui_slider",
        "z": "3ffe22899be4bb98",
        "name": "",
        "label": "Contrast",
        "tooltip": "",
        "group": "65dc5732224e06bb",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "msg",
        "min": "-2",
        "max": "2",
        "step": "1",
        "className": "",
        "x": 160,
        "y": 320,
        "wires": [
            [
                "82facdbd38555b3d"
            ]
        ]
    },
    {
        "id": "82facdbd38555b3d",
        "type": "function",
        "z": "3ffe22899be4bb98",
        "name": "",
        "func": "\nmsg.payload = \"http://192.168.1.100/control?contrast=\"+msg.payload\n\n//http://DEVICE_IP/cm?cmnd=WcBrightness%\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 320,
        "wires": [
            [
                "3eb709989cbfa5e8"
            ]
        ]
    },
    {
        "id": "3eb709989cbfa5e8",
        "type": "change",
        "z": "3ffe22899be4bb98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 320,
        "wires": [
            [
                "3a421e41eb0798ca"
            ]
        ]
    },
    {
        "id": "3a421e41eb0798ca",
        "type": "http request",
        "z": "3ffe22899be4bb98",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 710,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "4096ec15e4b77c49",
        "type": "ui_slider",
        "z": "3ffe22899be4bb98",
        "name": "",
        "label": "Resolution",
        "tooltip": "",
        "group": "65dc5732224e06bb",
        "order": 9,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "msg",
        "min": "0",
        "max": "13",
        "step": "1",
        "className": "",
        "x": 170,
        "y": 400,
        "wires": [
            [
                "df0942d4306437cf"
            ]
        ]
    },
    {
        "id": "df0942d4306437cf",
        "type": "function",
        "z": "3ffe22899be4bb98",
        "name": "",
        "func": "\nmsg.payload = \"http://192.168.1.100/cm?cmnd=WcResolution \"+msg.payload\n\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 400,
        "wires": [
            [
                "7a5f5df3622b4d8d"
            ]
        ]
    },
    {
        "id": "7a5f5df3622b4d8d",
        "type": "change",
        "z": "3ffe22899be4bb98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 400,
        "wires": [
            [
                "e8b89c69172482de"
            ]
        ]
    },
    {
        "id": "e8b89c69172482de",
        "type": "http request",
        "z": "3ffe22899be4bb98",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 710,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "f548cd9a67717089",
        "type": "function",
        "z": "3ffe22899be4bb98",
        "name": "",
        "func": "\nmsg.payload = \"http://192.168.1.100/cm?cmnd=Power \"+msg.payload\n\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 180,
        "wires": [
            [
                "9ed681202f03cf11"
            ]
        ]
    },
    {
        "id": "9ed681202f03cf11",
        "type": "change",
        "z": "3ffe22899be4bb98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 180,
        "wires": [
            [
                "79e50fa364a44c3c"
            ]
        ]
    },
    {
        "id": "79e50fa364a44c3c",
        "type": "http request",
        "z": "3ffe22899be4bb98",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 710,
        "y": 180,
        "wires": [
            [
                "ff09ad0891f090f0"
            ]
        ]
    },
    {
        "id": "a507020b2fd98594",
        "type": "ui_switch",
        "z": "3ffe22899be4bb98",
        "name": "",
        "label": "Led",
        "tooltip": "",
        "group": "65dc5732224e06bb",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 150,
        "y": 180,
        "wires": [
            [
                "f548cd9a67717089"
            ]
        ]
    },
    {
        "id": "ff09ad0891f090f0",
        "type": "debug",
        "z": "3ffe22899be4bb98",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 180,
        "wires": []
    },
    {
        "id": "65dc5732224e06bb",
        "type": "ui_group",
        "name": "cam2",
        "tab": "da28975d3db72c18",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "da28975d3db72c18",
        "type": "ui_tab",
        "name": "esp-cam1",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]



For more Details Watch this Youtube Video,








Post a Comment

Previous Post Next Post