ESP8266 MQTT Client

Special solutions for outdoor model railroading.

Re: ESP8266 MQTT Client

Postby Dagnall » 13.09.2018, 12:14

casperdeboer wrote:i will order an wemos tool from china

Casper, I use the wemos only for my LOCO{mobile} version, because it is small, but for the Stationary modules, for stations etc, I use the NodeMCU on a “NodeMCU Motor Shield”, as this has useful pins with 0V and V+ for each Port.
BUT YOU do need to make some small modifications and add a 5V regulator to give 5V at the power output pins for 5V (standard) servos.
See my user pages :https://wiki.rocrail.net/doku.php?id=users:dagnall53:hardware
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 15.09.2018, 05:52

Hi

It works fine now i have the nodemcu hooked on a seperate 5v power unit. So next is to test it on a test track. I am member of two modelrailroad assotiations one of them uses a modulare lay out and this would be a very great wat to get rid of a lot of wires.

Thnx for all the great work.

Casper
casperdeboer
 

Re: ESP8266 MQTT Client

Postby Dagnall » 15.09.2018, 09:19

casperdeboer wrote:Hi

It works fine now i have the nodemcu hooked on a seperate 5v power unit. So next is to test it on a test track. I am member of two modelrailroad assotiations one of them uses a modulare lay out and this would be a very great wat to get rid of a lot of wires.

Thnx for all the great work.

Casper

Excellent news!
I think it's an interesting idea to use it to add modules wirelessly to a big layout.

I have added a version of the comments I made to you in a new "troubleshooting" page on my user pages to (hopefully) help others having similar trouble getting started.

Dagnall
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 22.09.2018, 07:27

HI

When i try to programm the node to all inputs and after i check if the node mcu is programmed it goes back to the original settings? whaty do i do wrong. Should i check or unchek somethings in the .h file? could you please help me out. Yess i would like if it is nice and stable to implement it on our layout where whe will drive trains and cars.

Casper de Boer
casperdeboer
 

Re: ESP8266 MQTT Client

Postby Dagnall » 22.09.2018, 11:13

Casper, first,sorry,this mail will not have a definitive answer, as my main PC with rocrail and arduino has gone down, I have all the files on a network server, but until I get a new PC or fix the old one any answers will be untested..

I have not personally tested with all io set input or output, only with random selections. There is nothing I know of that would prevent setting all io as inputs, but I cannot test this until I rebuild the PC.
When you change the io to an input or output, the code sets an internal flag that waits of other settings changes, and then after about three or four ( perhaps 10?) seconds, it saves the current io settings to EEPROM. If you are watching the arduino serial monitor or my MQTT debug, this should be seen as a message saying "saving eeprom" ( or something like that). If you switch off the node before the settings are saved, the node will revert on power up to the original settings.. Hopefully you were just not waiting long enough for the code to be saved? I put this delay in to prevent lots of eeprom operations as you change the setup, as the eeprom has( apparently) a limited number or write cycles. I think the blue led on the node also flashed to let you know the settings have been saved to EEPROM, but this may get lost if other things are being done.

If you decide to go down the route of changing the program code defaults, you must note that the code normally looks at the EEPROM first and uses anything there. If there is nothing there, it then looks at the program defaults.. There is a # define option (#define _ForceDefaultEEPROM ) to force the program to use the program defaults, but of course the node must be finally programmed with this off to be able to change settings.
There is also a #define (#define_DefaultPrintOut 1) option in the programming code that sends the whole EPROMs setting out to the serial monitor, so you can 'easily' save it and place it as the "default" in the program. Without having the code in front of me I cannot show you exactly where these defines are, but I hope that as a programmer you would be able to see what to do if you needed this.. If you look in defaults you should see one huge set of defaults for the static code, and another for the mobile code. You could try changing this default, but then you will have to compile with the # define set to defaults applied ( and remove it once this set has been applied, and reprogram without the set to defaults applied.. Very tedious! ).
There is also a semi hidden code sequence to revert to defaults that uses the rocrail reprogram node tab, but it's complex, and without a working version in front of me I may explain it wrong. I may have explained it in one of my code notes..

I am not sure what you mean by "after i check if the node mcu is programmed" but I hope the answer to your problem is simply that you have not known to wait for the EEPROM to be saved, but i look forward to seeing your next note, and will try to get my setup back up and running so I can be more helpful.

( I looked in the GitHub, and all the programming defines are in 'directives.h' and are reasonably well explained.. )
Thankful that my iPad still works..

Dagnall
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 22.09.2018, 14:22

Hi

This evening i Will try this. What i meant was afterparty staving from rocrail rocnet programmer you van also Read data from node. I think i dit not wait long enough.

