Can someone help mqtt noob to get my project working ![]()
I have two window blinds and want to drive them with mqtt (homeassistant and MQtt server).
Homeassistant, mqtt server etc are ok and working.
...
Problem is find any good tutorial/easy example how i get arduino code that mqtt client.
I think something so easy like send mqtt command: 0-180
And thats it. If i send command 180 my homeassistant arduino get that 180number and move that directly my servo sketch and drive servos 180degrees position. (or if sen 132 sketch drive servos 132degreees position.
I have working sketch to drive servos (Use analog0 and potentiometer to test curtains, but that of course replace mqtt message info)
#include <Servo.h>
Servo myservo;Â // create servo object to control a servo
Servo myservo2;Â // create servo object to control a servo
Servo myservo3;Â // create servo object to control a servo
// twelve servo objects can be created on most boards
int sensorValue = 0;Â Â // variable to store the servo position
int sensorValue2 = 0;
void setup() {
 myservo.attach(5); // attaches the servo on pin 9 to the servo object
 myservo2.attach(4);
 myservo3.attach(2);
Â
 Serial.begin(74880);
 Serial.println("Test");
}
void loop() {
 sensorValue = analogRead(A0);
 sensorValue = map(sensorValue, 0, 1023, 0, 160);
Â
 Serial.println(sensorValue);
Â
  myservo.write(sensorValue);       // tell servo to go to position in variable 'pos'
  myservo2.write(sensorValue);
  myservo3.write(sensorValue);
 Â
delay(100);
}
Of course if is easy to get update what position curtains are example every 10minutes or something that very nice. That can be same like number back to mqtt broker.
Of course if easier messages can be example: open, close, half open
But i think that give more options to control blinds with homeassistant software when you only give exact position where blinds drive.
I am very thankfull any tips and hints.