I'm trying to control a servo from a node-red but I can't, I hope you can help me, thanks
You will have to give us a lot more information. What hardware is node-red running on and how have you connected the servo? Also what type of servo is it?
node-red is installed in aws the servo is connected to an esp-32 board and is a sg-90 servo
I want to use mqtt communication with a broker to communicate from esp to node-red
That should be possible. You need to add code to the Esp-32 program to subscribe to mqtt topics. You should be able to find instructions for doing that on the internet.
You will also have to set up your NR flow to publish information that the esp-32 will use to deal with the servo.
I haven't used the ESP-32, just the ESP8266 in the form of the Wemos D1 Mini flashed with ESPeasy.
Here's an example of a very simple flow sending position commands to a servo motor via MQTT.
[{"id":"6c871500.1021ec","type":"tab","label":"Servo motor","disabled":false,"info":"","env":[]},{"id":"ba80606d.5a80e","type":"inject","z":"6c871500.1021ec","name":"Move to zero degrees","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"servo,2,13,0","payloadType":"str","x":280,"y":200,"wires":[["209dbef2.233582"]]},{"id":"209dbef2.233582","type":"mqtt out","z":"6c871500.1021ec","name":"","topic":"node36/cmd","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"5ef29389.24415c","x":510,"y":200,"wires":[]},{"id":"a2fd2b39.2124b8","type":"inject","z":"6c871500.1021ec","name":"Move to 45 degrees","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"servo,2,13,45","payloadType":"str","x":270,"y":260,"wires":[["209dbef2.233582"]]},{"id":"68cf7cd2.366714","type":"inject","z":"6c871500.1021ec","name":"Move to 90 degrees","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"servo,2,13,90","payloadType":"str","x":270,"y":320,"wires":[["209dbef2.233582"]]},{"id":"4920b85ea56eb602","type":"comment","z":"6c871500.1021ec","name":"Need to set your node ID and broker IP address","info":"","x":500,"y":160,"wires":[]},{"id":"5ef29389.24415c","type":"mqtt-broker","name":"","broker":"192.168.1.138","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
You will need to set the node ID for your device as well as the IP address of your broker.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.