Main Content

Results for

Dear all, I am using the micro:bit with ESP-01s and the CO2 sensor to monitor indoor air quality. Thingspeak cannot show the data eventhough the ESP is connected to the wifi (checked with the router). Failed to talk to my ESP even I have setup a new channel many times. Can anyone advise me what to do?

Thank you for your help in advance.

hello, when I add a visualization, it is written "Field value unavailable" can somebody assist ?

many thanks

Satellite Communications Toolbox
53%
Mapping Toolbox
9%
Signal Processing Toolbox
14%
Navigation Toolbox
19%
Other (Explain in comments)
4%
2403 votes

Hi, I'm trying to send with a serial connection a signal. The signal is just a byte (uint8) that I want to send to my evaluation board every 1 millisecond using Simulink. How can I do that? I tried using the Serial Send block, but the result is different from what I expected to see. Then I tried to use the To instrument block, but I don't know why there isn't the port COM 5 so I couldn't use it.

The third movie in our new series is live. We focus on MATLAB Analysis and Visualizations in this video. You can see how to set up code to preprocess your data and how to add custom visualizations.

So far I haven't found an option to change the channel's name, neither on website nor in the API. Is it possible to change the channel name?

Hi, I am currently working on IOT control using ZYBO-Z7 FPGA with the Pmod ESP32, my goal is to read multiple data across 8 fields simultaneously, my current method is reading data from individual fields manually using the code given from this user from a digilent forum (https://forum.digilentinc.com/topic/21634-retrieve-data-from-thingspeak-through-using-pmod-esp32/), this method makes the control slow as I have to individually wait for 8 fields of data one by one. My current solution I am testing out is to read json data using the C++ code below, however the json file is a placed in constant and can only read from that specific array and does not update real time data from thingspeak, how do I get my ZYBO-Z7 to process multiple data from a single feed with 8 fields all from one json URL? Much needed help please and thanks.

/*
 * This workspace attempts to parse (deserialize) a serialize json data
 * from thingspeak (see project_4_1). The code below was extracted (with some editing) from
 * arduinojson.org/v5/assistant after I input the serialize json data
 * from project_4_1: {"channel":{"id":1410948,"name":"testing","latitude":"0.0","longitude":"0.0","field1":"temp","field2":"ph","created_at":"2021-06-08T07:08:42Z","updated_at":"2021-06-09T04:58:00Z","last_entry_id":3},"feeds":[{"created_at":"2021-06-08T08:05:31Z","entry_id":1,"field1":"63"},{"created_at":"2021-06-08T08:07:35Z","entry_id":2,"field1":"76"},{"created_at":"2021-06-08T08:14:50Z","entry_id":3,"field1":"56"}]}
 * The extracted code from arduinojson assistant was tested in
 * https://wandbox.org/permlink/T07A43gUP3EuZjaF
*/
#include <iostream> //if complained of "unresolved inclusion", just build project
#include <ArduinoJson-v5.13.5.h>
#include "xparameters.h"
#include "xil_printf.h"
#include "sleep.h"
#include "stdio.h"
#include "xtime_l.h"
#include "stdlib.h"  //added
#include "string.h"
#include "xgpiops.h"
extern"C"{
#include "PmodESP32.h"
}
#ifdef __MICROBLAZE__
#define HOST_UART_DEVICE_ID XPAR_AXI_UARTLITE_0_BASEADDR
#define HostUart XUartLite
#define HostUart_Config XUartLite_Config
#define HostUart_CfgInitialize XUartLite_CfgInitialize
#define HostUart_LookupConfig XUartLite_LookupConfig
#define HostUart_Recv XUartLite_Recv
#define HostUartConfig_GetBaseAddr(CfgPtr) (CfgPtr->RegBaseAddr)
#include "xuartlite.h"
#include "xil_cache.h"
#else
#define HOST_UART_DEVICE_ID XPAR_PS7_UART_1_DEVICE_ID
#define HostUart XUartPs
#define HostUart_Config XUartPs_Config
#define HostUart_CfgInitialize XUartPs_CfgInitialize
#define HostUart_LookupConfig XUartPs_LookupConfig
#define HostUart_Recv XUartPs_Recv
#define HostUartConfig_GetBaseAddr(CfgPtr) (CfgPtr->BaseAddress)
#include "xuartps.h"
#endif
#define PMODESP32_UART_BASEADDR XPAR_PMODESP32_0_AXI_LITE_UART_BASEADDR
#define PMODESP32_GPIO_BASEADDR XPAR_PMODESP32_0_AXI_LITE_GPIO_BASEADDR
#define BLOCK_SIZE 40
void EnableCaches();
void DisableCaches();
void DemoInitialize();
void DemoRun();
void DemoCleanup();
void receiveData(XTime time);
void setWifiMode(void);
void connectWifi(void);
void establishConnection(void);
void cipsend(void);
PmodESP32 ESP32;
HostUart myHostUart;
XTime TimeStart;
XTime TimeEnd;
int countdown =60;
char *ptr;
XGpioPs_Config *ConfigPtr;
static XGpioPs Gpio;
u8 light;
u8 light1; //ALS
u16 eCO2;
u16 TVOC;
u8 buf[5]; //AQS
u8 recv_buffer;
u32 num_received;
const float ReferenceVoltage = 3.3;
int sec = 0;
int min = 0;
int hour = 0;
int x = 0;
int j = 0;
int status;
int fakecount1 = 0;
int fakecount2 = 0;
int floatmotor = 0;
int floatpumpspoil = 0;
int motorreal = 0;
int DosingDone = 0;
int led1status = 0;
int led234status = 0;
int pumpstatus = 0;
int motorstatus = 0;
int pumpbroken = 0;
int checkingEC = 0;
float ECvalue = 0;
float PHvalue = 0;
void DemoInitialize () {
	HostUart_Config *CfgPtr;
	EnableCaches();
	ESP32_Initialize(&ESP32, PMODESP32_UART_BASEADDR, PMODESP32_GPIO_BASEADDR);
	CfgPtr = HostUart_LookupConfig(HOST_UART_DEVICE_ID);
	HostUart_CfgInitialize(&myHostUart, CfgPtr, HostUartConfig_GetBaseAddr(CfgPtr));
	   ConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
	   XGpioPs_CfgInitialize(&Gpio, ConfigPtr, ConfigPtr->BaseAddr);
	   XGpioPs_SetDirectionPin(&Gpio, 13, 1);
	   XGpioPs_SetOutputEnablePin(&Gpio, 13,1); //pin1 JF1 layer 1 LED #
	   XGpioPs_SetDirectionPin(&Gpio, 10, 1);
	   XGpioPs_SetOutputEnablePin(&Gpio, 10,1); //pin2 JF2 layer 2, 3, 4 LED #
}
void DemoRun() {
	setWifiMode();
	connectWifi();
	establishConnection();
	cipsend();
}
void DemoCleanup() {
	DisableCaches();
}
int main() {
	DemoInitialize();
	DemoRun();
	      free(ptr);
	      const size_t capacity = JSON_OBJECT_SIZE(10) + 140;
	      DynamicJsonBuffer jsonBuffer(capacity);
	      //const char* json = "{\"created_at\":\"2021-11-19T05:33:15Z\",\"entry_id\":134,\"field1\":\"0\",\"field2\":\"1\",\"field3\":\"1\",\"field4\":\"1\",\"field5\":\"2\",\"field6\":\"2\",\"field7\":\"2\",\"field8\":\"10\"}";
	      JsonObject& root = jsonBuffer.parseObject(json);
	      const char* created_at = root["created_at"]; // "2021-11-19T05:33:15Z"
	      int entry_id = root["entry_id"]; // 134
	      const char* field1 = root["field1"]; // "0"
	      const char* field2 = root["field2"]; // "1"
	      const char* field3 = root["field3"]; // "1"
	      const char* field4 = root["field4"]; // "1"
	      const char* field5 = root["field5"]; // "2"
	      const char* field6 = root["field6"]; // "2"
	      const char* field7 = root["field7"]; // "2"
	      const char* field8 = root["field8"]; // "10"
	      if(root["field1"] == "1")
	      {
	    	  xil_printf("1");
	      }
	      else if(root["field1"] == "0")
	      {
	    	  xil_printf("0");
	      }
	      else
	      {
	    	  xil_printf("error reading");
	      }
	      if(root["field2"] == "1")
	      {
	    	  xil_printf("1");
	      }
	      else if(root["field2"] == "0")
	      {
	    	  xil_printf("0");
	      }
	      else
	      {
	    	  xil_printf("error reading");
	      }
	      if(root["field3"] == "1")
	      {
	    	  xil_printf("1");
	      }
	      else if(root["field3"] == "0")
	      {
	    	  xil_printf("0");
	      }
	      else
	      {
	    	  xil_printf("error reading");
	      }
	      if(root["field4"] == "1")
	      {
	    	  xil_printf("1");
	      }
	      else if(root["field4"] == "0")
	      {
	    	  xil_printf("0");
	      }
	      else
	      {
	    	  xil_printf("error reading");
	      }
	      if(root["field5"] == "1")
	      {
	    	  xil_printf("1");
	      }
	      else if(root["field5"] == "0")
	      {
	    	  xil_printf("0");
	      }
	      else
	      {
	    	  xil_printf("error reading");
	      }
	DemoCleanup();
	return 0;
}
void setWifiMode(void){
    u8 tx[]="AT+CWMODE=3\r\n";
    u32 num = strlen((char *) tx);
    xil_printf((char *) tx);
    ESP32_SendBuffer(&ESP32, tx, num);
    usleep(100000);
    receiveData(1);
}
void connectWifi(void){
    u8 tx[] = "AT+CWJAP=\"eee-iot\",\"gr3enChess30\"\r\n";
    u32 num = strlen((char *) tx);
    xil_printf((char *) tx);
    ESP32_SendBuffer(&ESP32, tx, num);
    usleep(100000);
    receiveData(9);
}
void receiveData(XTime time){
    XTime tEnd, tCur;
    u8 recv_buffer=0;
    u32 num_received=0;
      XTime_GetTime(&tCur);
      tEnd  = tCur + (time * COUNTS_PER_SECOND);
      do
      {
          num_received = ESP32_Recv(&ESP32, &recv_buffer,1);
                  if(num_received >0){
                      num_received = ESP32_Recv(&ESP32, &recv_buffer,1);
                      xil_printf("%c", recv_buffer);
                  }
          if(tCur == tCur + COUNTS_PER_SECOND){
              countdown = countdown -1;
          }
          else
              XTime_GetTime(&tCur);
      } while (tCur < tEnd);
}
void receiveData2(XTime time){
    XTime tEnd, tCur;
    u8 recv_buffer=0;
    u32 num_received=0;
      int i=0;
      int max_index = BLOCK_SIZE-1;
      ptr = (char*) malloc(sizeof(int)*BLOCK_SIZE);  //compare with project_4_3 or _4_1 where (int*) is not required because it is a C file in those projects
      if(ptr==NULL)
      {
          perror("some error");
          //return 1;
      }
      XTime_GetTime(&tCur);
      tEnd  = tCur + (time * COUNTS_PER_SECOND);
      do
      {
          num_received = ESP32_Recv(&ESP32, &recv_buffer,1);
                  if(num_received >0){
                      num_received = ESP32_Recv(&ESP32, &recv_buffer,1);
                          if(i > max_index)
                          {
                              ptr=(char*) realloc(ptr, (max_index+1 + BLOCK_SIZE)*sizeof(int));  //compare with project_4_3 or _4_1 where (int*) in realloc is not required because it is a C file in those projects
                              if(ptr == NULL)
                              {
                                  perror("insufficient memory!");
                                  break;
                              }
                              //printf("\nReallocated!");
                              max_index += BLOCK_SIZE;
                          }
                          ptr[i]=recv_buffer;
                          i++;
                      //}
                  }
          if(tCur == tCur + COUNTS_PER_SECOND){
             countdown = countdown -1;
          }
          else
              XTime_GetTime(&tCur);
      } while (tCur < tEnd);
}
void establishConnection(void){
    u8 tx[] = "AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80\r\n";
    u32 num = strlen((char *) tx);
    ESP32_SendBuffer(&ESP32, tx, num);
    receiveData(1);
}
void cipsend(void){
    u8 command[150];
    u8 finalcmd[50];
      sprintf((char*)command, "GET https://api.thingspeak.com/channels/1572052/feeds/last.json/?api_key=xxxxxxxxxxxxxxxx\r\n");
      u32 length = strlen((char*)command);
      sprintf((char*)finalcmd, "AT+CIPSEND=%d\r\n", (int)length);
      u32 cmdlength =strlen((char*)finalcmd);
      xil_printf("Length %d\r\n", length);
      xil_printf((char *)finalcmd);
      ESP32_SendBuffer(&ESP32, finalcmd, cmdlength);
      usleep(100000);
      xil_printf((char *)command);
      ESP32_SendBuffer(&ESP32, command, length);
      receiveData2(1);
}
void EnableCaches() {
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHE
   Xil_ICacheEnable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHE
   Xil_DCacheEnable();
#endif
#endif
}
void DisableCaches() {
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHE
   Xil_ICacheDisable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHE
   Xil_DCacheDisable();
#endif
#endif
}

i am trying to decode the below sketch to integrate TTNv3 to thingspeak.

can someone help me with this issue

#include <lmic.h>
#include <dht.h>
#include <hal/hal.h>
#include <SPI.h>
dht DHT;
#define DHT11_PIN 5
#define PIN_A A0
float temperature,humidity;      
float tem,hum;
unsigned int count = 1;        //For times count
String datastring1="";        
String datastring2="";        
String datastring3="";
static uint8_t mydata[11] = {0x01,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x65,0x00,0x00};
/* LoRaWAN NwkSKey, network session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const PROGMEM u1_t NWKSKEY[16] = { 0x72, 0x13, 0xF8, 0xF0, 0x9A, 0x3C, 0xF9, 0xE5, 0xE6, 0x01, 0xDA,0xAC, 0x32, 0xBA, 0x37 };
/* LoRaWAN AppSKey, application session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const u1_t PROGMEM APPSKEY[16] = { 0x2F, 0xF5, 0xF4, 0x08, 0x4E, 0x37, 0x20, 0x02, 0xBA, 0x2B, 0xED,  0x40, 0x24, 0xA2, 0x945 };
/*
 LoRaWAN end-device address (DevAddr)
 See http://thethingsnetwork.org/wiki/AddressSpace
 ttn*/
static const u4_t DEVADDR = 0x260D0CA5;
/* These callbacks are only used in over-the-air activation, so they are
  left empty here (we cannot leave them out completely unless
   DISABLE_JOIN is set in config.h, otherwise the linker will complain).*/
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }
static osjob_t initjob,sendjob,blinkjob;
/* Schedule TX every this many seconds (might become longer due to duty
 cycle limitations).*/
