Esp32_cam not connected to my network

Hi, I’m trying to upload the code from https://github.com/edgeimpulse/example-esp32-cam So I copy/pasted the code to the Arduino IDE and I get this error: initializing argument 1 of ‘int WiFiClass::begin(char*, const char*)’
int begin(char* ssid, const char passphrase);
^
exit status 1
invalid conversion from 'const char
’ to ‘char’ [-fpermissive]

To solve this error
char ssid[] = "YOUR_SSID"; ***// this is changed*** const char* password = "YOUR_PASSWORD"; ***// this is fine*** [...] WiFi.begin(ssid, password);

I remove const char* to char … and error is also solved but my esp32_cam board is not connecting my Hotspot … (however I already verified H/w it is perfectly working fine. )

PLEASE HELP ME TO GET THROUGH !!
Many Thanks :slight_smile:

Hello @himani.upadhyay,

I never had an issue with this two variables declaration:

const char* ssid = "your-ssid";
const char* password = "your-password";

Are you sure you are using the right WiFi library? It can sometimes create a conflit between two different libraries.

Regards,

Louis

Hi, @louis
Many thanks for reply …

I don’t Know what is the exact problem about why esp32cam is not connected with Arduino IDE…

Here I’m attaching my file …
Pl. have look into it.

My wifi.h file

/*
WiFi.h - Library for Arduino Wifi shield.
*/

#ifndef WiFi_h
#define WiFi_h

#include <inttypes.h>

extern "C" {
	#include "utility/wl_definitions.h"
	#include "utility/wl_types.h"
}

#include "IPAddress.h"
#include "WiFiClient.h"
#include "WiFiServer.h"

class WiFiClass
{
private:

    static void init();
public:
    static int16_t 	_state[MAX_SOCK_NUM];
    static uint16_t _server_port[MAX_SOCK_NUM];

    WiFiClass();

    /*
     * Get the first socket available
     */
    static uint8_t getSocket();

    /*
     * Get firmware version
     */
    static char* firmwareVersion();


    /* Start Wifi connection for OPEN networks
     *
     * param ssid: Pointer to the SSID string.
     */
    int begin(char* ssid);

    /* Start Wifi connection with WEP encryption.
     * Configure a key into the device. The key type (WEP-40, WEP-104)
     * is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
     *
     * param ssid: Pointer to the SSID string.
     * param key_idx: The key index to set. Valid values are 0-3.
     * param key: Key input buffer.
     */
    int begin(char* ssid, uint8_t key_idx, const char* key);

    /* Start Wifi connection with passphrase
     * the most secure supported mode will be automatically selected
     *
     * param ssid: Pointer to the SSID string.
     * param passphrase: Passphrase. Valid characters in a passphrase
     *        must be between ASCII 32-126 (decimal).
     */
    int begin(char* ssid, const char *passphrase);

    /* Change Ip configuration settings disabling the dhcp client
        *
        * param local_ip: 	Static ip configuration
        */
    void config(IPAddress local_ip);

    /* Change Ip configuration settings disabling the dhcp client
        *
        * param local_ip: 	Static ip configuration
	* param dns_server:     IP configuration for DNS server 1
        */
    void config(IPAddress local_ip, IPAddress dns_server);

