Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By kas
#60655
I've been told its better to try to minimize the client.print calls as each might do an actual I/O which is slow, so for example concat the headers together and then send them altogether with a single client.print.

Clever idea, thanks torntrousers
User avatar
By al1fch
#60656 yes, single client.print in my codes :

Code: Select all  WiFiClient client;

  // connexion au serveur ThingSpeak pour mise à jour du canal par requete GET
  if (!client.connect(host, httpPort)) {
    //Serial.println("echec de connection");
    // on passe son tour !!
    ESP.deepSleep(intervalle * 60 * 1000000, WAKE_RF_DEFAULT); // WAKE_RF_DEFAULT  ou  WAKE_NO_RFCAL
  }

  // composer le contenu de la requete GET, dans la chaine 'url'
  String url = "/update?key=";
  url += myWriteAPIKey;
  url += "&field1=";
  url += String(voltage);
  url += "&field2=";
  url += String(session);
  url += "&field5=";
  url += String(tdallas);

  // envoi requete GET au serveur
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");

Did you try
.....
with no DNS ??

Yes but I don't remember effect from each 'trick' !!!!

Using static IP I am now able to get a consistent 165ms for router connection

Here (noisy environnement ? too many strong AP around me ?) I can't get consistant 200mS router's connection if device is more than 3 or 4 meter from AP.

I want to reach 9 month logging with 1500 mAh LifePo4 and begin some tests in two directions :
-replace DS18B20 by fast 12bits I2C TMP102
-send ("publish") data to local MQTT broker (Raspberry Pi connected to 'box' with Ethernet) and then
relay data to ThingSpeak withg some simple NodeRed code

(I still have no success in setting a local ThingSpeak server on my Raspberry Pi)

Amicalement :)
User avatar
By kas
#60742
So my goal is to bring the full session time (wake up, data acquisition, router connection, ThingSpeak connection, deep-sleep) below 800ms for
- 1-wire 18B20 (possibly 2 sensors at FULL 12 bits resolution)
- BMP180 temperature - BMP180 pressure
- battery voltage
- timing info
Still struggling to acquire the two 18B20 sensors at hi resolution within the suggested time frame :roll:

-send ("publish") data to local MQTT broker (Raspberry Pi connected to 'box' with Ethernet) and then relay data to ThingSpeak with some simple NodeRed code
I googled for "node-red" ...
wahoo, behind the door, yet another IoT alternate universe :o :o :o
Care to elaborate on your strategy versus ESP8266 direct MQTT connection ??
User avatar
By schufti
#60754 if you are not uploading your measurements directly to the web, then why use esp8266?
Using cheap serial RF for collecting node data you could build extremely low power sensor nodes.

Or, if it doesn't have to be "real time", collect one days values in spiffs and only transmit every 24hrs ...

and: yes you can use ip w/o setting dns if you connect to tsp via ip only, saves time for dns resolution but can break if they change ip...