const unsigned TX_INTERVAL = 10;
// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 10,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 9,
    .dio = {2, 6, 7},
};
void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println("OP_TXRXPEND, not sending");
    } else {
          dhtTem();
          light();
          // Prepare upstream data transmission at the next possible time.
          //  LMIC_setTxData2(1,datasend,sizeof(datasend)-1,0);
          LMIC_setTxData2(1, mydata, sizeof(mydata), 0);
          Serial.println("Packet queued");
          Serial.print("LMIC.freq:");
          Serial.println(LMIC.freq);
          Serial.println("Receive data:");
      } 
      // Next TX is scheduled after TX_COMPLETE event.
  }
void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    Serial.println(ev);
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            break;
        case EV_RFU1:
            Serial.println(F("EV_RFU1"));
            break;
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            if(LMIC.dataLen) {
                // data received in rx slot after tx
                Serial.print(F("Data Received: "));
                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
                Serial.println();
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
         default:
            Serial.println(F("Unknown event"));
            break;
    }
}
void setup() {
     // initialize digital pin  as an output.
      Serial.begin(9600);
      while(!Serial);
      Serial.println("Connect to TTN and Send data to mydevice(Use DHT11 Sensor):");
      #ifdef VCC_ENABLE
      // For Pinoccio Scout boards
      pinMode(VCC_ENABLE, OUTPUT);
      digitalWrite(VCC_ENABLE, HIGH);
      delay(1000);
      #endif
      // LMIC init
      os_init();
      // Reset the MAC state. Session and pending data transfers will be discarded.
      LMIC_reset();
      /*LMIC_setClockError(MAX_CLOCK_ERROR * 1/100);
       Set static session parameters. Instead of dynamically establishing a session
       by joining the network, precomputed session parameters are be provided.*/
      #ifdef PROGMEM
      /* On AVR, these values are stored in flash and only copied to RAM
         once. Copy them to a temporary buffer here, LMIC_setSession will
         copy them into a buffer of its own again.*/
      uint8_t appskey[sizeof(APPSKEY)];
      uint8_t nwkskey[sizeof(NWKSKEY)];
      memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
      memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
      LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
      #else
      // If not running an AVR with PROGMEM, just use the arrays directly 
      LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
      #endif
       for (int channel=0; channel<8; ++channel) {
      LMIC_disableChannel(channel);
    }
    for (int channel=16; channel<72; ++channel) {
       LMIC_disableChannel(channel);
    }
      // Disable link check validation
      LMIC_setLinkCheckMode(0);
      // TTN uses SF9 for its RX2 window.
      LMIC.dn2Dr = DR_SF9;
      // Set data rate and transmit power (note: txpow seems to be ignored by the library)
      LMIC_setDrTxpow(DR_SF7,14);
      // Start job
      do_send(&sendjob);
  }
  void dhtTem()
  {
         int16_t tem1;
         temperature = DHT.read11(DHT11_PIN);    //Temperature detection
         tem = DHT.temperature*1.0;      
        float humidity = DHT.read11(DHT11_PIN);
        float hum = DHT.humidity* 1.0;
        Serial.print(F("###########    "));
         Serial.print(F("NO."));
         Serial.print(count);
         Serial.println(F("    ###########"));
         Serial.println(F("The temperautre and humidity :"));
         Serial.print(F("["));
         Serial.print(tem);
         Serial.print(F("℃"));
         Serial.print(F(","));
         Serial.print(hum);
         Serial.print(F("%"));
         Serial.print(F("]"));
         Serial.println("");
         count++;
         tem1=(tem*10);
         mydata[2] = tem1>>8;
         mydata[3]= tem1;
         mydata[6] = hum * 2;
}
void light(){
      int16_t lux;
      int val,val1;
      val=analogRead(PIN_A);
     // Serial.print(F("a:"));
      //Serial.println(val);
      delay(500);
      val1=val*1.0;
      lux=val1;
      mydata[9]=lux>>8;
      mydata[10]=lux;
       //Serial.print(lux);
}
void loop() {
    os_runloop_once();
}

