Perfect!
Thank you very much. I will it setup and let you know if it worked for me.
Thanks once again!
Perfect!
Thank you very much. I will it setup and let you know if it worked for me.
Thanks once again!
Hi
I am having difficulties with the MQTT on Arduino. On Serial Monitor it says :
-2
try again in 5 seconds
Attempting MQTT connectionâŚ
failed, rc=
-2
try again in 5 seconds
Attempting MQTT connectionâŚ
and keeps on looping. I have uploaded the code successfully and the board is 2.3.0 it is a Wemos D1.
Can you please help?
Hi,
check that:
-your broker is installed and running
-the sketch is modified to connect to your broker,parameters below modified
#define wifi_ssid âwifi ssidâ
#define wifi_password âwifi pwdâ
#define mqtt_server âmqtt server ip adressâ
-if you broker need authentication set this:
#define mqtt_user âyour_usernameâ
#define mqtt_password âyour_passwordâ
and uncomment line 165 and comment line 168
play again,
PS: please avoid posting the same question on several places
Hi thanks for the reply and apologies for posting it many times.
I wanted to ask you what do you mean by âbroker is installed and running?â
Thanks.
The gateway send or receive data to or from an MQTT broker.
HA is also connected to the broker.
The broker is making the link between the gateway and HA.
A broker like mosquitto must be installed and running to make the gateway working.
I have installed mosquitto on my raspberry pi and is all connected to HA.
Does my MQTT server need to be the same as my mosquitto installed on my raspberry pi?
your MQTT server is your mosquitto one, if mosquitto is installed on your pi you have to put your pi ip adress into the gateway parameter for example:
#define mqtt_server "192.168.1.13"
Right I have done everything you told me and this is what I get in the serial monitor:
try again in 5 seconds
Attempting MQTT connectionâŚ
failed, rc=
5
try again in 5 seconds
Attempting MQTT connectionâŚ
failed, rc=
5
try again in 5 seconds
Attempting MQTT connectionâŚ
failed, rc=
5
try again in 5 seconds
Can you think of anything else? Do you think it could be the libraries?
what line is 165 and 168?
do you have authentication on your mosquitto, if you donât really need it you can remove it, will be easier.
If you really need it, set the username and password parameters
uncomment //if (client.connect(â433nIRtoMQTTto433nIRâ, mqtt_user, mqtt_password)) {
comment if (client.connect(â433nIRtoMQTTto433nIRâ)) {
I only have it on MQTT in HA not on mosquitto itself
OK I managed to get it working the MQTT on my esp8266 board. I am also able to extract the ir codes for my remote but as i try and use the emitted codes it doesnt seem to turn the switch on or off.
I guess I have connected my circuit incorrectly. Can you suggest a circuit without the rf modules and only IR led with a 2n2222 transistor please?
Thanks.
The circuit would be the same if you remove the RF transmitter and receiver.
Here is some tracks to follow:
-try to emit at 10cm from your switch, depending on your IR led model it can be more or less powerfull
-try to emit with different model (sendNEC, sendLGâŚ)
Post the code that you received from the gateway when pressing the remote control close to the IR receiver
ok I have tried everything according to what you said but still no luck.
I noticed that the code that I tried to emit is different. Do you know what could be the problem?
Could you post the code that you received from the gateway when pressing the remote control close to the IR receiver
This is what I get and I think the correct code is â3772793023â the rest are garbage:
Receiving IR signal
Sending IR signal to MQTT
4105841032
sending
4105841032
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3772793023
sending
3772793023
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3772793023
sending
3772793023
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
1511264422
sending
1511264422
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3772793023
sending
3772793023
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3772793023
sending
3772793023
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
1513342804
sending
1513342804
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
4105841032
sending
4105841032
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3609682416
sending
3609682416
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
2837457082
sending
2837457082
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
3772793023
sending
3772793023
to
home/sensors/ir
Receiving IR signal
Sending IR signal to MQTT
1911015101
sending
1911015101
to
home/sensors/ir
Now when I try and send :
mosquitto_pub -t home/commands/sendNEC -m 3772793023
I get the following confirmation when I subscribe to the topic sendNEC from my raspberry pi :
Client mosqsub/9575-raspberryp received PUBLISH (d0, q0, r0, m0, âhome/commands/sendNECâ, ⌠(10 bytes))
home/commands/sendNEC 3772793023
and on Serial Monitor in Arduino I get:
Hey I got a callback
Receiving data by MQTT
home/commands/sendNEC
3772793023
2147483647
Now I dont understand what code is â2147483647â ??
Also are these codes in raw format?
I do not undertstand what mistake am I making I took the IR LED close to the receiver as well but it doesnt work?
Please help!
Thanks
Could you try with the last version of the gateway, there was some correction made
I am using the latest version of gateway that you have uploaded.
I am using a 2N2222 transistor and wanted to find out if my connections are correct because in your Schematic it shows 1 (emitter) is connected to the resistor which then connects to pin D5, 2 (base) is connected to GND and 3 (collector) is connected to the IR LED.
Now I was looking at your other diagram it shows that you have connected 2 (base) to the resistor which is then connected to pin D5 and 1 (emitter) is connected to the GND. So which one is correct? because I am following the schematic i.e. 1 (emitter) connected to the resistor which is connected to pin D5, 2 (base) connected to GND and 3 (collector) connected to IR LED.
You will find that all the codes from your remote all start with the same string of digits, look for the pattern and then you can tell which is the right one. For example all my TV remote IR codes begin with 551.
Stick with it, Iâm about 3 days ahead of you and gone through exactly the same problems. Itâs bloody hard work starting from scratch!
The assumption above is correct.
I donât really see where you see two different schema, could you point me where there is a schema different from what is said above?
To verify that your setup is working just replace the IR led by a normal led, it should light on when you publish your IR code (note my nodemcu blue light switch on also in the same time)