Chat freely about anything...

User avatar
By mixxx2005
#47914 Hello, I love this cheap way of IoT , but I am new to all this so after tinkering around with different ESP modules some questions rise. So please give me some answers :

1. Is there any issues using Arduino IDE with ESP?
For example I use WiFiClient.ino example to log temperature, but often after 1 - 4 hours it freezes and reset is needed, so is it hardware related or software related issue? I tried same code with NodeMCU , ESP03 and ESP12E modules.

2. Is there any reason to flash new firmware to module,? or if I do not use AT commands and mainly use Arduino IDE - there is no need for that?

Thanks in advance
Greetings from Latvia!! ))
User avatar
By martinayotte
#47926 The freeze is probably caused by unstable power supply.
Make sure your PSU is strong enough, and add a big capacitor such 100uF nearby the ESP power pins.
No need to upgrade the firmware since the AT Firmware is already gone/erased by having Arduino sketches uploaded.
User avatar
By xtal
#47937 My experience has been that my arduino code freezes for what ever reason at random intervals, I havn't found a solution.
NodeMCU running very similiar code usually runs until PC is windows updated
User avatar
By mixxx2005
#48044 Ok, I will try bigger capacitor.

This is my code.

Code: Select all#include <OneWire.h>
#include <ESP8266WiFi.h>
OneWire  ds(12);  // on pin 10 (a 4.7K resistor is necessary)


int BL = 13;
float celsius;
const char* ssid     = "xxxxx";
const char* password = "xxxxx";
const char* host = "data.sparkfun.com";
const char* streamId   = "xxxxx";
const char* privateKey = "xxxxx";


void setup() {

  pinMode(BL,OUTPUT);
 
  WiFi.begin(ssid, password);
        while (WiFi.status() != WL_CONNECTED) {
        delay(500);
  }
}

void loop(){
digitalWrite(BL,HIGH);
delay(100);
digitalWrite(BL,LOW);
celsius = celsius +1;
sent();
delay(2000);
}

void sent(){
 
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
       return;
  }
 
  // We now create a URI for the request
  String url = "/input/";
  url += streamId;
  url += "?private_key=";
  url += privateKey;
  url += "&temp=";
  url += celsius;
 
   
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  int timeout = millis() + 1000;
  while (client.available() == 0) {
    if (timeout - millis() < 0) {
           client.stop();
      return;
    }
  }
 
  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
  }

}