¿ªÔÆÌåÓý

Locked Re: MQTT Connection in JMRI


 

[ This might be completely Off Topic, only because I don't know how to contact Sir Rood other wise ]

Chris,?

When I hand 5 ESP8266 ESP-01's to another guy for use on his layout, he would need to store the WiFi SSID and password, plus the MQTT ip address (at least) somewhere on the ESP-01, and if it is not in EEPROM, it needs to be in code...so does he give me this private information or do I give him the source code and expect him to load it in? EEPROM seemed to be a perfect fit for this need.?

But, a little more important?(since we could have use defaults for all the prior values, in a perfect world), my servos move between the default PWM values of 200 (Closed) and 300 (Thrown) and most of them need another small adjustment to completely close the points. Now, without hinting anything JMRI+MQTT could be doing, since a 0/1 or a Closed/Thrown is sufficient: you can send a "C193" (or a "C-7") to servo.0001/01 and it would move it to 193 (or 7 further to the outside), and then store THAT value in EEPROM, while?publishing a "Closed" to the same topic, so other listeners (who has not clue what to do with "C193") would get the "Closed" and update the Panel View, Signal, or whatever. Similar thing happens when you send a "T344", it moves to Thrown at 344, save to EEPROM and update MQTT with "Thrown".? Then after a power cycle, the ESP remembers where the C and T positions are for each of the 16 servos. You can also publish an "EEP?" to the "setup" channel ("servo.0001/00") and it would spit out all the EEPROM data to a servo.0001/EEP01 and servo.0001/EEP02 topic (Why 2? MQTT messages have 64 byte limits, and I like to see the hexadecimal values on my computer screen and not binary).

I use the EEPROM in a similar fashion to tell the ESP how many inputs and outputs there are on the i2c connected port expander, so it would know which ones to poll as inputs and which ones to subscribe to and update as outputs. So the next guy can now configure his ESP the way he likes without touching the code. All the EEPROM values can be updated through MQTT, which is a little harder when the WiFi is not set up yet, but the Serial port on the ESP provides a similar command set to allow all these changes...so the next guy only need one?ESP-01 to USB "Serial" board to set up the WiFi and MQTT server address, and from there Node Red or a phone app like MQTT Dash can do the rest.

If a board goes up in flames (don't worry, only happened once, when the 5V was not close enough to the required 3.3V), I have a Python script that takes the ESP01 and ESP02 hexadecimal values and populate the replacement board. Since my mosquitto_sub saved all the messages in a setup.txt file!

Does it makes some sense?

[ Thank you guys, back to the topic now! ]

Speed

Join [email protected] to automatically receive all group messages.