Hi there,

I have tried to get the data on thingspeak via integrating it on the things Network. but the GPS data I am receiving on the thingspeak is delayed by 2 mins.

is there any way I can code to send JSON file straight on thingspeak from the sensor or the gateway?

Following is the ardiuno sketch

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
TinyGPS gps;
SoftwareSerial ss(3, 4); // Arduino RX, TX to conenct to GPS module.
static void smartdelay(unsigned long ms);
unsigned int count = 1;        //For times count
String datastring1="";        
String datastring2="";        
String datastring3="";
uint8_t datasend[20];     //Used to store GPS data for uploading
char gps_lon[20]={"\0"};  //Storage GPS info
char gps_lat[20]={"\0"}; //Storage latitude
char gps_alt[20]={"\0"}; //Storage altitude
float flat, flon,falt;
static uint8_t mydata[] = "Hello, world!";      //For test using.
/* LoRaWAN NwkSKey, network session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const PROGMEM u1_t NWKSKEY[16] =  { 0xE4, 0x2A, 0x93, 0x96, 0xF7, 0xC9, 0x65, 0x9E, 0xF8, 0x90, 0xC6, 0xA0, 0x1A, 0x88, 0xF7, 0x47 };
/* LoRaWAN AppSKey, application session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const u1_t PROGMEM APPSKEY[16] = { 0x75, 0x43, 0x26, 0xA1, 0x82, 0x79, 0x7F, 0xCF, 0x3C, 0x1D, 0xBF, 0xF9, 0xBF, 0xCB, 0xC6, 0xD9 };
/*
 LoRaWAN end-device address (DevAddr)
 See http://thethingsnetwork.org/wiki/AddressSpace
 ttn*/
