Quantcast
Channel: ThingSpeak IoT Community - Forum: ESP8266 Wi-Fi Module
Viewing all 167 articles
Browse latest View live

mdahlb on Thingspeak and Wemos D1 Mini

$
0
0

Hello Tim

I have managed to read the last value (a temperature) from my private thingspeak channel with a Wemos D1 mini.. just replace the XXXXX in the code below with your personal settings:

 

#include "ThingSpeak.h"
#include <SPI.h>
#include <ESP8266WiFi.h>

char ssid[] = "XXXXXXX"; // your network SSID (name)
char pass[] = "XXXXXX"; // your network password

WiFiClient client;

unsigned long myChannelNumber = XXXXXXX;  // your channel number
const char * myReadAPIKey = "XXXXXX";  // your read api key

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
ThingSpeak.begin(client);
}

void loop() {
float temperature = ThingSpeak.readFloatField(myChannelNumber, 1, myReadAPIKey);  // reads a float, in this case a temperature
Serial.print("Last temperature: ");
Serial.print(temperature);
Serial.println(" *C");
delay(15000);
}


mdahlb on Sample code to retrive last value from Thinkspeak using ESP8266

$
0
0

If you just want to retrieve the last value for a channel you could use the official thingspeak/arduino library. That works fine. But if you also would like the date/time for the last value I don't think you could use that library. I'm having the same problem, I would like to get the timestamp for the last value as well.

PlStrss on Thingspeak library failure with returned Error codes! with cryptic meanings?

$
0
0

EmbarassedI'm new here and trying to post to a new channel via the Arduino IDE and a NodeMcu 0.9 ESP8266 board. I can post direct from a browser and see the results OK BUT when I run some code via the 

#include <ThingSpeak.h>

library e.g. the lines below... 

ThingSpeak.setField(1, float(20.2));
ThingSpeak.setField(2, float(23.4));
int ExitCode = ThingSpeak.writeFields(MyTSChannelNumber, MyTSWriteAPIKey);
if (ExitCode == 200)
{
Serial.print (" 200=Success! ");
}
else
{
Serial.print (" 🙁 Thingspeak Error Code = "); Serial.print(ExitCode);
}

I get a -302 error code!  and of course no data is written. Otherwise I am quite close to getting something done.

This is a "#define ERR_UNEXPECTED_FAIL     -302    // Unexpected failure during write to ThingSpeak"

Can anyone help with demystifying the library exit code or see a problem in what I have done? How can I test things better. I get a -301 when I sever the connection which is what I would expect.

Paul

DavidB on gaps in data recording

$
0
0

I agree on the cause, as I have the same issue. How did you fix the sync problem?

Nasser05 on Arduino+ESP8266+ThingSpeak

$
0
0

Hello,

I have problem to send data taken from temperature sensor on arduino using wifi shield "ESP8266". Neeeeed help

Here is the code:

#include <SoftwareSerial.h>
//#include <stdlib.h>

// LED
int ledPin = 13;
// LM35 analog input
int lm35Pin = 0;

// replace with your channel's thingspeak API key
String apiKey = "QWXWVLWCV42QPFFT";

// connect 10 to TX of Serial USB
// connect 11 to RX of serial USB
SoftwareSerial ser(10, 11); // RX, TX

// this runs once
void setup() {                
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);    

  // enable debug serial
  Serial.begin(9600);
  // enable software serial
  ser.begin(9600);
 
  // reset ESP8266
  ser.println("AT+RST");
}