    /* Change Ip configuration settings disabling the dhcp client
        *
        * param local_ip: 	Static ip configuration
	* param dns_server:     IP configuration for DNS server 1
        * param gateway : 	Static gateway configuration
        */
    void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway);

    /* Change Ip configuration settings disabling the dhcp client
        *
        * param local_ip: 	Static ip configuration
	* param dns_server:     IP configuration for DNS server 1
        * param gateway: 	Static gateway configuration
        * param subnet:		Static Subnet mask
        */
    void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);

    /* Change DNS Ip configuration
     *
     * param dns_server1: ip configuration for DNS server 1
     */
    void setDNS(IPAddress dns_server1);

    /* Change DNS Ip configuration
     *
     * param dns_server1: ip configuration for DNS server 1
     * param dns_server2: ip configuration for DNS server 2
     *
     */
    void setDNS(IPAddress dns_server1, IPAddress dns_server2);

    /*
     * Disconnect from the network
     *
     * return: one value of wl_status_t enum
     */
    int disconnect(void);

    /*
     * Get the interface MAC address.
     *
     * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
     */
    uint8_t* macAddress(uint8_t* mac);

    /*
     * Get the interface IP address.
     *
     * return: Ip address value
     */
    IPAddress localIP();

    /*
     * Get the interface subnet mask address.
     *
     * return: subnet mask address value
     */
    IPAddress subnetMask();

    /*
     * Get the gateway ip address.
     *
     * return: gateway ip address value
     */
   IPAddress gatewayIP();

    /*
     * Return the current SSID associated with the network
     *
     * return: ssid string
     */
    char* SSID();

    /*
      * Return the current BSSID associated with the network.
      * It is the MAC address of the Access Point
      *
      * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
      */
    uint8_t* BSSID(uint8_t* bssid);

    /*
      * Return the current RSSI /Received Signal Strength in dBm)
      * associated with the network
      *
      * return: signed value
      */
    int32_t RSSI();

    /*
      * Return the Encryption Type associated with the network
      *
      * return: one value of wl_enc_type enum
      */
    uint8_t	encryptionType();

    /*
     * Start scan WiFi networks available
     *
     * return: Number of discovered networks
     */
    int8_t scanNetworks();

    /*
     * Return the SSID discovered during the network scan.
     *
     * param networkItem: specify from which network item want to get the information
	 *
     * return: ssid string of the specified item on the networks scanned list
     */
    char*	SSID(uint8_t networkItem);

    /*
     * Return the encryption type of the networks discovered during the scanNetworks
     *
     * param networkItem: specify from which network item want to get the information
	 *
     * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
     */
    uint8_t	encryptionType(uint8_t networkItem);

    /*
     * Return the RSSI of the networks discovered during the scanNetworks
     *
     * param networkItem: specify from which network item want to get the information
	 *
     * return: signed value of RSSI of the specified item on the networks scanned list
     */
    int32_t RSSI(uint8_t networkItem);

    /*
     * Return Connection status.
     *
     * return: one of the value defined in wl_status_t
     */
    uint8_t status();

    /*
     * Resolve the given hostname to an IP address.
     * param aHostname: Name to be resolved
     * param aResult: IPAddress structure to store the returned IP address
     * result: 1 if aIPAddrString was successfully converted to an IP address,
     *          else error code
     */
    int hostByName(const char* aHostname, IPAddress& aResult);

    friend class WiFiClient;
    friend class WiFiServer;
};

extern WiFiClass WiFi;

#endif

My WiFi.cpp file

/*
WiFi.cpp - Library for Arduino Wifi shield.

*/

#include "utility/wifi_drv.h"
#include "WiFi.h"

extern "C" {
  #include "utility/wl_definitions.h"
  #include "utility/wl_types.h"
  #include "utility/debug.h"
}

// XXX: don't make assumptions about the value of MAX_SOCK_NUM.
int16_t 	WiFiClass::_state[MAX_SOCK_NUM] = { NA_STATE, NA_STATE, NA_STATE, NA_STATE };
uint16_t 	WiFiClass::_server_port[MAX_SOCK_NUM] = { 0, 0, 0, 0 };

WiFiClass::WiFiClass()
{
}

void WiFiClass::init()
{
    WiFiDrv::wifiDriverInit();
}

uint8_t WiFiClass::getSocket()
{
    for (uint8_t i = 0; i < MAX_SOCK_NUM; ++i)
    {
        if (WiFiClass::_server_port[i] == 0)
        {
             return i;
        }
    }
    return NO_SOCKET_AVAIL;
}

char* WiFiClass::firmwareVersion()
{
	return WiFiDrv::getFwVersion();
}

int WiFiClass::begin(char* ssid)
{
	uint8_t status = WL_IDLE_STATUS;
	uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;

   if (WiFiDrv::wifiSetNetwork(ssid, strlen(ssid)) != WL_FAILURE)
   {
	   do
	   {
		   delay(WL_DELAY_START_CONNECTION);
		   status = WiFiDrv::getConnectionStatus();
	   }
	   while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
   }else
   {
	   status = WL_CONNECT_FAILED;
   }
   return status;
}

int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
{
	uint8_t status = WL_IDLE_STATUS;
	uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;

	// set encryption key
   if (WiFiDrv::wifiSetKey(ssid, strlen(ssid), key_idx, key, strlen(key)) != WL_FAILURE)
   {
	   do
	   {
		   delay(WL_DELAY_START_CONNECTION);
		   status = WiFiDrv::getConnectionStatus();
	   }while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
   }else{
	   status = WL_CONNECT_FAILED;
   }
   return status;
}

int WiFiClass::begin(char* ssid, const char *passphrase)
{
	uint8_t status = WL_IDLE_STATUS;
	uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;

    // set passphrase
    if (WiFiDrv::wifiSetPassphrase(ssid, strlen(ssid), passphrase, strlen(passphrase))!= WL_FAILURE)
    {
 	   do
 	   {
 		   delay(WL_DELAY_START_CONNECTION);
 		   status = WiFiDrv::getConnectionStatus();
 	   }
	   while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
    }else{
    	status = WL_CONNECT_FAILED;
    }
    return status;
}

void WiFiClass::config(IPAddress local_ip)
{
	WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
}