static const u4_t DEVADDR = 0x260111D1;
/* These callbacks are only used in over-the-air activation, so they are
  left empty here (we cannot leave them out completely unless
   DISABLE_JOIN is set in config.h, otherwise the linker will complain).*/
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }
static osjob_t initjob,sendjob,blinkjob;
/* Schedule TX every this many seconds (might become longer due to duty
 cycle limitations).*/
const unsigned TX_INTERVAL = 20;
// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 10,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 9,
    .dio = {2, 6, 7},
};
void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println("OP_TXRXPEND, not sending");
    } else {
        GPSRead();
        GPSWrite();
          // Prepare upstream data transmission at the next possible time.
            LMIC_setTxData2(1,datasend,sizeof(datasend)-1,0);
          //LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
          Serial.println("Packet queued");
          Serial.print("LMIC.freq:");
          Serial.println(LMIC.freq);
          Serial.println("");
          Serial.println("");
          Serial.println("Receive data:");
      } 
      // Next TX is scheduled after TX_COMPLETE event.
  }
void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    Serial.println(ev);
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println("EV_SCAN_TIMEOUT");
            break;
        case EV_BEACON_FOUND:
            Serial.println("EV_BEACON_FOUND");
            break;
        case EV_BEACON_MISSED:
            Serial.println("EV_BEACON_MISSED");
            break;
        case EV_BEACON_TRACKED:
            Serial.println("EV_BEACON_TRACKED");
            break;
        case EV_JOINING:
            Serial.println("EV_JOINING");
            break;
        case EV_JOINED:
            Serial.println("EV_JOINED");
            break;
        case EV_RFU1:
            Serial.println("EV_RFU1");
            break;
        case EV_JOIN_FAILED:
            Serial.println("EV_JOIN_FAILED");
            break;
        case EV_REJOIN_FAILED:
            Serial.println("EV_REJOIN_FAILED");
            break;
        case EV_TXCOMPLETE:
            Serial.println("EV_TXCOMPLETE (includes waiting for RX windows)");
            if(LMIC.dataLen) {
                // data received in rx slot after tx
                Serial.print("Data Received: ");
                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
                Serial.println();
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println("EV_LOST_TSYNC");
            break;
        case EV_RESET:
            Serial.println("EV_RESET");
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println("EV_RXCOMPLETE");
            break;
        case EV_LINK_DEAD:
            Serial.println("EV_LINK_DEAD");
            break;
        case EV_LINK_ALIVE:
            Serial.println("EV_LINK_ALIVE");
            break;
         default:
            Serial.println("Unknown event");
            break;
    }
}
void setup() {
     // initialize digital pin  as an output.
      Serial.begin(9600);
       ss.begin(9600);  
      while(!Serial);
      Serial.println("LoRa GPS Example---- ");
      Serial.println("Connect to TTN");
      #ifdef VCC_ENABLE
      // For Pinoccio Scout boards
      pinMode(VCC_ENABLE, OUTPUT);
      digitalWrite(VCC_ENABLE, HIGH);
      delay(1000);
      #endif
      // LMIC init
      os_init();
      // Reset the MAC state. Session and pending data transfers will be discarded.
      LMIC_reset();
      /*LMIC_setClockError(MAX_CLOCK_ERROR * 1/100);
       Set static session parameters. Instead of dynamically establishing a session
       by joining the network, precomputed session parameters are be provided.*/
      #ifdef PROGMEM
      /* On AVR, these values are stored in flash and only copied to RAM
         once. Copy them to a temporary buffer here, LMIC_setSession will
         copy them into a buffer of its own again.*/
      uint8_t appskey[sizeof(APPSKEY)];
      uint8_t nwkskey[sizeof(NWKSKEY)];
      memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
      memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
      LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
      #else
      // If not running an AVR with PROGMEM, just use the arrays directly 
      LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
      #endif
      // Disable link check validation
      LMIC_setLinkCheckMode(0);
      // TTN uses SF9 for its RX2 window.
      LMIC.dn2Dr = DR_SF9;
      // Set data rate and transmit power (note: txpow seems to be ignored by the library)
      LMIC_setDrTxpow(DR_SF7,14);
      // Start job
      do_send(&sendjob);
  }
