Notifications
Clear all

ESP32 WiFi Access Point Creation Issues

23 Posts
3 Users
2 Likes
626 Views
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

Gone Flying, Sailing, or Both..


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@helisteve FYI @dronebot-workshop I can probably help but I don't see the body of the post, just the topic.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1085
 

@zander Yes, we seem to be having an issue with this - it's the second attempt today.  I'm waiting to hear back for more details.

@helisteve If you can see this Steve, please reply on this thread. And please check your email, I sent you a message a few minutes ago.

😎

Bill

 

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@dronebot-workshop Ok, I thought maybe it was me or my Mac, my one Win PC has lost it's mind and I was worried it was contagious.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

Hi guys. I do not see any text or code either. I guess if I can't even post it's no wonder I can't get my code working, ha-ha. I can try reposting in a response. What do you think Bill?

Gone Flying, Sailing, or Both..


   
ReplyQuote
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

Let's try again.

Hello Fellow DroneBots.

 

I am completely befuddled by the error I am getting in my current project code. I am using the ESP32 to create an access point that I connect to with an app on my phone. I copied the code from a previous project doing a similar type thing. That project works great. So I assumed using the code for my new project would work equally well. Boy was I surprised.

 

I am getting an assert failed error. What is that? If I comment out the server.begin() statement then no errors, but no access point either of course. I have no idea what is going on, and I have not been able to figure out how to find the problem. I have even tried new modules with no luck. If I reprogram the ESP32 with my old code it works fine as expected. Reprogram with my new program and the error returns. I have stared at the code until I was cross-eyed, but I have yet to find the problem. So I am hoping one of you may have seen this before and can tell my what I am doing wrong.

 

This is my first post so hopefully I did it correctly. Please let me know if I did not.

 

Below is the non-working code and error message

#include<WiFi.h>
#include<WebServer.h>
#include"esp_wifi.h"


#defineleftDIR13      // Left motor direction   GPIO13
#definerightDIR12      // Right motor direction  GPIO12
#defineleftPWM14      // Left motor PWM         GPIO14
#definerightPWM27      // Right motor PWM        GPIO27


#defineledLight4       // Light  GPIO4


#defineFORWARD   LOW
#defineREVERSE   HIGH
#defineOFF0
#defineduty2580
#defineduty50127
#defineduty75180
#defineduty100255


#defineBT_DISCOVER_TIME10000


String command;                                     //String to store app command state.
int speedCar =0;                                   // 0 to 255


//SSID and Password to your ESP Access Point
constchar* ssid ="Robot Wifi";
constchar* password ="robot";


WebServerserver(80);


String myName ="ESP32-Robot-Control";


/**************************************
*
*/
voidsetup()
{  
digitalWrite(leftDIR, FORWARD);
digitalWrite(rightDIR, FORWARD);
analogWrite(leftPWM, OFF);
analogWrite(rightPWM, OFF);


pinMode(leftDIR, OUTPUT);
pinMode(rightDIR, OUTPUT);
pinMode(leftPWM, OUTPUT);
pinMode(rightPWM, OUTPUT);
pinMode(ledLight, OUTPUT);


Serial.begin(115200);
 // Start WiFi AP HOTspot, removing password will disable security
if(!WiFi.softAP(ssid, password)) {
Serial.println(F("Soft AP creation Failed.."));
  }                      
  // Show IP address.
  IPAddress myIP =WiFi.softAPIP();
Serial.print("ESP32 AP IP address: ");
Serial.println(myIP);
  // Start WEB-server  
server.on( "/", HTTP_handleRoot);
server.onNotFound(HTTP_handle_NotFound);
server.begin();
Serial.println("ESP32 WiFi Robot Controller.");
Serial.println("Build 02, Date : 1/10/2024");    
} // End of setup()
 
The error message it prints out.
 
Rebooting...
ets Jul 29 2019 12:21:46
 
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Soft AP creation Failed..
ESP32 AP IP address: 0.0.0.0
 
assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)
 
 
Backtrace: 0x4008374d:0x3ffb1f70 0x4008bd51:0x3ffb1f90 0x40091359:0x3ffb1fb0 0x400eef5a:0x3ffb20e0 0x400ff3ed:0x3ffb2110 0x400ff44d:0x3ffb2130 0x400ee749:0x3ffb2180 0x400d4bf2:0x3ffb21a0 0x400d4c6c:0x3ffb21f0 0x400d6bd9:0x3ffb2210 0x400d2c7e:0x3ffb2230 0x400d9c96:0x3ffb2290
 
 
 
Hopefully this will post. Fingers crossed Bill.
 
 
 
 
 

Gone Flying, Sailing, or Both..


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1085
 

@helisteve Looks perfect to me Steve!

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1085
 

@helisteve As for your code, I'm curious about the line that says 

WebServerserver(80);

Perhaps I'm not reading it correctly, but shouldn't it be