// the loop
void loop() {
 
  // blink LED on board
  digitalWrite(ledPin, HIGH);   
  delay(200);               
  digitalWrite(ledPin, LOW);

  // read the value from LM35.
  // read 10 values for averaging.
  int val = 0;
  for(int i = 0; i < 10; i++) {
      val += analogRead(lm35Pin);   
      delay(500);
  }

  // convert to temp:
  // temp value is in 0-1023 range
  // LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C
  // So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt
  float temp = val*50.0f/1023.0f;

  // convert to string
  char buf[16];
  String strTemp = dtostrf(temp, 4, 1, buf);
 
  Serial.println(strTemp);
 
  // TCP connection
  String cm = "AT+CIPMUX=1";
  ser.println(cm);
 
  String cmd = "AT+CIPSTART=,\"TCP\",\"";
  cmd += "52.7.53.111"; // api.thingspeak.com
  cmd += "\",80";
  ser.println(cmd);
   
  if(ser.find("Error")){
    Serial.println("AT+CIPSTART error");
    return;
  }
 
  // prepare GET string
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr +="&field1=";
  getStr += String(strTemp);
  getStr += "

";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  ser.println(cmd);

  if(ser.find(">")){     // I thing problems begin here ! am i right ??????????????,
    ser.print(getStr);
  }
  else{
    ser.println("AT+CIPCLOSE");
    // alert user
    Serial.println("AT+CIPCLOSE");
  }
    
  // thingspeak needs 15 sec delay between updates
  delay(16000);  
}

AND I get on the monitor serie something like this :

AT+CIPCLOSE
27.5
AT+CIPCLOSE
28.0
AT+CIPCLOSE
27.4
AT+CIPCLOSE
27.4
AT+CIPCLOSE
27.4
AT+CIPCLOSE
27.4
AT+CIPCLOSE

So i thing the shield is connected but data not sent. Help me to solve pleeeeeaaaaaaaaaase

aissam on ThinSpeak Unreachable !

$
0
0
Hello,

I use an Arduino Uno linked to a LM35 temperature sensor, to ESP8266 01 and to my laptop, and I intend to send the data collected by the sensor to the ThingSpeak platform, and to do that I use the following code.
---------------------------------------------------------------------------------------------------------------------------------------------------------
int ledPin = 13;
// LM35 analog input
int lm35Pin = 0;

// replace with your channel's thingspeak API key
String apiKey = "T2RJXWQAVXG4ZV39";

// connect 10 to TX of Serial USB
// connect 11 to RX of serial USB
SoftwareSerial ser(10, 11); // RX, TX

// this runs once
void setup() {                
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);    

  // enable debug serial
  Serial.begin(9600); 
  // enable software serial
  ser.begin(9600);
  
  // reset ESP8266
  ser.println("AT+RST");
}


// the loop 
void loop() {
  
  // blink LED on board
  digitalWrite(ledPin, HIGH);   
  delay(200);               
  digitalWrite(ledPin, LOW);

  // read the value from LM35.
  // read 10 values for averaging.
  int val = 0;
  for(int i = 0; i < 10; i++) {
      val += analogRead(lm35Pin);   
      delay(500);
  }

  // convert to temp:
  // temp value is in 0-1023 range
  // LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C
  // So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt
  float temp = val*50.0f/1023.0f;

  // convert to string
  char buf[16];
  String strTemp = dtostrf(temp, 4, 1, buf);
  
  Serial.println(strTemp);
  
  // TCP connection
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149"; // api.thingspeak.com
  cmd += "\",80";
  ser.println(cmd);
   
  if(ser.find("Error")){
    Serial.println("AT+CIPSTART error");
    return;
  }
  
  // prepare GET string
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr +="&field1=";
  getStr += String(strTemp);
  getStr += "

";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  ser.println(cmd);

  if(ser.find(">")){
    ser.print(getStr);
  }
  else{
    ser.println("AT+CIPCLOSE");
    // alert user
    Serial.println("AT+CIPCLOSE");
  }
    
  // thingspeak needs 15 sec delay between updates
  delay(16000);  
}
----------------------------------------------------------------------------------------------------------------------------------------------------------
When I upload the code the ESP8266 connects to my WiFi network and I get an IP address, I can PING it .. in brief, no connection problems.
But the upload of my data to ThingSpeak does not work, I can not visualize anything in the platform and the serial monitor shows the temperature value and "AT + CIPCLOSE" (which means, I think, that after "AT + = CIPSEND data_length" I do not get a ">")
If you can see my error(s) and how to correct it: D

Thank you.

fahimhaider on data not show on thingspeak

$
0
0