void GPSRead()
{
  unsigned long age;
  gps.f_get_position(&flat, &flon, &age);
  falt=gps.f_altitude();  //get altitude    
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;   
  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places 
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
}
void GPSWrite()
{
  /*Convert GPS data to format*/
  datastring1 +=dtostrf(flat, 0, 4, gps_lat);   
  datastring2 +=dtostrf(flon, 0, 4, gps_lon);
  //datastring3 +=dtostrf(falt, 0, 2, gps_alt);
    if(flon!=1000.000000)
    {  
    strcat(gps_lon,",");
    strcat(gps_lon,gps_lat); 
    //strcat(gps_lon,","); 
    //strcat(gps_lon,gps_alt);
      int i = 0;
    for(i = 0; i < 2; i++)
    {
        //datasend.toFloat();
        atof(gps_lon);
       //Serial.println((char*)datasend);
      Serial.println("Testing converted data:");
      Serial.println(gps_lon);
      // atof(gps_alt);
      // Serial.print(gps_alt);
    }
    strcpy(datasend,gps_lon); //the format of datasend is longtitude,latitude,altitude
    Serial.print("###########    ");
    Serial.print("NO.");
    Serial.print(count);
    Serial.println("    ###########");
    Serial.println("The longtitude and latitude are:");
    Serial.print("[");
    Serial.print((char*)datasend);
    Serial.print("]");
    Serial.print("");
    /*
    for(int k = 0; k < 20;k++)
    {
    Serial.print("[");
    Serial.print(datasend[k], HEX);
    Serial.print("]");
    }
    Serial.println("");
    Serial.println("");*/
    count++;
    }
    int32_t lng = flat * 10000;
    int32_t lat = flon * 10000;
    datasend[0] = lat;
    datasend[1] = lat >> 8;
    datasend[2] = lat >> 16;
    datasend[3] = lng;
    datasend[4] = lng >> 8;
    datasend[5] = lng >> 16;
    smartdelay(1000);
  }
static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
    {
      gps.encode(ss.read());
    }
  } while (millis() - start < ms);
}
void loop() {
    os_runloop_once();
}

EDIT

Thank you to everyone who replied to this post! We now have a proper survey with these questions and a few more. If you'd like to provide feedback, please complete the survey at the following link:

https://www.surveymonkey.com/r/GPJTV6C

---

Original Post

I'm a member of the ThingSpeak team. I'd like to learn more about how the ThingSpeak community accesses channel data. Your feedback can help us make ThingSpeak better!

(A) Which of these statements best describes when the data you are interested in typically occurs?

  1. the last X hours / minutes / seconds
  2. a specific time window, e.g. "Monday, October 4th, 2021 9:00AM to 10:00PM"
  3. the last N feeds
  4. all data in the channel

(B) What is a typical duration of time that you are interested in? (e.g. "3 hours", "a few minutes")

(C) How many data points do you typically expect to read?

In the past 2 months, we had a lot of fun together playing in the two contests. To make future contests better and more appealing to you, we created a 1-minute survey to understand your experience.

Your feedback is critical to us. Thank you in advance and hope to see you in 2022!

Hello everyone! i want to send current sensor data using Arduino and nodeMCU to thingspeak. is there anyone who worked on something before. your responses will be highly appreciatable. thanks in advance

