Please, help. Cactus Micro doesn't work anymore

Hello!
As I said in my other post (where nobody answered) I don’t know anything about Arduino and I’m struggling in connecting a Cactus Micro Rev2 to my wifi router.
Today I uploaded a code and now my Cactus isn’t recognized anymore by my PC. Is there a way to reset the board and erase the uploaded code?

The uploaded code is:

#include avr/pgmspace.h

//period between posts, set at 60 seconds
#define DELAY_PERIOD 10000

// Important!! We use pin 13 for enable Serial1  
#define WIFI_ENABLE_PIN 13

// TODO
#define SSID         "upc"
#define PASS         "pass"

#define HOST         "192.168.1.225"
#define HOST_NAME    "localhost"

#define DEBUG         1

#define REQ_PREFIX    "POST /event.php\r\n" \
    "Host: " HOST_NAME "\r\n" \
    "Accept: *" "/" "*\r\n" \
    "Content-Length: " 

#define REQ_SUFFIX    "\r\n" \
    "Content-Type: application/x-www-form-urlencoded\r\n" \
    "Connection: close\r\n\r\n" 

#define printDebug(x)       Serial.print(F(x)); Serial1.print(F(x));
#define printlnDebug(x)     Serial.println(F(x)); Serial1.println(F(x));

#define printVar(x)         Serial.print(x); Serial1.print(x);
#define printlnVar(x)       Serial.println(x); Serial1.println(x);


long nextTime;
String prevString;

void clearRx() {
    while(Serial1.available() > 0) {
        Serial1.read();
    }
}

String readString(
    long timeout, 
    String target1, 
    String target2 = "", 
    String target3 = "",
    String target4 = ""
) {
    String data;
    char a;
    unsigned long start = millis();

    while (millis() - start < timeout) {
        while(Serial1.available() > 0) {
            a = Serial1.read();
            if(a == '\0') {
                continue;
            }
            data += a;
            Serial.write(a);
        }

        if (data.indexOf(target1) != -1) {
            break;
        } 

        if (target2.length() && (data.indexOf(target2) != -1)) {
            break;
        }

        if (target3.length() && (data.indexOf(target3) != -1)) {
            break;
        }

        if (target4.length() && (data.indexOf(target4) != -1)) {
            break;
        }
    }

    return data;
}

bool connectWifi() {     
    bool connected = false;
    long timeout = 10000;
    clearRx();
    printDebug("AT+CWJAP=\"");
    printDebug(SSID);
    printDebug("\",\"");
    printDebug(PASS);
    printlnDebug("\"");
    
    String ret = readString(timeout, "OK", "FAIL");
    if (ret.indexOf("OK") != -1) {
        return true;
    }
    return false;
}

void setup() {

    Serial1.begin(9600);   //connection to ESP8266
    Serial.begin(9600);     //serial debug

    // For atmega32u4, Please set DEBUG = 0 if it not connected to USB
    if(DEBUG) {
        while(!Serial);
    }

    pinMode(WIFI_ENABLE_PIN, OUTPUT);
    digitalWrite(WIFI_ENABLE_PIN, HIGH);

    delay(1000);
    //set mode needed for new boards
    Serial1.println(F("AT+RST"));
    delay(3000);//delay after mode change       
    Serial1.println(F("AT+CWMODE=1"));
    delay(300);
    Serial1.println(F("AT+RST"));
    delay(3000);
    // Sinlge connection
    Serial1.println(F("AT+CIPMUX=0"));
    delay(500);

    if (connectWifi()) {
        Serial.print("Connected AP success\r\n");
    } else {
        Serial.print("Connect AP failure\r\n");
    }

    printlnDebug("AT+CIFSR");
    String ret = readString(10000, "STAIP"); 
    
    if (ret.indexOf("STAIP") != -1) {
        Serial.println(ret); 
    } else {
        Serial.println(F("Not got IP"));
    }

    nextTime = millis(); //reset the timer
}

void loop() {
    //wait for timer to expire
    if(nextTime < millis()){
        Serial.print("timer reset: ");
        Serial.println(nextTime);

        httpPost("test=123");

        //reset timer
        nextTime = millis() + DELAY_PERIOD;       
    }

}

//web request needs to be sent without the http for now, https still needs some working

void httpPost(String data) {    
    String ret;
    long timeout = 2000;
    Serial.println(F("Sending data..."));

    delay(1000);
    clearRx();
    printDebug("AT+CIPSTART=\"TCP\",\"");
    printDebug(HOST);
    printlnDebug("\",8080");
    
    ret = readString(timeout, "OK", "ALREAY CONNECT", "ERROR", "busy"); 

    //test for a start error
    if ((ret.indexOf("OK") != -1) || (ret.indexOf("ALREAY CONNECT") != -1)) {
        Serial.println(F("Connected"));
    } else {
        Serial.println(F("Not connected"));
        clearRx();
        printlnDebug("AT+CIPCLOSE");
        return;
    }   

    //send to ESP8266
    clearRx();
    delay(1000);
    printDebug("AT+CIPSEND="); 
    printlnVar( 
        String(REQ_PREFIX).length() + 
        String(data.length()).length() +
        data.length() +
        String(REQ_SUFFIX).length() 
    );

    ret = readString(timeout, String(">"), "link is not"); 
    Serial.print(F("Done:"));
    Serial.println(ret);
    if (ret.indexOf(">") != -1) {
        // Send data
        Serial.println(F("ready to send:"));
        Serial1.print(F(REQ_PREFIX));
        Serial1.print(String(data.length()));
        Serial1.print(F(REQ_SUFFIX));
        Serial1.print(data);

        ret = readString(timeout, "OK");
        //clearRx();
        printlnDebug("AT+CIPCLOSE");
    } else {
        printlnDebug("AT+CIPCLOSE");
        Serial.println(F("Connect timeout"));
        delay(1000);
    }
    
clearRx();}

Please check the wiki first.

Thank you for your reply. I cheched your link but I didn’t understand waht I have to do. My CactusMicro is not recognized anymore by the PC.

Incorporating all of the USB tasks on a single chip is an awesome feature that makes the Cactus Micro and boards like it truly unique. But it also places more stress on a single chip, and if anything goes wrong with that chip, the board becomes nearly unusable. It’s not uncommon for Cactus Micro’s to become “bricked” and unprogrammable. But, in most cases, the bricking is reversible!

Please check our wiki for how to revive the board.

Thanks a lot for your help. I checked the link you gave me but it doesn’t work. If i double touch the reset button, I can connect to the Cactus for 8 seconds but it’s a too short time to upload any new program.
I give up. I’ll throw the cactus micro to the trash bin and I’ll look for a better supported board.

I think the topic is helpful for you.

Yes!!! It worked!!! Thank you very very much!!!
Do you have any good link to set up a wifi connection between Cactus Micro and my router, please?

Here’s a sketch for mqtt connection you can try

I struggled a bit but it works! Thank you!!!
May ask a bit more? Is it possible to send an email when a switch on the Cactus Micro is pressed?

I think you can do this with IFTTT