Thnx for your quick andere.

Casper
casperdeboer
 

Re: ESP8266 MQTT Client

Postby Dagnall » 22.09.2018, 16:47

casperdeboer wrote:Hi

This evening i Will try this. What i meant was afterparty staving from rocrail rocnet programmer you van also Read data from node. I think i dit not wait long enough.

Thnx for your quick andere.

Casper

Yes, that sounds possible, 'read' will read the dynamic memory, but this is not stored until the EEPROM save time is completed. If you leave it 'alone' after doing all your changes, you should see the blue light blink when it saves to EEPROM ( I think!).
Let me know if this works.

My old PC is still kerplunk.. But I'm working on it..

Dagnall
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 22.09.2018, 17:21

Ok

i Will let you know. Where are you from?.

Casper
casperdeboer
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 22.09.2018, 20:01

hi

tried different things but still my changes arent saved to th eeeprom . I commented the lines default eeprom save and default printout. But stil the eeprom wont keep my desierd setup. It still goes back ot the default settings. I did the changes in the directive.h.

Hope your pc is reapaird soon and you can help me out.

Casper
casperdeboer
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 23.09.2018, 14:39

Have tried a different sketch also made by you and this works.
casperdeboer
 

Re: ESP8266 MQTT Client

Postby Dagnall » 23.09.2018, 16:55

Casper, FYI I am in uk.
Thank you for using English, I can use google translate, but it can sometimes introduce difficulty in understanding details.

Does your most recent post mean you have solved the problem?

If not, can you copy your directives.h so I can check it? I am afraid that I have lots of possible directives for the various options, and some interactions may not be obvious.

My PC is sort of working, but is only running very slow, perhaps a disk problem.. I have not had it running the necessary rocrail and arduino for testing yet.

Cheers Dagnall
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Re: ESP8266 MQTT Client

Postby casperdeboer » 23.09.2018, 17:41

Yes solved it. Most people van talk and writer english.

Casper
casperdeboer
 

Re: ESP8266 MQTT Client

Postby Dagnall » 23.09.2018, 21:02

Casper.
I have my PC working well enough to repeat the issue and solve it ! (as I think you have)..

The "problem/bug" is that the PI03 "Channel" Setup options to make a pin a PWM Output or SERVO Output ("Blink" or "Servo") take priority over the Pi02 "Port" Type/direction settings ("Input" /"Output").

So, If you have any of the "Channel" pins set to Blink or Servo, then the Pi02 Port Type/direction will always be set(forced) to "Output". (Note: It will report "Output" if you "get" the settings, to show that it is an Output)

- You may have to "set" and "get" the port / channel settings a few times to confirm what you have set if you have problems, and check you have not set Blink or servo in the Channel settings...
If you have the Arduino Serial Monitor running you should see the result of the "PortSetupReport()" function that is called as part of the commit EEprom sequence. This sends out something like this:
Code: Select all
*Debug Message:<20:50:41s>  Node:28 (Wood St) Msg:Commiting EEPROM 
Commiting EEPROM
 ---- Switching OFF ALL Servos---
 Port :0 is SignalLED  Output (FIXED) Pi02 PortType :0  Pi03_Setting_options:0
 Port :1 is Input with pullup Pi02 PortType :1  Pi03_Setting_options:0
 Port :2 is Input with pullup Pi02 PortType :1  Pi03_Setting_options:0
 Port :3 is Input with pullup Pi02 PortType :65  Pi03_Setting_options:0
 Port :4 is Input with pullup Pi02 PortType :65  Pi03_Setting_options:0
 Port :5 is Input with pullup Pi02 PortType :1  Pi03_Setting_options:6
 Port :6 is Input with pullup Pi02 PortType :65  Pi03_Setting_options:0
 Port :7 is Input with pullup Pi02 PortType :1  Pi03_Setting_options:1
 Port :8 is Input with pullup Pi02 PortType :1  Pi03_Setting_options:1
---------------------- LOCO Setup   -----------------------
          'Locomotive Address' is7


Ports 3,4 and 6 are set "inverting" (hence the "PortType : 65")
(Note you cannot change port 0 settings!!, and it still sends out the nodes "loco address" even if it is not a loco..)

The Commit to EEprom happens quite quickly after the setting, so this was not the issue.

I may try and expand this configuration report display and send it to the MQTT debug, but that may have to wait a while, unless you would like to try?

Cheers
Dagnall
ESP8266 Based RocNet Universal 8 i/o decoder and Mobile Decoder. http://wiki.rocrail.net/doku.php?id=users:dagnall53:description
G Scale 3D printed Locos and wagons : (on Thingyverse)
Dagnall
 

Previous

Return to Garden Railroads