void WiFiClass::config(IPAddress local_ip, IPAddress dns_server)
{
	WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
	WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
}

void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
{
	WiFiDrv::config(2, (uint32_t)local_ip, (uint32_t)gateway, 0);
	WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
}

void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
{
	WiFiDrv::config(3, (uint32_t)local_ip, (uint32_t)gateway, (uint32_t)subnet);
	WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
}

void WiFiClass::setDNS(IPAddress dns_server1)
{
	WiFiDrv::setDNS(1, (uint32_t)dns_server1, 0);
}

void WiFiClass::setDNS(IPAddress dns_server1, IPAddress dns_server2)
{
	WiFiDrv::setDNS(2, (uint32_t)dns_server1, (uint32_t)dns_server2);
}

int WiFiClass::disconnect()
{
    return WiFiDrv::disconnect();
}

uint8_t* WiFiClass::macAddress(uint8_t* mac)
{
	uint8_t* _mac = WiFiDrv::getMacAddress();
	memcpy(mac, _mac, WL_MAC_ADDR_LENGTH);
    return mac;
}
   
IPAddress WiFiClass::localIP()
{
	IPAddress ret;
	WiFiDrv::getIpAddress(ret);
	return ret;
}

IPAddress WiFiClass::subnetMask()
{
	IPAddress ret;
	WiFiDrv::getSubnetMask(ret);
	return ret;
}

IPAddress WiFiClass::gatewayIP()
{
	IPAddress ret;
	WiFiDrv::getGatewayIP(ret);
	return ret;
}

char* WiFiClass::SSID()
{
    return WiFiDrv::getCurrentSSID();
}

uint8_t* WiFiClass::BSSID(uint8_t* bssid)
{
	uint8_t* _bssid = WiFiDrv::getCurrentBSSID();
	memcpy(bssid, _bssid, WL_MAC_ADDR_LENGTH);
    return bssid;
}

int32_t WiFiClass::RSSI()
{
    return WiFiDrv::getCurrentRSSI();
}

uint8_t WiFiClass::encryptionType()
{
    return WiFiDrv::getCurrentEncryptionType();
}


int8_t WiFiClass::scanNetworks()
{
	uint8_t attempts = 10;
	uint8_t numOfNetworks = 0;

	if (WiFiDrv::startScanNetworks() == WL_FAILURE)
		return WL_FAILURE;
 	do
 	{
 		delay(2000);
 		numOfNetworks = WiFiDrv::getScanNetworks();
 	}
	while (( numOfNetworks == 0)&&(--attempts>0));
	return numOfNetworks;
}

char* WiFiClass::SSID(uint8_t networkItem)
{
	return WiFiDrv::getSSIDNetoworks(networkItem);
}

int32_t WiFiClass::RSSI(uint8_t networkItem)
{
	return WiFiDrv::getRSSINetoworks(networkItem);
}

uint8_t WiFiClass::encryptionType(uint8_t networkItem)
{
    return WiFiDrv::getEncTypeNetowrks(networkItem);
}

uint8_t WiFiClass::status()
{
    return WiFiDrv::getConnectionStatus();
}

int WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
{
	return WiFiDrv::getHostByName(aHostname, aResult);
}

WiFiClass WiFi;

Thanks in Advance …

Hello @himani.upadhyay,

Can you try removing all unnecessary libraries and boards that you have in your Arduino IDE, delete the ESP32 boards and install them again to check if this solve the issue.

If the issue still persist, can you tell me:

  • Which ESP32 Cam board you have
  • Which version of the Arduino IDE you are using
  • Send a screenshot of the Arduino IDE screen

Regards,

Louis

1 Like

Hi,
Yes I reinstalled my all wifi library but still facing the issue.

I have ESP32-CAM is a development board with OV3660 camera board.
Arduino version is 1.8.14

Hi!