WebServer server(80);

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

@dronebot-workshop Hi Bill, it is correct in my code with the space like needed. I sure wish that was it. Not sure why it removed it when I posted. Seems I'm not having good luck with my first post.

Gone Flying, Sailing, or Both..


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@helisteve It looks like a lot of your code is missing white space, perhaps you are editing with an editor that inserts something other than a ' ' (blank) (space) like a tab perhaps.

Use the Arduino IDE and do a Menu Tools Auto Format for starters, then insert BLANKS (space bar) where needed (my compile shows lot's of errors) All the defines, the ServerServer that Bill pointed out. Set compiler warnings to maximum and fix everything.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@helisteve Here is your code fixed up re white space. There are 2 errors marked with //RCA that I leave to you to fix.

Q, shouldn't pinmode come before the writes?

#include <WiFi.h>
#include <WebServer.h>
#include "esp_wifi.h"


#define leftDIR 13   // Left motor direction   GPIO13
#define rightDIR 12  // Right motor direction  GPIO12
#define leftPWM 14   // Left motor PWM         GPIO14
#define rightPWM 27  // Right motor PWM        GPIO27


#define ledLight 4  // Light  GPIO4


#define FORWARD LOW
#define REVERSE HIGH
#define OFF 0
#define duty2580
#define duty50127
#define duty75180
#define duty100255


#define BT_DISCOVER_TIME 10000


String command;    //String to store app command state.
int speedCar = 0;  // 0 to 255


//SSID and Password to your ESP Access Point
const char* ssid = "Robot Wifi";
const char* password = "robot";


WebServer server(80);


String myName = "ESP32-Robot-Control";


/**************************************
*
*/
void setup() {
  digitalWrite(leftDIR, FORWARD);
  digitalWrite(rightDIR, FORWARD);
  analogWrite(leftPWM, OFF);
  analogWrite(rightPWM, OFF);


  pinMode(leftDIR, OUTPUT);
  pinMode(rightDIR, OUTPUT);
  pinMode(leftPWM, OUTPUT);
  pinMode(rightPWM, OUTPUT);
  pinMode(ledLight, OUTPUT);


  Serial.begin(115200);
  // Start WiFi AP HOTspot, removing password will disable security
  if (!WiFi.softAP(ssid, password)) {
    Serial.println(F("Soft AP creation Failed.."));
  }
  // Show IP address.
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("ESP32 AP IP address: ");
  Serial.println(myIP);
  // Start WEB-server
  //RCAserver.on("/", HTTP_handleRoot);
  //RCAserver.onNotFound(HTTP_handle_NotFound);
  server.begin();
  Serial.println("ESP32 WiFi Robot Controller.");
  Serial.println("Build 02, Date : 1/10/2024");
}  // End of setup()

void loop() {
  // put your main code here, to run repeatedly:

}

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

@zander I am using the Arduino IDE 2.x and it looks fine for me. I will try your suggestions and see how that looks. It looks like I can now post photos so maybe I can try that also. Thank you.

Gone Flying, Sailing, or Both..


   
ReplyQuote
HeliSteve
(@helisteve)
Member
Joined: 4 months ago
Posts: 20
Topic starter  

@zander Thanks for the quick reply. I am confused with your two statements:

RCAserver.on( "/", HTTP_handleRoot);

RCAserver.onNotFound(HTTP_handle_NotFound);
 
I have both of those in my code without the RCA prefix. Did I miss what you are telling me to fix?
 
Second, I always set my outputs to the value I want before setting them as outputs. I've always felt this was a better way. Maybe it's not.
 

Gone Flying, Sailing, or Both..


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@helisteve Those two lines have errors, so I just commented them out as I didn't know the fix off the top of my head. Remove the //RCA and compile so you can fix.

AFAIK you MUST set the pinmode first. What you are doing is pressing the throttle before turning the key although that is a horrible example. It's proly not the source of your error, but it is wrong. Just because it compiles doesn't mean it's right.

I have tried to test, but am unable as my FREE WiFi6e router is not configurable vis-a-vis the internal network and the router uses 192.168.4.1 as it's address. Apparently, they don't know that it is not just wrong; it's illegal from an internet law perspective.

If I were you I would find an example sketch that does something similar and make sure it works, then see what is different. I have tried, but since the softap uses 192.168.4.1 I can't go any further until I either get a new router, or figure out how to force the softap to a different address.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@helisteve This is your error (see pic)

the assert is a C++ thing, I am not a C++ expert so my lingo may be wrong but it's a run time check that checks basic stuff like is a var all numeric or similar. If you look at the entire line, it should mean something to you as the author of the code, albeit several hundreds of LOC below your source.

Maybe fix the obvious stuff first and get the AP to work. My hunch is the assert will not happen when you have a valid AP established.

 

Screenshot 2024 01 11 at 13.33.04

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Page 1 / 2