Main Content

Results for

Ali Rasouli
Ali Rasouli
Last activity on 25 Oct 2021

I currently have my ThingSpeak log temp, airflow velocity raw and airflow velocity filtered. The column names show as field1, field 2 and field 3. Is there a way for me to change field1 to temperature? Thanks

Hi,

I am experiencing trouble in sending the actual sensor values to Thingspeak. I use a code template that I downloaded from a github repository https://github.com/mathworks/thingspeak-arduino/tree/master/examples/ESP32/WriteMultipleFields. The main issue is that I don't know how to fill out the source code to get real sensor values instead of random values.

I am using a DHT sensor, from which I want to measure both the temperature and the humidity. Here is what it looks like in the serial monitor after uploading the code to the ESP32 dev board.

Here is my code that I amended from the source template, and uploaded to the ESP32 board.

#include "DHT.h"
#include <WiFi.h>
#include "ThingSpeak.h"
// The wire is in pin 14 as required by the DHT-sensor, so it is written here:
#define DHTPIN 14    
// We use a DHT11-sensor
#define DHTTYPE DHT110
const char* ssid = "Koti_9BE9";   // your network SSID (name) 
const char* password = "XXXXXXX";   // your network password
WiFiClient  client;
// We write one (1) as the channel number. Assumably in that order in which they are in the MyChannels-page. 
unsigned long myChannelNumber = 1;
const char * myWriteAPIKey = "NW34MMOB5J1NGRL2";
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 10000; // This specifies what kind of delay we want between measurements. DHT11
// The fastest measurement interval of DHT sensors is 2000 ms (2 seconds).
// An object from where values are brought from the DHT library
DHT dht(DHTPIN, DHTTYPE);
// Initialize our values. Writing down the values that need to be measured from DHT-sensors: 
// humidity h, temperature t, and temperature in fahrenheit-scale f
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
String myStatus = "";
void setup() {
  Serial.begin(115200);
  Serial.println(F("DHT11 test!"));
    dht.begin();
    WiFi.mode(WIFI_STA);   
   ThingSpeak.begin(client);
  }
void loop() {
    delay(20000);
    float h = dht.readHumidity();
    float t = dht.readTemperature();
    float f = dht.readTemperature(true);
    if (isnan(h) || isnan(t) || isnan(f)) {
      Serial.println(F("Failed to read from DHT sensor!"));
      return;
    }
    if(WiFi.status() != WL_CONNECTED){      
      Serial.print("Attempting to connect");
      while(WiFi.status() != WL_CONNECTED){
        WiFi.begin(ssid, password); 
        delay(5000);     
      } 
      Serial.println("\nConnected.");
    }
    float hif = dht.computeHeatIndex(f, h);
    float hic = dht.computeHeatIndex(t, h, false);
    Serial.print(F("Humidity: "));
    Serial.print(h);
    Serial.print(F("%  Temperature: "));
    Serial.print(t);
    Serial.print(F("°C "));
    Serial.print(f);
    Serial.print(F("°F  Heat index: "));
    Serial.print(hic);
    Serial.print(F("°C "));
    Serial.print(hif);
    Serial.println(F("°F"));
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
  Serial.println("Channel update successful.");
}
else{
  Serial.println("Problem updating channel. HTTP error code " + String(x));
}
}

Many thanks for any advice.

Lauri

i have url that contains value for reading data, how can i send data to field from url that i have?

I have a project that collects data from a CO2 sensor and stored it in these ints:

    CO2PPM = (int)data[2] * 256 + (int)data[3];
    temperature = (int)data[4] - 40;  

which are defined as ints. Then just before the http request, they are processed like this:

       static char outstr3[15];
       static char outstr4[15];
       String dataString3 = dtostrf(CO2PPM, 8, 2, outstr3);
       String dataString4 = dtostrf(temperature, 8, 2, outstr4);

and finally used in the GET request:

          wifly.println("GET /update?api_key=apikey&field1="dataString4"&field2="+dataString3+" HTTP/1.1");

which fails to successfully register the data into TS. However if I hardcode it like this:

          wifly.println("GET /update?api_key=apikey&field1=23.45&field2=67.89 HTTP/1.1");

it works, the data is registered.

Any idea how to fix this issue?

Greetings!

So, I'm working on a project that needs to send collected data using a SIM808 over GPRS to ThingSpeak to multiple fields. The upload interval is 2 minutes with samples taken every 10 seconds and each batch of samples includes 19 bytes of data (12 sets of 19 bytes equal 228B for each bulk data pack that has to be sent and the memory can be flushed). It's worth mentioning that I'm using an Arduino Pro Mini (ATmega328P).

I've looked at the bulk data upload example, and I'm having some trouble adapting it to the SIM808. I am also not sure how to send multiple fields using the bulk method. Unfortunately, I don't have much time to tinker with the code as the whole project had to be done in 2 days and I've only got one day to finish. I'd appreciate any help regarding this as I'm on a very tight schedule.

Thanks in advance!

We've started a new video series on how and why to use ThingSpeak. IoT from Data to Action . Most of you pros here at the forum probably already know this stuff, but there's some great overview material in these videos if you are interested. Two of four planned movies are posted, Ill let you know again when the others come out too. -Christopher

Hi Distance Learning Community members, if you are looking for content in Descriptive Statistics and Probability Distributions for teaching in a course or just brushing up on the concepts yourself, check out these Live Scripts developed by Dr. Ward Nickle from Humboldt State University. If you are interested, this material is also available in Japanese . Enjoy and looking forward to hearing your thoughts!!

Hello! I have been working on an app for viewing thingspeak numerical data as graphs and I'm planning to publish it on playstore soon. If anybody is interested to test the beta version I would appreciate it. Here is the link https://play.google.com/apps/testing/com.mlundell.theThingV

ThankYou !

Magnus

I have both of my account profile and channel export time zones set to "(GMT+8000)Beijing". The datetime from the exported feeds.csv looks like:

'2021-09-06 11:16:28 CST'

I want to import data, but MATLAB do not directly understand its datetime format. I assume "CST" to be "China Standard Time", but when I try to convert it to datetime, MATLAB throws an error:

 >> datetime(s,'InputFormat',"yyyy-MM-dd HH:mm:ss z","TimeZone","Asia/Shanghai","Locale","zh_CN")
 Error using datetime (line 651)
 Unable to convert '2021-09-06 11:16:28 JST' to datetime using the format 'yyyy-MM-dd HH:mm:ss z' and locale 'zh_CN'.

However if I change the "Locale" to US instead:

>>datetime(s,'InputFormat',"yyyy-MM-dd HH:mm:ss z","TimeZone","Asia/Shanghai","Locale","en_US")
ans = 
    datetime
07-Sep-2021 01:16:28

There is no error, but the time is wrong and is 14 hours ahead. So I guess that MATLAB sees this "CST" as "Central Standard Time".

My point is:

  1. It's pretty strange that the datetime exported by ThingSpeak could not be directly understood by MATLAB. MATLAB is supposed to work with ThingSpeak data seamlessly, but now I have to find a detour to import ThingSpeak data to MATLAB.
  2. It seems that the datetime function needs improvement to understand this "CST" timezone, or that ThingSpeak could improve its datetime output format.

I'm not a programmer but I'm loving Thingspeak!

by way of background: i have been having mysterious PM 2.5 spikes on my PurpleAir several times a day (usually from ~12 ug/m3 to 100 ug/m3!!). i recently figured out what is causing it: i live by a charcoal burger place that sends smoke throughout my neighborhood when they relight their grill at peak hours. it is what it is unfortunately, until these restaurants get properly regulated.

that being said, i like to work in my yard, and id love to be able to just put on an N95 when a charcoal smoke event is happening. so i'm trying to use thingspeak to build a little notification system for me.

the PurpleAir Thingspeak channels are private (by default I believe), so I'm using a Matlab analysis to copy the raw data from the PurpleAir Thingspeak channel over to a channel I can administer.

next i set up TimeControls to run the data update Matlab analysis at 5 minute intervals, and staggered them apart from each other (the channel seems to be updating just about every minute now).

next i set up a React that, upon data insertion of a PM 2.5 value above 35 mg/um3, triggers a ThingHTTP which sends a request to Pushover's API --> so I get text messages and Chrome notifications when there are air events.

this seems to be working great so far -- the air in LA right now is pretty good, so it just captures the transient charcoal smoke events and notifies me of them.

but my concern is --> the air in LA can often get worse for extended periods. Some days, the average will be 40 ug/m3. so when those days inevitably come, will my system just be constantly chirping at me all day about the air values?

if so, is there anything i can do about this? is there a way to tell react to notify me, but then only retest again after an hour, for instance?

thanks for your help, thingspeak community!

Hi everyone,

I need your help. As of 10-4-2021 the option of &headers=false stopped working?

It worked beautifully for about 2 years (circa early 2020) and suddenly on 10-4 the headers are being returned despite this option in the URL (no testing with Chrome isn't a credible test, it internally suppresses them regardless)

Need your help, if there's a way to suppress headers and just return the value of interest as it worked prior to Monday 10-4-2021

Thank you Boyan

How do I code my arduino sketch in order to get the HTTP response from an arduino post?

Hello,

I am working on a project which measures the water level in a well and the temperature of the water. Currently, we have a few of these units deployed in the field and they are working well, but our environmental engineer does not like the water level graphs because they are not "intuitive" enough. The water levels displayed on our graphs are simply the distance between the surface of the water and our distance sensor, so when the water in the well rises, the y-axis value drops, which bothers the environmental guy. Is there a way to flip the y-axis without driving back out to these rural locations and flashing revised code to the mcu? I have been looking around the channel and graph settings and I do not see anything. Google has taken me to some matlab forum links which suggest changing values in objects, which I do not think is any help right now.

Any help is appreciated.

Hi,

my first time to use thingspeak. I have a graph where from time to time there is a peak with 4000, ussualy the data ist arround 50. When I insert the "hampel(my_variable)" I get a message that the toolbox is requierd.

Is there a different way to get rid of these spikes?

greetings

Title pretty much explains it. I can control a TMC2209 Stepper Motor controller or a BMP280 Barometric Pressure device, but when I hook both up to one MEGA if fails. Help would be greatly appreciated. The goal is to sample the barometric pressure, run a vacuum pump to bring the pressure down inside a vessel, then bring the pressure back to the sampled value and then run stepper motors with the TMC2209.

#include "SparkFunBME280.h"

//Stepper driver pin definitions #define PIN_STEP_ENABLE 14 #define PIN_STEP1_DIRECTION 13 #define PIN_STEP1_STEP 12

BME280 mySensorA; //Uses default I2C address 0x77 BME280 mySensorB; //Uses I2C address 0x76 (jumper closed)

void setup() { //Configuer stepper driver pins as OUTPUTs pinMode(PIN_STEP1_DIRECTION, OUTPUT); pinMode(PIN_STEP1_STEP, OUTPUT); pinMode(PIN_STEP_ENABLE, OUTPUT);

//ENABLE pin has to be pulled LOW for TMC2209 digitalWrite(PIN_STEP_ENABLE, LOW);

//Serial.begin(115200);

//Wire.begin();

mySensorA.setI2CAddress(0x76); //The default for the SparkFun Environmental Combo board is 0x77 (jumper open). //If you close the jumper it is 0x76 //The I2C address must be set before .begin() otherwise the cal values will fail to load.

if(mySensorA.beginI2C() == false) Serial.println("Sensor A connect failed"); //if I remark out his line and the line //like it for SensorB ( 2 lines down ) the stepper will run but I get no pressure readings, I stopped getting pressure //readings as soon as I added the code to operate the TMC2209

mySensorB.setI2CAddress(0x76); //Connect to a second sensor if(mySensorB.beginI2C() == false) Serial.println("Sensor B connect failed");

Wire.begin(); Serial.begin(115200);

}

void loop() { //determine starting direction of Stepper digitalWrite(PIN_STEP1_DIRECTION,HIGH);

// Makes 200 pulses for making one full cycle rotation for(int x = 0; x < 2000; x++) { Serial.println(" Forword "); digitalWrite(PIN_STEP1_STEP,HIGH); delayMicroseconds(50); digitalWrite(PIN_STEP1_STEP,LOW); delayMicroseconds(50); } delay(1000); // One second delay

digitalWrite(PIN_STEP1_DIRECTION,LOW); //Changes the rotations direction // Makes 400 pulses for making two full cycle rotation for(int x = 0; x < 2000; x++) { Serial.println(" Reverse "); digitalWrite(PIN_STEP1_STEP,HIGH); delayMicroseconds(50); digitalWrite(PIN_STEP1_STEP,LOW); delayMicroseconds(50); } delay(1000);

Serial.print(" PressureA: "); Serial.println(mySensorA.readFloatPressure(), 0);

//Serial.print(" PressureB: "); //Serial.println(mySensorB.readFloatPressure(), 0);

Serial.println();

delay(500); }

When I browse thingspeak,It loading so slow and can't read data from my project

I am trying to migrate a project that used to post from an Arduino with a Tinysine Wifly shield (from Roving networks) to a php form/mysql db using this code snippet:

void reportToCloud() {
  data = "";
  Serial.println("Reporting to cloud...");
   if (wifly.available() > 0) {
  char ch = wifly.read();
  Serial.write(ch);
  if (ch == '\n') {
      /* add a carriage return */ 
      Serial.write('\r');
  }
   }
     if (wifly.open(site, 80)) {
         Serial.print("Connected to ");
    Serial.println(site);
      // Set data to send
      static char outstr1[15];
      static char outstr2[15];
      static char outstr3[15];
      static char outstr4[15];
      String dataString1 = dtostrf(uvindex, 8, 2, outstr1);
      String dataString2 = dtostrf(mq2ratio, 8, 2, outstr2);
      String dataString3 = dtostrf(CO2PPM, 8, 2, outstr3);
      String dataString4 = dtostrf(temperature, 8, 2, outstr4);
      data = String("uvindex=" + dataString1 + "&mq2=" + dataString2 + "&age=" + dataString3 + "&name=" + dataString4);    
      Serial.print(data); //name = temp && age = co2
      //Reset all values
      uvindex = 0;
      mq2ratio = 0;
      CO2PPM = 0;
      temperature = 0;
          /* Send the request */
    wifly.println("POST /arduino/data_post.php HTTP/1.0");
    wifly.println("Host: www.santiapps.com"); // SERVER ADDRESS HERE TOO
          wifly.println("Content-Type: application/x-www-form-urlencoded" );
          wifly.print("Content-Length: ");
          wifly.println(data.length());
    wifly.println();
          wifly.print(data);
          Serial.println("Posted successfully");
     } else {
         Serial.println(">>Failed to connect");
     }
     if (Serial.available() > 0) {
    wifly.write(Serial.read());
     }
     //Added Sat 14 Nov @820am
     wifly.close();
  }

Now Im trying to make it post to thingspeak for improved analysis capabilities and what not. I get a post successful but I get no data in my thingspeak channel. I've checked the string used and its fine:

void reportToCloud() {
  data = "";
  Serial.println("Reporting to cloud...");
  if (wifly.available() > 0) {
    char ch = wifly.read();
    Serial.write(ch);
    if (ch == '\n') {
      /* add a carriage return */ 
      Serial.write('\r');
    }
  }
    if (wifly.open(site, 80)) {
      Serial.print("Connected to ");
      Serial.println(site);
      // Set data to send
      static char outstr3[15];
      static char outstr4[15];
      String dataString3 = "33.33";//dtostrf(33.33, 8, 2, outstr3);//dtostrf(CO2PPM, 8, 2, outstr3);
      String dataString4 = "44.44";//dtostrf(44.44, 8, 2, outstr4);//dtostrf(temperature, 8, 2, outstr4);
      data = String("field3=" + dataString3 + "&field4=" + dataString4);    
      //Serial.print(data); //for debugging
      //Reset all individual values
      CO2PPM = 0;
      temperature = 0;
      /* Send the request */
      String postData = "POST /update?api_key=mykey&"+data+" HTTP/1.0";
      //Serial.println(postData);
      wifly.println("Host: api.thingspeak.com"); // SERVER ADDRESS HERE TOO
      wifly.println("Content-Type: application/x-www-form-urlencoded" );
      wifly.print("Content-Length: ");
      wifly.println(postData.length());
      wifly.println();
      wifly.print(postData);
      Serial.println("Posted successfully");
    } else {
      Serial.println(">>Failed to connect");
    }
    if (Serial.available() > 0) {
      wifly.write(Serial.read());
    }
    //Added Sat 14 Nov @820am
    wifly.close();
  }

postData is printed with this result:

printing co2...
87 105 102 108 121 45 87 101 98 
false returned
Free memory: 670
setPrompt hasnt been called
Already joined network
DeviceID: Wifly-WebClient2
Reporting to cloud...
open santiapps.com 80
Connected to santiapps.com
POST /update?api_key=mykey&field3=33.33&field4=44.44 HTTP/1.0
Posted successfully
close: failed, no *CLOS*
Reporting to cloud...
open santiapps.com 80
Connected to santiapps.com
POST /update?api_key=mykey=33.33&field4=44.44 HTTP/1.0
Posted successfully
close: failed, no *CLOS*

So basically the first snippet works fine and posts to the db via my php form and i can then read it off the db. The second snippet returns what seems to be a successful post but the data is not posted to thingspeak.

what happen to thingspeak? it also loading so slow. it happen for almost a week, until now it has not been like normal

I am using a Microsoft surface laptop (running on Microsoft RT) and using a Explorer browser (which unfortunately cannot be upgraded to Microsoft Edge, or replaced by Chrome or Firefox). Until end of August 2021 I could log into ThingSpeak, with the login (email) entry fields in page https/:thingspeak.com (after clicking "Get started for free"). However since end of August this email entry item does not appear anymore on the webpage of thingspeak.com on my Surface. So I can't login anymore and thus can't use Thingspeak anymore on my Surface RT laptop. This is rather frustrating. Is there a possibility of provide arguments to the URL so that I can login directly (e.g. https://thingspeak.com/login?email?password, or something similar) or do you know another way to login. Your help is greatly appreciated.

Several educators worldwide use MATLAB Grader to scale assessments and automatically grade MATLAB coding assignments. MATLAB Grader can be used in any learning environment, for both formative assessments with automated feedback and summative assessments, such as quizzes and exams.

Educators often revise and update their MATLAB Grader problems. They may sometimes want to revisit a past version of a problem, such as to debug an assessment test error. Instructor users can now browse the version history for a specific problem and see draft and final versions.

Note that the versions are read-only and rollback is not supported at this time. However, you can copy code or descriptions and update the problem accordingly.

Get started with MATLAB Grader. If you are new to it, watch the MATLAB Grader Overview video and try the interactive Teaching with MATLAB online course (Section 6 is about MATLAB Grader).