I am using an Arduino Nano with an ESP 8266 for monitoring the temperature in a room. But it only works in the hotspot of my Android Phone. But i want to use it with a router. I tryed 3 different routers and the ESP 8266 is connecting to them (it is visible in the setup page of the router and “Connected to WiFi” appears in the serial monitor.) But i am getting this error in my serial monitor
“[864985] <[1D|00|01|00] f013d308057346708fa816dfxxxxxxx
[875040] Cmd error”. But in the Hotspot of my phone it is working flawlessly. I tryed to disable the firewall of the router but that does not help. What should i do to fix this?
Please post your code if you want any significant advice.
I’d look if phone or router were setup different in these areas.
Wep / Wpa / Wpa2
is the ssid spelled the same? Including capitalized letters?
Ps: BianchiRider is right, you should post your code, kinda hard for us to guess at the problem.
char ssid[] = "Logger";
char password[] = "Vidl***";
char token[] = "f013d30805734670xxxxxxxx";
char email[] = "xxxxxxxxxxxx@gmail.com";
char subject[] = "Temperatur";
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
// Set ESP8266 Serial object
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(11, 12); // RX, TX
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
//init max min value (0 makes no sense)
double tempMax = - 273;
double tempMin = +200;
bool autoSend;
void setup()
{
// Set console baud rate
Serial.begin(19200);
EspSerial.begin(19200);
Blynk.begin(token, wifi, ssid, password);
//timer for temp measure
timer.setInterval(500L, getTemp);
}
void loop()
{
Blynk.run();
timer.run(); //Call timer (other than normal timers)
}
BLYNK_CONNECTED() {
Blynk.syncVirtual(V5); //sync email auto send state
}
void getTemp() { //get temp, convert to C and send
double currValue = Thermistor(analogRead(A0)) ; //Convert to C !!! Pot: round((x*10)/10)
if (currValue < tempMin) {
tempMin = currValue;
}
if (currValue > tempMax) {
tempMax = currValue;
}
Blynk.virtualWrite(V0, currValue);
Blynk.virtualWrite(V1, currValue);
Blynk.virtualWrite(V3, tempMin);
Blynk.virtualWrite(V2, tempMax);
}
double Thermistor(int RawADC) {
//Source: http://playground.arduino.cc/ComponentLib/Thermistor2
double Temp;
Temp = log(10000.0 * ((1024.0 / RawADC - 1)));
// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp )) * Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
// Temp = (Temp * 9.0)/ 4.7 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void sendSummary() { //send email summary
Blynk.email(email, subject, Thermistor(analogRead(A0)) );
}
BLYNK_WRITE(V6) { //Timer Send
if (autoSend) {
sendSummary();
}
}
BLYNK_WRITE(V4) { //Button Send
sendSummary();
}
BLYNK_WRITE(V5) { //config email send
autoSend = param.asInt();
}
Both phone and router had WPA2 encryption and i tested them with the same SSID and same password.
To be honest, I’m surprised it works at all at that baud rate. SoftwareSerial is only really good up to about 9600 baud as it’s using a virtual UART created via code.
Note that the ESP-01 needs to be set to the same baud rate as the one used in the sketch - using an AT command - so you can’t just change the SoftwareSerial baud rate in the sketch and expect it to work.
Also, do you really need to check your temperature reading every half a second?
Pete.
It worked with 19200 with the phone hotspot. But i tryed it with 9600 as you said (and changed the baud of the esp with AT+UART_DEF=9600,8,1,0,0
) but that did not help. But i noticed that it connects for a very short time sometimes. It then says “connected” in the app as this shows up in the serial monitor:
22:24:43.639 -> [361015] <[1D|00|01|00] f013d308057346708fa816dfxxxxxxx
22:24:43.811 -> [361169] >[00|00|01|00|C8]
22:24:43.811 -> [361169] Ready (ping: 26ms).
22:24:43.811 -> [361170] Free RAM: 783
but it says “disconnected” a short time later and this message again appears:
22:26:51.956 -> [489473] <[1D|00|01|00] f013d308057346708fa816dfxxxxxxx
22:27:02.011 -> [499561] Cmd error
and no i don´t need to check that so often. I changed it to 5 seconds now but that does not change a thing at all.
How close is your ESP-01 to your router?
Normally these things are pretty good at picking-up a Wi-Fi signal, but it is possible to reduce the output power using AT commands and maybe it’s just not talking reliably to your router where it is?
Your free memory seems quite low. This might be because you have BLYNK_DEBUG enabled - BTW the docs say that this should be the very first line of code in your sketch:
I’m not sure why this would have any bearing on your problem, but who knows!
Otherwise, it could be something that your ISP is doing, which is being bypassed when using your phone’s GSM connection via a hotspot.
I guess the next test would be to try the same hardware/sketch (with the SSID & password changed of course) on a different Wi-Fi network.
Pete.