Commit 2f8c0abc authored by Wouter Klop's avatar Wouter Klop

Implementation of mDNS. Both OTA and web page access are now much easier, no...

Implementation of mDNS. Both OTA and web page access are now much easier, no messing with IP addresses.
parent 2447acc2
......@@ -30,6 +30,10 @@ Assembly is quite straightforward. For those who like some instructions, here go
IMPORTANT: adjust the voltage regulator to 5V BEFORE inserting any modules. By default, the voltage regulator is set to a higher voltage, and if you don't adjust it, you'll fry some components.
## Advanced
You can de-solder de current adjustment potentiometer on the stepper driver breakout boards. Add a wire to the wiper terminal, and connect the (two) wires to J4. Current can then be adjusted via the web interface. Or, get creative, and implement some current saving functionality.
For better performance, you can tie the decay mode pin of the DRV8825 to VCC, setting it in fast mode. The DRV8825 sometimes skips steps in slow/mixed decay mode.
# BOM
Applicable for v1.1. v1.0 doesn't have R7.
......
......@@ -13,18 +13,32 @@ Open src/main.cpp. You should now be able to combile (ctrl+alt+B).
For uploading, I strongly prefer OTA, as this works very nice in PlatformIO.
## Serial port
For the first upload, you'll need to upload via USB / the serial port. In platformio.ini, state the COM port under which the ESP32 module is connected (uncomment the line with an IP address), for example
For the first upload, you'll need to upload via USB / the serial port. In platformio.ini, state the COM port under which the ESP32 module is connected (uncomment the line with an IP address / host name), for example
upload_port = COM3.
; upload_port = 192.168.178.33
; upload_port = balancingRobot.local
Hit the upload button. Currently, the auto reset functionality of the ESP32 module doesn't seem to work, see Issue #10. So, once the message "Serial port COMx" appears, press the enable and boot buttons on the module. First release the boot button, then the enable button. You might have to try a few times. Luckily, once succeeded with the serial upload, you can use OTA upload.
## OTA upload
When the ESP32 boots, it's IP address is printed. In platformio.ini, fill in this IP address under upload_port. Make sure to be connected to the same WiFi network as the ESP32.
When the ESP32 boots, it's IP address is printed. In platformio.ini, fill in this IP address under upload_port. Or, even better, use the hostname balancingRobot.local. This means you don't have to mess around with IP addresses. Make sure to be connected to the same WiFi network as the ESP32, and hit upload.
# WiFi connection
After flashing, the ESP32 will start an access point (AP), named balancingRobot. The default key is "turboturbo". Once connected, open the balancingRobot web configuration page. Here, among others, you can change the WiFi options. Under "WiFi configuration", enter the SSID and key of your home network, change the selector from "AP" to "SSID", and click the "set" button, followed by the "reboot" button. If all goes well, the ESP32 will now connect to your home network.
Don't forget to check the ESP32's IP address, and update this in platformio.ini. I like to assign a fixed IP address to the ESP32 (via the router).
If you are using an IP address instead of host name, don't forget to check the ESP32's IP address, and update this in platformio.ini. It is probably wise to assign a fixed IP address to the ESP32 (via the router).
If the home network cannot be found, the AP will be started.
# Web page editor
hostName.local/edit
User/pass: admin, admin
Be aware though that changes here are not kept on your PC, so make sure to copy and paste everything.
# Plotting signals
hostName.local/plotTest.htm
To be merged into index.htm
For this to work, first load plotTest.htm, then index.htm. This allows to view signals, while simultaneously adjusting parameters.
......@@ -15,5 +15,4 @@ framework = arduino
monitor_port = COM3
monitor_speed = 115200
; upload_port = COM3
upload_port = 192.168.178.33
; upload_port = 192.168.4.1
upload_port = balancingrobot.local
......@@ -124,6 +124,9 @@ float gyroGain = 1.1;
float steerFilterConstant = 0.7;
float speedFilterConstant = 0.9;
// -- WiFi
const char host[] = "balancingrobot";
// ----- Interrupt functions -----
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
......@@ -230,7 +233,7 @@ void setup() {
Serial.println(WiFi.softAPIP());
}
ArduinoOTA.setHostname("balancingRobot");
ArduinoOTA.setHostname(host);
ArduinoOTA
.onStart([]() {
String type;
......@@ -257,7 +260,11 @@ void setup() {
ArduinoOTA.begin();
Serial.println("Ready");
// Start DNS server
if (MDNS.begin(host)) {
Serial.print("MDNS responder started, name: ");
Serial.println(host);
}
httpServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Loading index.htm");
......@@ -275,6 +282,9 @@ void setup() {
wsServer.begin();
wsServer.onEvent(webSocketEvent);
MDNS.addService("http", "tcp", 80);
MDNS.addService("ws", "tcp", 81);
// Make some funny sounds
// for (uint8_t i=0; i<150; i++) {
// motRight.speed = 500 + i*10;
......@@ -291,6 +301,8 @@ void setup() {
pidSpeed.setParameters(6,5,0,20);
pidSpeed.setpoint = 0;
Serial.println("Ready");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment