Main Content

Results for

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

many thanks

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.

Hi, currently I'm studying about DC-DC Boost converter with controller. After I applied the step time, the output voltage supposed to follow the step time, but there is some delay in the simulation results after I applied the "step time" in the step input block. Can someone help, why this delay occur? Please see the attached pictures. Thanks

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.

For UC3843A you will have to refer to the data sheet, link given below: https://www.ti.com/lit/ds/symlink/uc3843a.pdf?ts=1637624394197&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FUC3843A

For UC3843A, the reference output voltage is 5 V and the normal output voltage is 13.5 V.

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?

After repairing the power supply of a big water buffalo PC150NCA, now all the parts found to be broken are replaced, but the power-on output 12V is only 4.2V. The original power supply block is UC3843B, which is not sold locally. I can only buy a UC3843A replacement . I don’t know if the low output voltage has anything to do with this (the optocoupler and the 431 voltage regulator block have also been replaced)

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
}

Attention all Controls Professors, Teaching Assistants, and Students!

The Virtual Hardware and Labs for Controls by Brian Hong is an absolute must-have from the MATLAB Central File Exchange. With the help of Simscape for physical modelling and simulation of mechatronic systems,

  • students can use the interactive experiments to teach themselves some of the concepts of control theory in a learn by doing approach.
  • professors and TA’s can use this to replace or augment actual lab work.

With tightening budgets and/or in person class restrictions this can help you transfer these vital skills to the students in a fun manner. Here is an overview of the available modules:

https://www.mathworks.com/matlabcentral/fileexchange/100064-virtual-hardware-and-labs-for-controls

If you have any questions feel free to leave a comment below and I’ll get back to you.

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 DLC, in case you haven't seen it already, Dr. Dennis Dahlquist and Dr. Zekeriya Aliyazicioglu recently developed a collection of Virtual Labs in Electric Circuits . Please feel free to explore and share your thoughts!

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?

Rose Li
Rose Li
Last activity on 11 Nov 2021

With the switching power supply made by VIPER22A scheme , the 5V output always has noise, and the ripple exceeds 200MV after loading. How to change it? 1. 220VAC input, two outputs, 24V and 5V output are noisy, the ripple after 5V load is more than 200MV, 5V is connected with an LDO to 3.3V, and the measured 3.3V is also noisy, and the LDO heats up seriously. Change The LDO remains unchanged. 2. It is suspected that the load current is large, but I changed a circuit board with the same scheme and found that there is no noise. Although there are ripples, it is not very hot. 3. In addition, directly use a 5V adapter to convert to 3.3V through the same LDO. problem. How to change the device in this figure? 4. For hardware novices, the transformer will not be changed temporarily, and I hope to improve it by adjusting other devices.

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

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.