-->
Page 1 of 1

Huzzah ESP8622 Attached to Arduino Uno, Wifi Not Connecting

PostPosted: Thu Aug 04, 2022 5:07 pm
by Calder1
Overview:

Hello all,

I am doing an internship project for some of the hoophouse vegetable growers in my area. They are interested in have a temperature alarm to let them know when the hoophouse gets too hot or cold, their hoophouses are out of wifi and bluetooth range, and they’d like to see the data online and have a temperature alert sent to their phones as well. My experience is pretty limited but I wanted to try and do it.

I decided to go with a radio transmitter since the hoophouses are not super close to the house. The overall plan has been to have a temperature sensor (AHT20 but may switch to SHT-30) connected to an Arduino Uno and a RFM69HCW radio transmitter to transmit the temperature to another RFM69HCW at the house, also connected to an arduino uno. A Piezo Buzzer and red LED go off when temp is too low or high.

Right now all of the above is working. The temp is transmitted by radio, displayed on an LCD in the house, and an alarm goes off if it’s too hot or cold. (code attached below is tester for wifi issues, current working code is not attached).

I also want to send this information to Thingspeak so that the data can be tracked, and I’m also hoping to send SMS alerts to peoples phones if their hoophouse is overheating or too cold.

I bought an ESP8266 Huzzah board from Adafruit thinking it would be a good for the wifi connection and would connect to the Arduino Uno at the house (I also have the FTDI cable if needed). Adafruit HUZZAH ESP8266 Breakout : ID 2471 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Current Issue:
Currently the Huzzah ESP8266 is not connecting to the internet. My code gets stuck on ‘reconnecting’. There are no lights (blue or red) on the ESP8266 while this is happening. The TX and RX lights on the Arduino UNO do go off though.

I tried playing around with the FTDI and another program earlier, when I did that the blue and red lights on the ESP8266 were going off. Also I am right next to the router, and I know the internet is working well, pw and wifi name are correct, the router is 5 GHz which i’ve read is correct for the ESP8266.

I’ve heard that the arduino takes in the command and may not relay it to the ESP8266, and I think this is my problem, but I’m not sure how to fix it. On older forum posts some people have said remove the MCU of the Uno, but that would mess up my other operations I believe.

Is this why I cannot connect to Wifi, and is there a fix for it?

Curent Setup:
Image
(Having trouble uploading photo, see attachment)

Pin Setup:
Note: the Huzzah ESP8266 has a voltage regulator so I can connect the V+ to 5V, and the Rx is 5V compatible. Also I have tried TX-RX, RX-TX.

Per a suggestion on another forum, I've also tried connecting Tx and Rx to different digital pins (6 and 7, because 2 and 3 are being used by the RFM68HCW radio transmitter). That resulted in the same 'reconnecting' issue.

Uno: --- ESP8266:
TX --- TX
Rx --- RX
5V --- V+
3.3V --- EN, RST
GND --- GND


Current Code:
Note: This code is just to test the wifi and connect with Thingspeak.
I took the original code from here: ThingSpeak Arduino Weather Station - Arduino Project Hub, I have not switched their DHT sensor code to mine, as well as a few other things, that shouldn’t be too hard though. I just need to get past the wifi stuff first.

Code: Select allSerial.print(" nnn ");
 
  Serial.begin(9600);  //Start with baud 9600
  ESP8266.begin(9600);
  dht.begin();
  startTime = millis();
  ESP8266.println("AT+RST");
  delay(2000);
  Serial.println("Connecting to Wifi");
   while(check_connection==0)
  {
    Serial.print(".");
   ESP8266.print("AT+CWJAP=\"*******\",\"*************\"\r\n");
  ESP8266.setTimeout(5000);
 if(ESP8266.find("WIFI CONNECTED\r\n")==1)
 {
 Serial.println("WIFI CONNECTED");
 break;
 }
 times_check++;
 if(times_check>3)
 {
  times_check=0;
   Serial.println("Trying to Reconnect..");
  }
  }

 
}

void loop()
{
 
  waitTime = millis()-startTime;   
  if (waitTime > (writingTimer*1000))
  {
//    readSensors();
    writeThingSpeak();
    startTime = millis();   
  }
}


//void readSensors(void)
//{
  //temp_f = dht.readTemperature();
  //humidity = dht.readHumidity();
 // temp_f = temp.temperature();
  //humidity = humidity.relative_humidity();
//}

void writeThingSpeak(void)
{
 
  float temp = 5; //faking sensor data to test wifi
  float humid = 6; //faking sensor data to test wifi
 
  startThingSpeakCmd();
  // preparacao da string GET
  String getStr = "GET /update?api_key=";
  getStr += myAPIkey;
  getStr +="&field1=";
  getStr += String(temp);
  getStr +="&field2=";
  getStr += String(humid);
  getStr += "\r\n\r\n";
  GetThingspeakcmd(getStr);
}

void startThingSpeakCmd(void)
{
  ESP8266.flush();
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149"; // api.thingspeak.com IP address
  cmd += "\",80";
  ESP8266.println(cmd);
  Serial.print("Start Commands: ");
  Serial.println(cmd);

  if(ESP8266.find("Error"))
  {
    Serial.println("AT+CIPSTART error");
    return;
  }
}

String GetThingspeakcmd(String getStr)
{
  String cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  ESP8266.println(cmd);
  Serial.println(cmd);

  if(ESP8266.find(">"))
  {
    ESP8266.print(getStr);
    Serial.println(getStr);
    delay(500);
    String messageBody = "";
    while (ESP8266.available())
    {
      String line = ESP8266.readStringUntil('\n');
      if (line.length() == 1)
      {
        messageBody = ESP8266.readStringUntil('\n');
      }
    }
    Serial.print("MessageBody received: ");
    Serial.println(messageBody);
    return messageBody;
  }
  else
  {
    ESP8266.println("AT+CIPCLOSE");     
    Serial.println("AT+CIPCLOSE");
  }
}


Serial Monitor:
Code: Select all12:55:21.090 -> ⸮  Connecting to Wifi
12:55:24.654 -> ....Trying to Reconnect..
12:55:44.774 -> ....Trying to Reconnect..
12:56:04.923 -> ....Trying to Reconnect..
12:56:25.087 -> ....Trying to Reconnect..
12:56:45.223 -> .


Thank you for any help!

Re: Huzzah ESP8622 Attached to Arduino Uno, Wifi Not Connect

PostPosted: Sun Aug 21, 2022 12:29 am
by rooppoorali
Is the wiring right? Shouldn't the Arduino Tx be connected to the Huzzah Rx and vice versa?

Re: Huzzah ESP8622 Attached to Arduino Uno, Wifi Not Connect

PostPosted: Sun Aug 21, 2022 2:15 am
by JurajA
esp8266 can connect only to 2.4 GHz WiFi