Project: RFLink to MQTT using ESP8266 and arduino IDE

I’ve got a strange behavior, I dont know if it’s normal.

Everytime I send a command (and this is working), I’ve got juste after an MQTT entry “online” :

RF/status online
RF/command 10;NewKaku;0110b000;2;ON

RF/status online

as you can see in my mosquito_sub, I have a “\n”, the one I’ve put in home-assistant.
I’m losing one ping packet, so I suppose ESP is rebooting. But don’t know why because I’m using ‘\n’ as asked.

I have the same behavior with a direct publish on mqtt with ‘\n’ :

pi@rpi3-dev:~$ mosquitto_pub -h 127.0.0.1 -t RF/command -m "10;NewKaku;0110b000;2;ON
> "
pi@rpi3-dev:~$

It would seem to be my crappy arduino coding!

I will try and have a look later (at work now)

Might just need some management of the payload coming in from MQTT to ensure it has a trailing \n or \0 if you are keen to attempt yourself.

Thx, I gonna try by myself with test mode, but I’m not sure I have the knowledge to fix it. to be continued :slight_smile:

Hi @phileep,

Last News :
I’ve tried to debug without success. I have a an Exception(28) with a stack trace every time i use swSer. I change the SoftwareSerial lib with the one design for ESP : https://github.com/plerup/espsoftwareserial but i have the same problem.

So you use another library with your code ?

Will check what library I have installed.

Does your unit transmit an RF code before crashing?

Also, what pins are you connecting to on your NodeMCU? some pins are a bit special and might cause issues I think. Will confirm what I am using also tonight.

I’m using D5/D6 pin, so it must be GPIO12/14.

Yes, RF is transmit and execute by RFLink, but just after this ESP is crashing.

I’ve tried to do the same with swSer commented and no more crash, so i’m quite sure the problem is SoftwareSerial.

PS : small Fix for you about ‘\n’, it seems swSer.println is what you need to remove ‘\n’ from hass config.

Hi
I tried this project too, but replaced my 433 mhz devices with ESP8266/Sonoff instead.
I didn`t get this working when trying, but found this statement in the RFlink Hub page (Component): Due to different logic levels, a voltage level shifter is required between the 3.3V NodeMCU and 5V Arduino MEGA 2560 pins.

I cant see that phileep mentions this, but if you dont have on installed, maybe the ESP restart or maybe the voltage level shifter was reason why I could not get this working :slight_smile:

Hum, i have not this part. What is the difference between level shifter and level regulator ? I can just puta lm1117 ?

hmm. Not sure. I think lm1117 could interupt/change the signals. Maybe a electronics guy could help us.

When looking up the type I bought I found this in additional information part: The level converter is very easy to use. The board needs to be powered from the two voltages sources (high voltage and low voltage) that your system is using. High voltage (5V for example) to the ‘HV’ pin, low voltage (3.3V for example) to ‘LV’, and ground from the system to the ‘GND’ pin.

I think I found out why I didnt get it to work… I only supplied 5v and thought I could use the LV side for other stuff… :smiley:

I’ve made a level shifter for both side, but it doesn’t help.

I have continue my debug, and if I remove the wire from TX Arduino to RX ESP, it works. I can’t read data from RFLink, but activate is OK et non crash. So I suppose the problem is when RFLink say OK to the command I sent.


EDIT:

@phileep @Rune Found It !! I will propose a pull request on gitHub.
The problem is that RFLink send 20;xx;OK; when you send a command. (New in R46 ? if you dont have the problem ? )
The void parseData crash when it tries to get RFData. So if RFName == OK => return; to exit void. And ESP is running fine. I will add the fix for \n too. I hope I will get time this WeekEnd to propose it.

1 Like

Did you end using the level shifter?

It works with and without, so i have removed it

1 Like

Not using a level shifter is a slight risk.

However it is only on the communications in to the ESP8266, and the NODEMCU units seem tolerant, especially to such short bursts.

If you want to be sure, cheapest is a voltage divider on the TX from the MEGA as that is 5v logic. google voltage divider - you only need 2 resistors of different ratings to get the voltage down to the proper 3.3v range for the ESP.

The proof you don’t need on is that all the inward signals have been working fine. ie we can get data from the RFLink mega without the shifter.

Great work @Minims.

Will await your PR - let me know if you want me to add it by hand, although you deserve the credit in the reopo!

Some time ago the CEO of Espressif apparently tweeted that the ESP’s can handle 5V no issues.

:smiley:

1 Like

@phileep PR done, I have list my changes in the commit comment. I hope it will help :-).

No crash since I’ve applied the fix. I now use a generic ESP-12F instead of my node MCU. I use the 3.3v power of the MEGA and it seems working great.

About level shifter, I 've had a voltage divider with 1k/2k resistors just for security and because it’s not the Node MCU version.

1 Like

I thought I give this a try but I’m stuck at the point of trying to login to MQTT for the lack of mqtt username and password within the Esp sketch, need your help.
thank you.

The sketch is not setup currently for a mqtt password.

You need to add it to the sketch.

I think it is as simple as adding the username & password to the mqtt client conect statement at about line 125
change if (client.connect(client_name, willTopic, 0, willRetain, willMessage)) {
to if (client.connect(client_name, username, password, willTopic, 0, willRetain, willMessage)) {

Where you define variables in the sketch or input directly your own username and password in this statement.

For more information on the syntax, see http://pubsubclient.knolleary.net/api.html#connect4

Hopefully this will get you going

Thanks that done the trick will commence with my testing. :slight_smile:

Hi,

I did make a pull request a few months ago, to fix stability, negative temperatures and Mqtt authentication. It doesn’t appear to have been merged yet.

Guys, it is not clear to me. I connected my Arduino with Rflink to NodeMCU with ESP-LINK. Esp-Link is supporting:

  1. MQTT
  2. Serial over Wifi

How do I connect with the latter to Home Assistant?

The documentation is missing how to setup Esp-Link, port etc.? While there is an information that it has been tested with Esp-Link:

Tested with Wifi serial bridge [esp-link V2.2.3](https://github.com/jeelabs/esp-link/releases/tag/v2.2.3) running on a NodeMCU (ESP8266 Wifi module) with ESP8266 TXD0 (pin D10) and RXD0 (pin D9) connected to Arduino MEGA 2560 RX (Pin 2) and TX (Pin 3) respectively.