Dear ALL

I am sending temperature data to thingspeak but it did't show in my channel. Below is my code. Please give me the suggestion.

t=require("ds18b20_1")
pin = 1
t.setup(pin)
addrs = t.addrs()
if (addrs ~= nil) then
  print("Total DS18B20 sensors: "..table.getn(addrs))
   end

-------------------------------------------------------------------------------
wifi.setmode(wifi.STATIONAP)
wifi.sta.config("INNEXIV", "innexiv$1")
tmr.alarm(0,5000,1, function()    -- 5sec for get the ip address for router
   add = wifi.sta.getip()
   if(add == nil) then
      print("Connecting to AP...
")
   else
      ip, nm, gw=wifi.sta.getip()
      print("IP Info:
IP Address: ",ip)
      print("Netmask: ",nm)
      print("Gateway Addr: ",gw,'
')
      tmr.stop(0)
   end
end)
-------------------------------------------------
function sendData()
  value=ds18b20_1.read()
-- print("temp",value)
print("Sending data to thingspeak.com")
conn=net.createConnection(net.TCP,false)
conn:on("receive", function(conn, payload) print(payload) end)
-- api.thingspeak.com 184.106.153.149
conn:connect(80,'184.106.153.149')
conn:send("GET /update?key=XDKWXU7SQ39WXXPY&field1="..value.." HTTP/1.1
")
conn:send("Host: api.thingspeak.com
")
conn:send("Accept: */*
")
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)
")
conn:send("
")
conn:on("sent",function(conn)
                      print("Closing connection")
                      conn:close()
                  end)
conn:on("disconnection", function(conn)
          print("Got disconnection...")
  end)
end
-- send data every X ms to thing speak
tmr.alarm(2, 60000, 1, function() sendData() end )

--------------------------------------------------------

Hans on data not show on thingspeak


rberkelm on Data do not show in ThingSpeak

$
0
0

Hi All

I in my earliest stages of trying to post data to my Thingspeak channel via an ESP8266. I have managed to successfully send data via my browser, but via my ESP does not seem to work. I have my ESP connected via a FTDI converter and am using Terminal V1.93b as a serial terminal program. The data I attempt to send seems to be successfully sent according to the Terminal program. However, when I check my thingspeak channel, there are no updates. I've been at this for 3 days and I've tried all sorts of permutations, incl the number of /r/n's at the end of the GET line. Now I am at a total loss. Can someone please help?

Log of terminal connection:

Terminal log file
Date: 23/06/2016 - 9:26:09 PM
-----------------------------------------------
AT+CIPSTART=1,"TCP","api.thingspeak.com",80

OK
Linked
AT+CIPSEND=1,52

> GET /update?api_key=27YZ7P1D60A7X1CH&field2=41

busy s...

SEND OK

OK
Unlink

-----------------------------------------------
Date: 23/06/2016 - 9:27:26 PM
End log file

piajola on Data do not show in ThingSpeak

$
0
0

Hi rberkelm,

Please read this post, my aswer is part 2.

http://community.thingspeak.com/forum/thingspeak-projects/esp8266-and-thingspeak

I use windows and termite (http://www.compuphase.com/software_termite.htm) but ANY RS232 terminal will do.

Please check AT+GMR because different AT versions have "different syntax". (In my case I must test in my Arduino program for the answer "ERROR" because with other version the test must be done against "Error" and the program fails. UPPERCASE ... lowercase)

ESP8266 -> Thingspeak works!

Hope this helps ... questions? Smile

Regards

rberkelm on Data do not show in ThingSpeak

$
0
0

Yeehah!! It worked - I am stoked! Piajol, you have made my day, thank you!

So, for the record, at the time of my original post I was running the default version of the AT firmware (008000901) with its 115200 baud rate. Later in the night I reflashed to AT firmware 008000902 (AI Thinker) with a baud rate of 9600 hoping I would do better. Unfortunately it made it even worse as I now could not even link to the ThingSpeak site with my syntax above.

However thanks to you I was successful with the following syntax and settings:

AT+GMR      '008000902.
AT+CWMODE=3  'ESP is both a station and a server
AT+CIPMODE=0
AT+CIPMUX=0   'Single channel
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSEND=62
GET /update?api_key=27YZ7P1D60A7X1CH&field1=33.5&field2=65.5

To all first-timers like me, the ESP is incredibly sensitive to syntax variation between Firmware variations, so beware! Thanks again for setting me straight!

Ray

piajola on Data do not show in ThingSpeak

$
0
0

Hi Ray,

Glad you are in the game 😀

Any further help ... ask

Regards

H.S.

jenifferhomes on Error 400 Bad Request

$
0
0

i get 400 error while im trying to receive data with second device. To make sure it's not problem with my code i used Termite terminal and simply send AT commands to ESP. CR and LF signs are enabled.

oded on inconsistent data readings from thingspeak - thingspeak library + arduino +esp8266

$
0
0

hi all.

 i try this forum since i had no success in the arduino thinspeak forum.

sorry for double posting - !!

 

i try to read last values of 3 field set  of thhingspeak channel.

like that:-

after setting up client with these libraries

#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspServer.h>
#include <WiFiEspUdp.h>

#include <ThingSpeak.h> ////<<<<<<<<<<<<<<

etc.

etc.

 

void loop() {

int field1 = ThingSpeak.readIntField(141045,1);
Serial.println();
delay(1000);
Serial.print("field 1 is: ");
Serial.print(field1);
Serial.println();
int field2 = ThingSpeak.readIntField(141045,2);
Serial.println();
delay(10000);
Serial.print("field 2 is: ");
Serial.print(field2);
Serial.println();
int field3 = ThingSpeak.readIntField(141045,3);
Serial.println();
delay(10000);
Serial.print("field 3 is: ");
Serial.println(field3);
Serial.println();

delay(10000); // Note that the weather station only updates once a minute

;};

 

PROBLEM:

I set the data to be   600 , 600,600 

i get unstable readings (of same line wihch i try to read for testing purposes over the loop),

as follows  over the arduino  mega serial terminal 

 

field 1 is: 0
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600 

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 607
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

 

any body can explain  whats wrong here ?

 

is it low memory of arduino as one suggested  somewhere  ?

 

wifi is strong , and all results come ok over http terminal .

 

thanks  

Oded,

Vinod on inconsistent data readings from thingspeak - thingspeak library + arduino +esp8266

$
0
0

Is your device having a brownout?

Frequently the power consumption of the device will momentarily increase when it needs to transmit data over WiFi. If the power source is not capable of supplying the required power, a brownout may occur. I've had this happen to me with several ESP8266 devices.

Some things to try:

  1. Connect your device using an ethernet cable (if that is an option) and power it by external power (as opposed to battery power) and see if it reliably retrieves data
  2. If (1) works, then power it by new battery/freshly charged battery and ensure it works reliably
  3. If (2) works, then switch to wifi at a spot that has strong Wifi signal and ensure it works reliably 
  4. If (3) works, deploy device in field

prince1 on how measure several 18D20 on ESP8266

$
0
0

Hello All

 

Im trying to find out how can i setup on one ESP8266 E12 with thingspeak  dallas sensors?

i have an ESP8266 with 3 18D20 sensors that working fine, how do i setup 3 reading in the same time via thingspeak ?

 

can anybody direct me to the right process or code ?

thanks

abduu on connecting arduino to my android application

$
0
0

so i am using arduino uno with ESP8266-01 wifi module and i made my own application that receives notifications so i want to connect the arduino to this application to send notifications when something specific happens so can you help me please ?

Vinod on connecting arduino to my android application

Vinod on how measure several 18D20 on ESP8266

$
0
0

Currently you can only post to a specific channel once every 15 seconds. So, if you want 3 devices to post, you may need to do some sort of aggregation where a device collects the data from the other two devices and posts to ThingSpeak every 15 seconds.

Alternatively, you can create 3 channels and have each device post to its own channel.

rw950431 on how measure several 18D20 on ESP8266

Viewing all 167 articles
Browse latest View live