It seems it has compiled successfully, what happens now if you open the serial console (the upper right button with a magnifying glass icon.

Regards,

Hi @louis
Resolved my wifi Issue by following your suggestions.
but now I face one another error on serial monitor.

Run classifier...
ERR: failed to allocate tensor arena
Failed to allocate TFLite arena (error code 1)

Thanks & Regards

Hello @himani.upadhyay,

This is because you model is too big, can you make sure you used a MobileNet V1 for the transfer learning base model?

Regards,

Louis

Hi @louis
Followed your instruction and yes camera started and also click photo :slight_smile:
I used MobileNetV1 0.25 version . But It clicked blurry picture (attached SS (that tiny square is image which clicked by the esp32 cam)) and the moment I run the code it automatically click the picture, where I can’t see my toggle setting for active edge impulse inference which you already show in github example

Many Thanks :slight_smile:

The example with a small WebUI is located in the Advanced Example on the Github repository.

And here the image is very small because I guess so set 48x48 for your model:

You can change this settings to 96x96 when using the MobileNetV1, you should have enough ressources on your ESP32 CAM to run this model :slight_smile:

Regards,

Louis

Hi @louis

Again here with an Error !!
Here I’m trying Advanced Example 160x160 image width and height to capture image (I want 160x160 only) with MobilenetV2 0.35 and also tried with other neural network architecture but it gives me same error As I already faced …

Getting signal…
Run classifier…
ERR: failed to allocate tensor arena
Failed to allocate TFLite arena (error code 1)
run_classifier returned: -6
JPG: 7546B 339ms
{“success”: false,“timing”: {“timing_dsp”:0,“timing_classification”:0,“timing_anomaly”:0}}
{“success”: false,“timing”: {“timing_dsp”:0,“timing_classification”:0,“timing_anomaly”:0}}

How can I solved this ?

Thanks

Hello @himani.upadhyay,

Unfortunately, 160x160 images with MobileNetV2 0.35 won’t fit on the ESP32 CAM ressources.
Especially on the Advanced Example where the board need also ressources to host the small web server and the wifi connectivity.

Regards,

Louis

Thanks @louis

Ohh,okay.
As per you told ESP32 CAM ressources won’t fit with my 160x160 image model So, I changed my H/W ESP32 CAM to ESP EYE now can you pls let me know which MobileNetV2 is fit with my 160x160 model.

Ps: I’m using Advance Example . (by using Arduino IDE)

Hello @himani.upadhyay,

I think the ESP EYE has 520K of RAM, as you can see below, no 160x160 models would fit (unless you use the PSRAM but you’d need to implement that on your side):

I’d recommend to use MobileNet V1 0.1 or 0.2 with 96x96 images with ESP Cam projects as it would leave enough space and memory to use a small web interface and the connectivity processes:

Best regards,

Louis

Thanks @louis

Yes, I tried with MobilenetV2 160 x 160 with all versions but it gives error like

Item psram alloc failed. Size: 172800 x 1
matrix3du item alloc failed.
dl_matrix3du_alloc failed
Item psram alloc failed. Size: 172800 x 1
matrix3du item alloc failed.
dl_matrix3du_alloc failed

Can you pl suggest.

Regards:)

Hello @himani.upadhyay

MobileNet v2 160x160 will not work due to the resources limitation of the board.
Try MobileNet v1 0.01 instead, we’ll see if it works.

Regards,

Louis

Hi @louis
Thank you for your support.
I have some Quarry related edge impulse .

  1. I’m planning to move with ESP-IDF free RTOS so could you please let me know If edge impulse library will work with ESP-IDF.

  2. How much accuracy different between 96 x 96 and 160 x 160 in terms of the detection of the images.

Hello @himani.upadhyay,

  1. Yes it will work but as Espressif boards are not officially supported by Edge Impulse, you’ll have to integrate Edge Impulse sdk on your side (you can download the C++ Library from the deployment tab)

.

Most of the code I wrote for the ESP32 Cam on Arduino will work using ESP IDF (get a frame for the camera, resize it while allocating the memory buffers, etc…).

For Edge Impulse SDK, you can use the same function that I used that do not contain any board-related dependencies: https://docs.edgeimpulse.com/docs/running-your-impulse-locally
You can also reuse the classify() function that I used to run the inference:

void classify()
{
  Serial.println("Getting signal...");
  signal_t signal;
  signal.total_length = EI_CLASSIFIER_INPUT_WIDTH * EI_CLASSIFIER_INPUT_WIDTH;
  signal.get_data = &raw_feature_get_data;

  Serial.println("Run classifier...");
  // Feed signal to the classifier
  EI_IMPULSE_ERROR res = run_classifier(&signal, &result, false /* debug */);

  // Returned error variable "res" while data object.array in "result"
  ei_printf("run_classifier returned: %d\n", res);
  if (res != 0)
    return;

  // print the predictions
  ei_printf("Predictions (DSP: %d ms., Classification: %d ms., Anomaly: %d ms.): \n",
            result.timing.dsp, result.timing.classification, result.timing.anomaly);
  for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    ei_printf("    %s: \t%f\r\n", result.classification[ix].label, result.classification[ix].value);
    if(result.classification[ix].value > 0.8){
      label = String(result.classification[ix].label);
    }
  }
  
#if EI_CLASSIFIER_HAS_ANOMALY == 1
  ei_printf("    anomaly score: %f\r\n", result.anomaly);
#endif
}
  1. This will really depend on you project so hard to tell, you can always add more images over the time to get better models as the time fly or you can also try not to use the transfer learning and add your custom architecture but I doubt that you’ll get a better accuracy.

Regards,

Louis