Follow the github link from the downloads page for the binary file to download, and right above it the pdf file to show you what to do with it…
When you power up an mqTrains module, on first power up, it will create an access point (AP) mqTrains-0001 and you can use your computer, phone or tablet to connect to it…you then proceed to 126.96.36.199 with your browser to get to the web page to configure it, and when you are successful in configuring your SSID, WepKey, MQTT’s IP Address and the base topic to subscribe too, it will reboot, connect to your WiFi router, connect to the MQTT broker (server) and publish the IP address of the module to with
"/baseTopic/IPA 10.10.10.172 is here!", and now you know where to find the web page again to configure the servos and I/O as you need. The AP will turn off once the module publish the IPA message. Next power cycle AP on again and off when IPA is published. So you have a way to reconnect to it on power up. But, if you don’t have a way to see the MQTT messages easily, we just added and tested a very inexpensive SSD1306 OLED LCD module (also explained in a Random Nerd Tutorial here). So consider having one or two LCDs handy to monitor your first mqTrains device:
Starting mosquitto from the command line, you can use the ‘-v’ (or ‘–verbose’) option for showing verbose messages…this will override the
logtype option in the config file. So first step, when something is not going right, start the MQTT server manually with
mosquitto -v and watch what the server does while you debug the problem.
If you don’t have direct access to the Broker/Server, you can also check out MQTTBox http://workswithweb.com/mqttbox.html, works on most platforms…great tip from David B., thank you.
Create a new MQTT Client, with some unique MQTT Client Name (MeBox will work), select the protocol you are using in your application, and enter the hostname or IP address for the Host. Enter Username and Password, if used, and check or uncheck all the other boxes that are application to your setup. Then click Save and selecting the “MeBox” client in the list, will allow you to add Publishers to Publish to a Topic, or Subscribers to Subscribe to one or more Topics, with the wildcards (Single Level ‘+’ and Multilevel ‘#’) , as usual.
Very easy to monitor and interact with the MQTT Server: a Published message has a “Publish again” arrow, avoiding quite a but of typing.; restarting MQTTBox will automatically connect (if the option was selected), but you will need to click the Subscribe button in each Subscriber window.
Monitoring the verbose output in the debug window in the Arduino 1.8.12 IDE, we see:
C:\Users\name\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3 C:\Users\name\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.0/tools/upload.py --chip esp8266 --port COM4 --baud 115200 --before default_reset --after hard_reset write_flash 0x0 mqTrainsIO_xxx.bin
esptool.py v2.8 Serial port COM4 Connecting......_
Enable verbose output with Settings (Ctrl+Comma). File -> Preferences -> Show verbose output during: [ x ] compilation [ x ] upload
So, if we do this in Linux or on a Mac or Raspberry Pi:
All we need is
sudo apt-get update
sudo apt-get install python python-pip
sudo pip install esptool
esptool.py --chip esp8266 --port /dev/ ttyUSB0 --baud 460800 --before default_reset --after hard_reset write_flash 0x0 mqTrains_ServoPCA_1.0_1MB.bin
For the Windows kind, there is a Nodemcu-Flasher tool here in a 32 and 64 bit version which you can specify the bin file on the Config tab:
Set the appropriate Flash Size, Flash speed and SPI Mode on the Advanced tab:
And then head back to the Operation tab and a click “Flash(F)”:
Of course, the Windows device driver needs to be in place for the USB programmer you are using (COM7 shown here).
We also recommend using this little DYI Mall programmer which avoids the slide switch at power up to be in program mode, but instead gives you a reset button and the same 8 pins on the ESP-01 to connect to the next i2c board:
Select Files and Service
To start the service, Computer Management (right-click on My Computer, Manage) -> Services and Applications->Services->Mosquitto Broker->right click->Start
(You can also set the service to Automatic in right click on the service->Properties->Startup type)
If not run as a service, you can start it with
C:\”Program Files”\mosquitto\mosquitto.exe -v -c “C:\Program Files\mosquitto\mosquitto.conf”
To test, run:
C:\Program Files\mosquitto\mosquitto_sub -h localhost -v -t “TxNamib/#”
If the service is not running or accessible, the error wil show:
Error: No connection could be made because the target machine actively refused it.
Else, you will only see a message if it was “retained”, or you publish something to TxNamib now
C:\”Program Files”\mosquitto\mosquitto_pub -h localhost -t “TxNamib/servo.2003/03” -r -m “CLOSED”
C:\”Program Files”\mosquitto\mosquitto_pub -h localhost -t “TxNamib/servo.2003/03” -r -m “THROWN”
Ubuntu and Raspberry Pi (3, 4, 400 and Zero W):
sudo apt-get install mosquitto
snap install mosquitto
Older versions of Ubuntu:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
Welcome to the mqTrains WordPress site. This is our first post!