Hello,

I am sending mqtt values from esp8266 devices to different channels - e.g. https://thingspeak.com/channels/1182897

The values are sent correctly and also show up on the channel's page correctly and quickly in time.

But mqtt receivers are getting the data with a varying long delay. Often the delay is 1h, so I first thought, this could be a time zone problem. But that's not the case.

I tried two different mqtt clients: Both get the values at the same (late time): E.g. when I now get a value from channels/1182897/subscribe/fields/field3 and look into the history of values (using "Data Import/Export") then this value can be found 20 minutes up to 1 hour ago. This can also be confirmed when looking into the device's logs.

What could I do to be up-to-date with my values? Thank you very much. Dirk

After 7 weeks of fun, the MATLAB Central community 20th anniversary contests have concluded! Together, we shared the art of MATLAB and contributed to the battle against the global pandemic. See the fantastic stats below.

MATLAB Mini Hack Winners - Week 4

In Week 4, we invited the MATLAB Graphics team to help judge the entries. As the authors of the MATLAB functions used in every entry, they made sure every entry selected used a unique graphics function or technique from the other winners. Here are their choices:

1. Umbrellas by Shanshan Wang

Comment: Cool use of 'swarmchart' to make art from distributions; Only use of one of our newest graphics functions

2. Happy Sheep by Victoria

Comment: Cute!

3. Alien Giant by Jenny Bosten

Comment: Original idea, well textured, and efficient code

4. 3D Ultrasound by Adam Danz

Comment: Replicate source material very well. Effective use of lighting and material. Overall, impressive to produce this image given the limitation

5. Sunset in the Savanna by Sebastian Kraemer

Comment: Looks cool! Nice mix of 'image', 'fill' and 'scatter' commands.

6. Night Flight by Ratul Das

Comment: original; clever use of 'rectangle'

7. Lantern #2 by Tim

Comment: Nice use of 'getframe' to create a texture for 'surf' for a compelling picture

8. Geometric Design (6) by Daniel Pereira

Comment: Looks like some walls at MathWorks

9. Rosette 1313 by Alex P

Comment: Looks cool! Nice use of 'pcolor'

10. Mandelbrot contour by Sumihiro

Comment: Best use of contour!

11. Aim High by Murty PLN

Comment: Largest number of unique graphics objects for the Mini Hack (plot, patch,stairs,stem,text)

In the spirit of Mini Hack, the MATLAB Graphics team also created several cool graphs about the contest. Facing a similar space limit, I have picked only 2.

Bonus Prize Winners - Week 4

Congratulations to our 5 winners for their dual participation in the Treasure Hunt and the MATLAB Mini Hack. Yogiraj Bhagavatula, Pramod Devireddy, Devika U, FruitsLord, and Augusto Mazzei.

Lucky voters - Week 4

Congratulations to the lucky voters who cast the 12000th vote (Gordg Garin), 12500th vote (Eder Esteban Reyes), 13000th vote (Peram Balakrishna), 13500th vote (Emerson Nithiyaraj), 14000th vote(Sekar Naai), 14500th vote (Arika Amasarao), 15000th vote (Nikita Yakovlev), 15500th vote (Kesava Rao), and 16000th vote (Kundi Chandra Sekhar).

