Results for
I have android 2.4 and 4.4 mobile device. I tried yesterday night, they are good working. Send data to my chanels and receive data good working. Same program android 6.0 good working yesterday night and tonight. But tonight, android 2.4 and 4.4 mobile device give 1101 error.
COMO FACO PARA COLOCAR EM TEMPO REAL VIA CODIGO AT + CLBS a localizacao, alguem pode me ajudar ????
we are doing a project on health monitoring system. We have made all the required changes in the code but our data is not being uploaded in thingspeak.It would be of great help if you can suggest some way.
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <SoftwareSerial.h>
float pulse = 0;
float temp = 0;
SoftwareSerial ser(9,10);
String apiKey = "xxxxxxxxxxxxxxxx"; // Variables
int pulsePin = A0; // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 7 ; // pin to blink led at each beat
int fadePin = 13; // pin to do fancy classy fading blink at each beat
int fadeRate = 0; // used to fade LED on with PWM on fadePin// Volatile Variables, used in the interrupt service routine!
volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when nota "live beat".
volatile boolean QS = false; // becomes true when Arduoino finds a beat. // Regards Serial OutPut -- Set This Up to your needs
static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse
volatile int rate[10]; // array to hold last ten IBI values
volatile unsigned long sampleCounter = 0; // used to determine pulse timing
volatile unsigned long lastBeatTime = 0; // used to find IBI
volatile int P = 512; // used to find peak in pulse wave, seeded
volatile int T = 512; // used to find trough in pulse wave, seeded
volatile int thresh = 525; // used to find instant moment of heart beat, seeded
volatile int amp = 100; // used to hold amplitude of pulse waveform, seeded
volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM
volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable BPM void setup()
{
lcd.begin(16, 2);
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!
Serial.begin(115200); // we agree to talk fast!
interruptSetup(); // sets up to read Pulse Sensor signal every 2mS// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
// analogReference(EXTERNAL);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Patient Health");
lcd.setCursor(0,1);
lcd.print(" Monitoring ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Initializing....");
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Getting Data....");
ser.begin(9600);
ser.println("AT");
delay(1000);
ser.println("AT+GMR");
delay(1000);
ser.println("AT+CWMODE=3");
delay(1000);
ser.println("AT+RST");
delay(5000);
ser.println("AT+CIPMUX=1");
delay(1000); String cmd="AT+CWJAP=\"Harshini Arulkumaran\",\"prythian\"";
ser.println(cmd);
delay(1000);
ser.println("AT+CIFSR");
delay(1000);
} // Where the Magic Happens
void loop()
{
serialOutput();
if (QS == true) // A Heartbeat Was Found
{ // BPM and IBI have been Determined
// Quantified Self "QS" true when arduino finds a heartbeat
fadeRate = 255; // Makes the LED Fade Effect Happen, Set 'fadeRate' Variable to 255 to fade LED with pulse
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
QS = false; // reset the Quantified Self flag for next time
}
ledFadeToBeat(); // Makes the LED Fade Effect Happen
delay(20); // take a break
read_temp();
esp_8266();
}
void ledFadeToBeat()
{
fadeRate -= 15; // set LED fade value
fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!
analogWrite(fadePin,fadeRate); // fade LED
}
void interruptSetup()
{
// Initializes Timer2 to throw an interrupt every 2mS.
TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER
OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED
}
void serialOutput()
{ // Decide How To Output Serial.
if (serialVisual == true)
{
arduinoSerialMonitorVisual('-', Signal); // goes to function that makes Serial Monitor Visualizer
}
else
{
sendDataToSerial('S', Signal); // goes to sendDataToSerial function
}
}
void serialOutputWhenBeatHappens()
{
if (serialVisual == true) // Code to Make the Serial Monitor Visualizer Work
{
Serial.print("Heart-Beat Detected"); //ASCII Art Madness
Serial.print("BPM: ");
Serial.println(BPM);
}
else
{
sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
sendDataToSerial('Q',IBI); // send time between beats with a 'Q' prefix
}
}
void arduinoSerialMonitorVisual(char symbol, int data )
{
const int sensorMin = 0; // sensor minimum, discovered through experiment
const int sensorMax = 1024; // sensor maximum, discovered through experiment
int sensorReading = data; // map the sensor range to a range of 12 options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 11);
// do something different depending on the
// range value:
switch (range)
{
case 0:
Serial.println(""); /////ASCII Art Madness
break;
case 1:
Serial.println("---");
break;
case 2:
Serial.println("------");
break;
case 3:
Serial.println("---------");
break;
case 4:
Serial.println("------------");
break;
case 5:
Serial.println("--------------|-");
break;
case 6:
Serial.println("--------------|---");
break;
case 7:
Serial.println("--------------|-------");
break;
case 8:
Serial.println("--------------|----------");
break;
case 9:
Serial.println("--------------|----------------");
break;
case 10:
Serial.println("--------------|-------------------");
break;
case 11:
Serial.println("--------------|-----------------------");
break;
}
} void sendDataToSerial(char symbol, int data )
{
Serial.print(symbol);
Serial.println(data);
}
ISR(TIMER2_COMPA_vect) //triggered when Timer2 counts to 124
{
cli(); // disable interrupts while we do this
Signal = analogRead(pulsePin); // read the Pulse Sensor
sampleCounter += 2; // keep track of the time in mS with this variable
int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise
// find the peak and trough of the pulse wave if(Signal < thresh && N > (IBI/5)*3) // avoid dichrotic noise by waiting 3/5 of last IBI
{
if (Signal < T) // T is the trough
{
T = Signal; // keep track of lowest point in pulse wave
}
}
if(Signal > thresh && Signal > P)
{ // thresh condition helps avoid noise
P = Signal; // P is the peak
} // keep track of highest point in pulse wave
// NOW IT'S TIME TO LOOK FOR THE HEART BEAT
// signal surges up in value every time there is a pulse
if (N > 250)
{ // avoid high frequency noise
if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) )
{
Pulse = true; // set the Pulse flag when we think there is a pulse
digitalWrite(blinkPin,HIGH); // turn on pin 13 LED
IBI = sampleCounter - lastBeatTime; // measure time between beats in mS
lastBeatTime = sampleCounter; // keep track of time for next pulse if(secondBeat)
{ // if this is the second beat, if secondBeat == TRUE
secondBeat = false; // clear secondBeat flag
for(int i=0; i<=9; i++) // seed the running total to get a realisitic BPM at startup
{
rate[i] = IBI;
}
}
if(firstBeat) // if it's the first time we found a beat, if firstBeat == TRUE
{
firstBeat = false; // clear firstBeat flag
secondBeat = true; // set the second beat flag
sei(); // enable interrupts again
return; // IBI value is unreliable so discard it
}
// keep a running total of the last 10 IBI values
word runningTotal = 0; // clear the runningTotal variable
for(int i=0; i<=8; i++)
{ // shift data in the rate array
rate[i] = rate[i+1]; // and drop the oldest IBI value
runningTotal += rate[i]; // add up the 9 oldest IBI values
}
rate[9] = IBI; // add the latest IBI to the rate array
runningTotal += rate[9]; // add the latest IBI to runningTotal
runningTotal /= 10; // average the last 10 IBI values
BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM!
QS = true; // set Quantified Self flag
// QS FLAG IS NOT CLEARED INSIDE THIS ISR
pulse = BPM;
}
}
if (Signal < thresh && Pulse == true)
{ // when the values are going down, the beat is over
digitalWrite(blinkPin,LOW); // turn off pin 13 LED
Pulse = false; // reset the Pulse flag so we can do it again
amp = P - T; // get amplitude of the pulse wave
thresh = amp/2 + T; // set thresh at 50% of the amplitude
P = thresh; // reset these for next time
T = thresh;
}
if (N > 2500)
{ // if 2.5 seconds go by without a beat
thresh = 512; // set thresh default
P = 512; // set P default
T = 512; // set T default
lastBeatTime = sampleCounter; // bring the lastBeatTime up to date
firstBeat = true; // set these to avoid noise
secondBeat = false; // when we get the heartbeat back
}
sei(); // enable interrupts when youre done!
}// end isr
void esp_8266()
{
// TCP connection AT+CIPSTART=4,"TCP","184.106.153.149",80
String cmd = "AT+CIPSTART=4,\"TCP\",\"";
cmd += "192.168.137.1"; // api.thingspeak.com
cmd += "\",80";
ser.println(cmd);
Serial.println(cmd);
if(ser.find("Error"))
{
Serial.println("AT+CIPSTART error");
return;
}
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr +="&field1=";
getStr +=String(temp);
getStr +="&field2=";
getStr +=String(pulse);
getStr += "\r\n\r\n";
// send data length
cmd = "AT+CIPSEND=4,";
cmd += String(getStr.length());
ser.println(cmd);
Serial.println(cmd);
delay(1000);
ser.print(getStr);
Serial.println(getStr); //thingspeak needs 15 sec delay between updates
delay(3000);
}
void read_temp()
{
int temp_val = analogRead(A1);
float mv = (temp_val/1024.0)*5000;
float cel = mv/10;
temp = (cel*9)/5 + 32;
Serial.print("Temperature:");
Serial.println(temp);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BPM :");
lcd.setCursor(7,0);
lcd.print(BPM);
lcd.setCursor(0,1);
lcd.print("Temp.:");
lcd.setCursor(7,1);
lcd.print(temp);
lcd.setCursor(13,1);
lcd.print("F");
}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
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?
- the last X hours / minutes / seconds
- a specific time window, e.g. "Monday, October 4th, 2021 9:00AM to 10:00PM"
- the last N feeds
- 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.
- 1,700 entries created and 24,000 votes cast in MATLAB Mini Hack
- 6,300 tasks completed in Treasure Hunt
- $17,000 raised for Direct Relief
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.
- Ciro Bermudez
- Jenny Bosten
- Adam Danz
- Jr
- Maximilian Schönau
- KSSV
- Dr Raveendranathan K C
- taoizm
- Sebastian Kraemer
- Victoria
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.
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