ESP32 'int close(int)' compiler error

I have reseached this error and have found nothing that would help.

I am using a Mac OSX v12.5.1, IDE v2, board is Adafruit ESP32 Feather V2.

Here is the more of this error:

previous declaration 'int close(int)'
 int     close (int __fildes);

All comments or suggestions are most welcome.

Thank you.

Please post a complete sketch that illustrates the problem, using code tags when you do, and the full error message, also in code tags

It looks like the close() function is being declared twice in the sketch, possibly in a library and also in your own sketch

1 Like

Is this the same problem?

https://forums.adafruit.com/viewtopic.php?p=940009

by adafruit_support_carter » Fri Sep 09, 2022 2:34 pm

Don't use the Wifi101 library, which is meant for ATMEL WINC1500 wifi module devices:

Try the wifi examples here:
https://learn.adafruit.com/adafruit-esp ... /wifi-test

@UKHeliBob @Whandall

Thank you both for your comments and suggestions.

As brifely as I can, this is my situation: I donated my time and resources to our water association (WA) to build/install water level monitoring systems for their two 18 ft water tanks.

They requested that it would be great if they could receive texts when the water level(s) fell to 8 feet. Over the course of several months, I made that all work, but I was using my own non-secure website to bounce the texts from.

I built the WA's website as a secure - HTTPS - site and I have never been able to receive texts from this secure site. After much time and effort I can only conclude that my failure to receive texts from this site is precisely because it is a secure site.

Fast forwarding: I was advised to use another microcontroller that has a built in 'SSL stack' which would enable me to 'connect' with secure sites due to certain required libraries. So I went from an Adafruit Feather MO WIFI to an Adafruit ESP32 Feather V2.

This is all fine and good save for the fact that for some reason I have not been able to receive texts from the non-secure site like I used to. I thought that it was either my cell carrier, Verizon, or Apple that was blocking these texts. The Verizon tech did some testing and concluded it was not they who were blocking my texts, if anyone actually was. I could not argue because I had no proof to dispute his assumption.

What I did was change all of the creds in the text sending PHP file that was in the includes folder of my website. I was shocked when I began receiving texts once again. These texts were spaced over 60 intervals so whether whomever is blocking these texts would consider that many texts to be SPAM or not I do not know. At any rate, I was now receving texts and now I could return to testing with the secure site.

After installing all of the required files necessary to run the ESP32 microcontrollers, I was all set or so I thought. I say this because I am no longer able to receive texts like I was doing just a week ago.

Boards do not matter because I reverted back to the original non-ESP Feather, I just am not able to trigger these texts as I used to. I have no idea what the problem is. So I turn to folks such as yourself for help

Back on topic: I did in fact remove the wifi101.h lib, and was able to get the sketch to compile, but if I am not able to receive texts then I have no way to test.

I have the Adafruit PDF file you linked me to and have built the 'Secure Connection Example' but did not get the results I was supposed to.

I need a break.

I sincerely appreciate your help,
Phillip

Could you not simply send the texts directly from the water monitoring system rather than "bouncing" them through a website ?

Thank you for your response.

The water tank sketch has a function that 'triggers' the text sending as follows:

void send_text(float interval, float tank_level){

      Serial.println("\t >>> In send_text(...) ...\n");

      String current_tank_level = String (tank_level,2);

      postData = postVariable + current_tank_level; 
      
      unsigned long tank_level_currentMillis = millis(); 
      
      if (tank_level_currentMillis - tank_level_previousMillis >= interval) 
        { 
          tank_level_previousMillis = tank_level_currentMillis;
      
          if (client.connect(server, 80))
              {
              client.println("POST /includes/bill_noland_send_text.php HTTP/1.1");  
              //client.println( "Host: www.talaveramdwca.org" ); // client site ...
    
              client.println( "Host: www.redristracards.com" );  // my test site ...
              
              client.println( "Content-Type: application/x-www-form-urlencoded" );
              //client.println( "Connection: close" );  // I commented out .... ?
              
              client.print("Content-Length: ");
              client.println(postData.length());
              client.println();
              client.print(postData);

              Serial.println("TEXT Sent");
              Serial.println(postData);
            }

            if (client.connected()) {
                client.stop();
             }
          }
        }

The following line triggers the php file in the includes folder of the website:

   client.println("POST /includes/bill_noland_send_text.php HTTP/1.1");  

You suggestion is very interesting. I thought my method was the only way to send texts from within a sketch. I'm all ears to whatever you have to add.

Thanks again for your help.

I should have added that I have a handfull of Arduino Nano 33 IoT microcontrollers. If these are more beneficial that my ESP32 boards then I will consider using them.

The entire enclosure for this project is complete so I would have to make some major changes due to the different form factors. However, if I can send texts from within the sketch then there would seemingly be no need to change microcontrollers. Tweaking the sketch may be all that would be necessary.

Here is the enclosure:

Things have never gone that easy for me of late, but I can only hope.

Thanks again for your help.

@UKHeliBob

Alright, I just found this informative article.

I may indeed finally get to see the light at the end of the tunnel I have been entombed in for months. I cannot thank you enough for sending me down the correct path.

Would you like anchovy on your pizza?

Good luck with your project going forward

I have been helping someone with a project to remote control a remote water pumping system using texts to control the system and receive feedback as to its status, hence my very recent experience with the SIM800 modules

The main problem with them seems to be that they need to be powered properly at the correct voltage and with sufficient current, but once set up they seem to work consistently

Thank you. With the way things have been going for me, it seems that I will be needing a lot of luck with this project.

Looking back on this project most of the system components were not too difficult to stitch together. The ultrasonic sensor was cumbersome to code up, but the rest was fairly straightforward.

However, the text alerts have been a colossal pain in the 'arse'. This was an 'after the fact' request from the WA, but it is perfectly valid. In fact, it truly is the heart of the entire system.

After a bit of research yesterday, I came to realize that had read about IFTTT in the past. Because my text sending method was working perfectly I saw no need to learn much about it, so I didn't. Things have indeed changed. And, thanks again for bringing this concept back to my attention.

What still puzzles me is I cannot determine what is causing the text blockage. As noted earlier, my method worked without fail. Then texts stopped arriving, then they began arriving, then they stopped once again. All of this without zero code changes. It makes no sense unless, of course, some entity 'bot' is blocking these texts. Regardless, this method of receiving texts is less than reliable.

Manually executing the PHP file (in the URL) does not send texts either. In truth, I never tested that manual method when things were working, but it seems logical to me that a text should be sent in that manner.

At any rate, I will dig into the IFTTT docs and see if it will do what I need done.

I appreciate your help.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.