Grant Prize Winners

Finally, after validating entries and votes, we have picked the grand prize winners. We appreciate the time and effort you spent and the awesome entries you created. Huge congratulations!

1. Top 10 Authors of most voted entries

Each author will receive 5 customized T-shirts with the winning image and your name on the back of the T-shirts. You can choose the sizes and share them with your family or friends.

2. Top 10 Authors with most total votes

Top 10 contestants on the leaderboard will each get an Amazon gift card. The top 3 winners on the leaderboard will also earn special virtual badges.

  • Ciro Bermudez
  • KSSV
  • Juan Villacrés
  • Murty PLN
  • Pink_panther
  • Jenny Bosten
  • KARUPPASAMYPANDIYAN M
  • Jr
  • Adam Danz
  • Victoria

On behalf of the MATLAB Central community team, we thank you for joining our celebration of the MATLAB Central community’s 20th anniversary with us in the past 7 weeks. We hope you enjoyed these contests and look forward to seeing you in next year’s contests. Question: “What contests would you like to see next?”

I have a chart of data and need to eliminate the outliers which are making the chart look bad. Is there a configuration for this?

Hello, I try to publish to an already working channel. I have created an device and using the credentials shown in the image. I would like connect via TCP and port 1883 to mqtt3.thingspeak.com My Library always returns "Connection Refused - Bad Username or Password". This means it already has got a CONNACK reply. I have already successfully published an item to another server. So, the Lib basically works and I am using it correctly. I do not have mistyped the credentials. Could there be something on the Thingspeak side? Could you please help me with that? Thank you in advance.

VOTE on your favorite MATLAB images before Oct. 31 and win special edition T-shirts!

In just 2 weeks, 11,000 votes have been cast on 1200+ entries ! In the final week (Oct 25~Oct 31, 2021), we will add some fun and give out a T-shirt to lucky voters who cast:

  • The 12000th vote
  • The 12500th vote
  • The 13000th vote
  • The 13500th vote
  • The 14000th vote
  • The 14500th vote
  • The 15000th vote
  • The 15500th vote
  • The 16000th vote

Furthermore, for every vote an entry gets, MathWorks will donate $1 to Direct Relief (Maximum amount of $20 donated per entry; maximum of $20,000 in total).

Look at the entries , and if they make you smile, VOTE!

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

In Week 3, we passed several amazing milestones! 1,000 Participants in the Treasure Hunt , 1,000 ENTRIES and 10,000 votes in the MATLAB Mini Hack , and $10,000 charity donation from both contests! I recommend you read Ned Gulley’s recent blog post , which is a fantastic summary of the contest highlights.

During the last week of this contest, we strongly encourage you to inspire your colleagues, classmates, or friends to participate by either VOTING or CREATING entries. To add some fun, we will give out a T-shirt to LUCKY voters who cast:

  • The 12000th vote
  • The 12500th vote
  • The 13000th vote
  • The 13500th vote
  • The 14000th vote
  • The 14500th vote
  • The 15000th vote
  • The 15500th vote
  • The 16000th vote

MATLAB Mini Hack Winners - Week 3

We’ve received many creative entries for our new categories. Congratulations to the winners! Each of you won a special edition T-shirt:

Greg, entry: better Christmas tree , category: Holidays

Ratul Das, entry: To All Pepperoni Lovers , category: Food

Peter Stampfli, entry: Louis V , category: Fractals

Adrien Leygue, entry: Stained Glass membrane , category: MathWorks Logo

Spencer Miesner, entry: ~Breathe~ , category: Album Cover

Stewart Thomas, entry: The only QR code you ever need , category: Black & White

Sebastian Kraemer, entry: sun , category: 3D

Jenny Bosten, entry: The joys of spring , category: Plant

Adam Danz, entry: MATropolis rooftop view , category: Illustration

Eric Ogier, entry: UFO , category: Fun

Simon Thor, entry: Mandelbrot in 52 characters , category: Concise

Tim, entry: Low Tide , category: Realism

Bonus Prize Winners - Week 3

We are giving out additional giveaways to participants of both the Treasure Hunt and the MATLAB Mini Hack . Congratulations to our 5 winners. Each of you has also won a special edition T-shirt.

  • Teodo
  • Dyuman Joshi
  • Shanshan Wang
  • Nirvik Sinha
  • Felipe Torres

Week 4

After the contest ends, we need additional time to validate entries for Grand Prize and Weekly Prize. The winners are expected to be announced within a couple of days after the contest ends. Thank you in advance for your patience.