Quantcast
Channel: ThingSpeak IoT Community - Forum: Arduino
Viewing all 172 articles
Browse latest View live

cstapels on Dragino-KPN-ThingSpeak

$
0
0

Your call to ThingSpeak.begin(); does not have a client.  See the examples in the Arduino IDE when you install the thingSpeak library.  For example the "writeMultipleVoltages.ino".  Generally the client that connects to the wifi or ethernet is passed to the ThingSpeak object.


dtecres on Arduino Uno R3+W5100+LM35, Temperature not display in Thingspeak...

$
0
0

Hi cstapels,

I was able to update as method provided.

Tonibco6 on Dragino-KPN-ThingSpeak

$
0
0

I am aware about it, so I deleted it, because it was providing me an error. So, I was wondering if the client parameter was coming from the client.ino. However, I am not using a client sketch to combine with the server, I meant, I am just using an entire code to send everything. 

Tonibco6 on Dragino-KPN-ThingSpeak

cstapels on Dragino-KPN-ThingSpeak

$
0
0

Perhaps you can try removing some libraries.  You could temporarily remove the dht library and just send dummy data to thingspeak to prove the concept.  Then you could focus on reducing the size once that is working.

Another thing I saw in one of the thingSpeak library examples for use with Yun was 

Bridge.begin();  

before the ThingSpeak.begin(client).  and I see that the yun client is depreciated.

dtecres on Arduino Uno R3+W5100+LM35, Temperature not display in Thingspeak...

$
0
0

Hi cstapels,

I've found the cause of the data not able to update to Thingspeak. This is due to model DNS is not set to open DNS, after set to open DNS it works fine now.

However, it turned to not working back when I had added send email function when temperature over the threshold. I can't figure what went wrong and the response number returned after pushed the data to Thingspeak same as before added the send email function. 

Please help...

Thanks.

Best Regards,

Kinble Gray

 

#include <SPI.h>
#include <Ethernet.h>
#include <utility/w5100.h>
#include "ThingSpeak.h"

// W5100 Network Setup
byte W5100_MacAddress[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
const IPAddress No_Connet_IP = IPAddress(0, 0, 0, 0);

//Thingspeak Setup
unsigned long Channel_Number = 302633; // Channel ID
const char * Write_API_Key = "VAMPTX0YTHJ17WJ5"; // Write API Key
int Channel_Field = 1; // Field where Temperature data upload to

// LM35 sensor input to analog
#define LM35_Temp_Sensor A0

// SMTP2GO eMail Setup
char smtp_server[] = "smtpcorp.com";
int smtp_port = 2525;

EthernetClient client;

float LM35_Temp_Value = 0; // Initial Temperature value
float Preset_Temp_Value = 37.00; // Preset Temperature
int Interval = 300; // Interval read the temperature every 5 mins

void setup()
{
Serial.begin(9600);
delay(200);
while (!Serial)
{
delay(200);
}
Serial.println("Arduino Uno R3 was detected...");

// Disable SD Card SPI
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);

Ethernet.begin(W5100_MacAddress);
byte MACvalue[6];

// Detecting W5100 Ethernet Shield present
W5100.getMACAddress(MACvalue);
for (byte i = 0; i < 6; i++)
{
if (MACvalue[i] != W5100_MacAddress[i])
{
Serial.println(F("W5100 ethernet shield is not detected!!!"));
while (true)
{
// Waiting user to restart the module...
}
}
}
Serial.println();
Serial.println(F("W5100 ethernet shield was detected..."));

// Check the W5100 Ethernet Connection to DHCP server
IPAddress W5100_IPAddress = Ethernet.localIP();
if (W5100_IPAddress[0] == No_Connet_IP[0] || W5100_IPAddress[1] == No_Connet_IP[1] || W5100_IPAddress[2] == No_Connet_IP[2] || W5100_IPAddress[3] == No_Connet_IP[3])
{
Serial.println(F("W5100 failed to connect to DHCP server!!!"));
while (true)
{
// Waiting user to restart the module...
}
}
else
{
Serial.println();
Serial.println(F("W5100 is connect to DHCP server..."));
Serial.println();
Serial.print("W5100 IP Address: ");
Serial.println(Ethernet.localIP());
Serial.print("W5100 Subnet Mask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("W5100 Gateway: ");
Serial.println(Ethernet.gatewayIP());
Serial.println();
}

// Connect to Thingspeak server
if (ThingSpeak.begin(client))
{
Serial.println("Connect to Thingspeak Server!!!");
Serial.println();
}
else
{
Serial.println("Failed to connect to Thingspeak Server!!!");
Serial.println();
}
}

void loop()
{
LM35_Temp_Value = analogRead(LM35_Temp_Sensor)* 0.0048828125 * 100;
Serial.print("Current temperature: ");
Serial.print(LM35_Temp_Value);
Serial.println("°C");
delay(100);

// Write the temperature to Thingspeak Server
int response = ThingSpeak.writeField(Channel_Number, Channel_Field, LM35_Temp_Value, Write_API_Key);
Serial.println("Response from server: "+ String(response));
if(response >=0)
{
Serial.println();
Serial.println("Uploading data to Thingspeak Server...");
Serial.println();
}
else
{
Serial.println();
Serial.println("Failed to upload data to Thingspeak Server!!!");
Serial.println();
}
client.stop();

// Send alert email in temperature over the threshold
if (LM35_Temp_Value >= Preset_Temp_Value)
{
Serial.println("Temperature over threshold!!!");
Serial.println("Sending over temperature alert email...");
delay(100);
if(sendEmail())
{
Serial.println(F("Over temperature alert email sent successfully..."));
}
else
{
Serial.println(F("Over temperature alert email sent failed!!!"));
}
}

// The temperature will read every 5 mins
for (int i=0; i <= Interval; i++)
{
delay(1000); // 1 second delay
}

}

byte sendEmail()
{
byte thisByte = 0;
byte respCode;

Serial.println(F("Connecting to SMTP Server..."));
if(client.connect(smtp_server,smtp_port) == 1)
{
Serial.println(F("W5100 is connect to SMTP Server..."));
}
else
{
Serial.println(F("W5100 failed to connect to SMTP Server!!!"));
return 0;
}
if(!eRcv()) return 0;

Serial.println(F("Sending hello..."));
// Replace 1.2.3.4 with your Arduino's ip
//client.println("EHLO 1.2.3.4");
client.println("EHLO W5100_IPAddress");
if(!eRcv()) return 0;

Serial.println(F("Sending auth login..."));
client.println("auth login");
if(!eRcv()) return 0;

Serial.println(F("Sending UserID..."));
// Change to your base64 encoded user
client.println("User ID");
if(!eRcv()) return 0;

Serial.println(F("Sending Password..."));
// change to your base64 encoded password
client.println("Password");
if(!eRcv()) return 0;

// change to your email address (sender)
Serial.println(F("Sending From..."));
client.println("MAIL From: <ektan@unigen.com>");
if(!eRcv()) return 0;

// change to recipient address
Serial.println(F("Sending To..."));
client.println("RCPT To: <ektan@unigen.com>");
if(!eRcv()) return 0;

Serial.println(F("Sending DATA..."));
client.println("DATA");
if(!eRcv()) return 0;

Serial.println(F("Sending email..."));

// change to recipient address
client.println("To: EK Tan <ektan@unigen.com>");

// change to your address
client.println("From: Eekhay Tan <ektan@unigen.com>");
client.println("Subject: Over Temperature Email Alert!!!
");
client.print("Temperature: ");
client.print(LM35_Temp_Value);
client.println("°C");
client.println("Current temperature is over the threshold!!!");
client.println("Please take immediate action now!!!");
client.println(".");
if(!eRcv()) return 0;

Serial.println(F("Sending QUIT..."));
client.println("QUIT");
if(!eRcv()) return 0;

client.stop();

Serial.println(F("SMTP Server is disconnected..."));

return 1;
}

byte eRcv()
{
byte respCode;
byte thisByte;
int loopCount = 0;

while(!client.available()) {
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
client.stop();
Serial.println(F("
eRcv Timeout!!!"));
return 0;
}
}

respCode = client.peek();
while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

if(respCode >= '4')
{
efail();
return 0;
}

return 1;
}

void efail()
{
byte thisByte = 0;
int loopCount = 0;

client.println(F("QUIT"));

while(!client.available())
{
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000)
{
client.stop();
Serial.println(F("
eFail Timeout!!!"));
return;
}
}

while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

client.stop();

Serial.println(F("SMTP Server is disconnected..."));
}

cstapels on Arduino Uno R3+W5100+LM35, Temperature not display in Thingspeak...

$
0
0

Consider using ThingTweet and a react to generate a tweet when your channel value reaches a particular value.

cstapels on Cant send Unsigned long values from arduino to ThingSpeak

$
0
0

Can you post the line where you use writeFields?  Possibly you are using the wrong number of arguments or one of the other variables is the wrong type.


Tonibco6 on Dragino-KPN-ThingSpeak

$
0
0

Is ThingSpeak reading either 'int' or 'float' values? I have just contacted KPN and I provided them my Write Key link in order to send my sensor value data to my channel, but it seems that there is something wrong once they provide the data to ThingSpeak.

I am sending format values as 25.00

Would that value be Ok in order to show it on my channel graphic? 

Thanks

cstapels on Dragino-KPN-ThingSpeak

Tonibco6 on Dragino-KPN-ThingSpeak

$
0
0
It seems that I managed to send "something" to ThingSpeak dashboard throughout KPN network (not Gateway). However, it is only sending a '0' value... I removed the ThingSpeak(client) function as I am not using any client scketch. I have got a warning even when I comment dht library and sending just a static number: "Low memory available, stability problems may occur." 
Code: link

 
Any code modification suggested?
(The code above is working properly when I send sensor data to KPN, I have just added some lines in order to transfer this data to ThingSpeak, which are the ones I would like to get some advise)
 
You can also see on the following link the steady temperature value '0' I have got into  my ThingSpeak channel: link

Many thanks

Studvio on Channel update

$
0
0

Hi all, I'm new around here, and I am a free user (i.e. 15 secs. delay between updates)

According to https://thingspeak.com/pages/license_faq,

"A message is defined as a write of up to 8 fields of data to a ThingSpeak channel"

However, using the following Arduino lines of code

ThingSpeak.begin(ThingSpeakClient);
ThingSpeak.writeField(myChannelNumber, 2, 0, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber, 4, 0, myWriteAPIKey);
ThingSpeakClient.stop();

will only result in updating of field 2 only, and not field 4 as well.

Adding a 15 secs. delay between line 2 and 3 in the code above (delay(15000);) will result in both fields being updated when I run the code.

Could anyone shed some light into this matter please? Thank you.

ThingSpeak.begin(ThingSpeakClient);
ThingSpeak.setField(2, 0);
ThingSpeak.setField(4, 0);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
ThingSpeakClient.stop();

 

Later edit: Solved, thanks!Laugh

Angmo on Is Thingspeak tracking the device IP address?

$
0
0

I created 3 thingspeak account for my project. 3Arduino was used to collect the data and the data collected was sent to arduino D. Each arduino was assigned to different thingspeak account. The program at arduino D will differentiate the data is from which arduino and then upload to the respective thingspeak account every 15second. However, i realized something strange. After arduino A upload to the respective thingspeak account, within the 15second interval that is limit by the free thingspeak account, no data is uploaded by arduino b and arduino c. Because i used the same arduino ( arduino D) to upload the data so i doubt that is thingspeak tracking the IP address of the device that used to upload to thingspeak and set a limit of 15second interval? 

Hans on Is Thingspeak tracking the device IP address?

$
0
0

The situation that you are describing should work properly. Check to make sure that the Write API Key is unique for each device. You can also accomplish the same goal with one account and three channels.

Vinod on Is Thingspeak tracking the device IP address?


gkaplan on thingspeak ThingSpeak.readIntField(,,) on arduino with esp8266 unstable

$
0
0

Hi Oded !

I also have some problems with Arduino Uno and WifiEsp and Thingspeak libraries.

Did you solve your problem? Or any workaround.

Thanks for help.

Best regards.

Tonibco6 on Wrong Value ThingSpeak

$
0
0

I am sending sensor data from the LoRa module (Sodaq ONE) throughtout KPN network. I would like to be able to see this sensor data monitorised within "ThingSpeak", but a '0' value is received constantly. I am not sure whether it happens because the payload is sent in HEX code rather than ASCII...? If so, how can I convert it?

#include "Arduino.h" #include &lt;Sodaq_RN2483.h&gt; #include "DHT.h" #define DHTPIN 2 // Pin connect sensor #define DHTTYPE DHT11 // Define sensor we are using DHT dht(DHTPIN,DHTTYPE); // Initialize the device #define debugSerial SERIAL_PORT_MONITOR #if defined(ARDUINO_AVR_SODAQ_MBILI) #define loraSerial Serial1 #define BEE_VCC 20 #elif defined(ARDUINO_SODAQ_AUTONOMO) || defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) #define loraSerial Serial1 #elif defined(ARDUINO_SODAQ_EXPLORER) #define loraSerial Serial2 #else // please select a sodaq board debugSerial.println("Please select a sodaq board!!"); #endif // ABP const uint8_t devAddr[4] = { }; const uint8_t appSKey[16] = { }; const uint8_t nwkSKey[16] = { }; // OTAA uint8_t DevEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t AppEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t AppKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; void setupLoRaABP(){ if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, false)) { debugSerial.println("Communication to LoRaBEE successful."); } else { debugSerial.println("Communication to LoRaBEE failed!"); } } void setupLoRaOTAA(){ if (LoRaBee.initOTA(loraSerial, DevEUI, AppEUI, AppKey, false)) { debugSerial.println("Communication to LoRaBEE successful."); } else { debugSerial.println("OTAA Setup failed!"); } } void setup() { //Power up the LoRaBEE #if defined(ARDUINO_AVR_SODAQ_MBILI) || defined(ARDUINO_SODAQ_AUTONOMO) pinMode(BEE_VCC, OUTPUT); digitalWrite(BEE_VCC, HIGH); #endif delay(3000); while ((!SerialUSB) &amp;&amp; (millis() &lt; 10000)){ // Wait 10 seconds for the Serial Monitor } //Set baud rate debugSerial.begin(57600); loraSerial.begin(LoRaBee.getDefaultBaudRate()); // Debug output from LoRaBee // LoRaBee.setDiag(debugSerial); // optional //connect to the LoRa Network setupLoRa(); } void setupLoRa(){ // ABP setupLoRaABP(); // OTAA // setupLoRaOTAA(); LoRaBee.setSpreadingFactor(9); dht.begin(); //start the device } void sendPacket(String packet){ switch (LoRaBee.send(1, (uint8_t*)packet.c_str(), packet.length())) { case NoError: debugSerial.println("Successful transmission."); break; case NoResponse: debugSerial.println("There was no response from the device."); setupLoRa(); break; case Timeout: debugSerial.println("Connection timed-out. Check your serial connection to the device! Sleeping for 20sec."); delay(20000); break; case PayloadSizeError: debugSerial.println("The size of the payload is greater than allowed. Transmission failed!"); break; case InternalError: debugSerial.println("Oh No! This shouldn't happen. Something is really wrong! Try restarting the device! The network connection will reset."); setupLoRa(); break; case Busy: debugSerial.println("The device is busy. Sleeping for 10 extra seconds."); delay(10000); break; case NetworkFatalError: debugSerial.println("There is a non-recoverable error with the network connection. You should re-connect. The network connection will reset."); setupLoRa(); break; case NotConnected: debugSerial.println("The device is not connected to the network. Please connect to the network before attempting to send data. The network connection will reset."); setupLoRa(); break; case NoAcknowledgment: debugSerial.println("There was no acknowledgment sent back!"); // When you this message you are probaly out of range of the network. break; default: break; } } void loop() { //HumidityDHT1, TempDHT11 String packet = String(dht.readHumidity()) + ", "; packet += String(dht.readTemperature()); debugSerial.println(packet); sendPacket(packet); delay(5000); }

 

https://thingspeak.com/channels/266512

Any suggestion,please?

Many Thanks!

cstapels on Wrong Value ThingSpeak

$
0
0

ThingSpeak will accept Hex values as well as ASCII.  Depending on how they are formatted, it may interpret the hex values as strings.  For example, Cheerlights (channel 1417) contains the string from the color name and the hex code in separate fields. I couldn't find information about Lorabee.send() function in a quick google search so I don't know how it works.  I assume it must have the api key correct if you are getting posts to your channel, even if they are zero.

 Perhaps you aren't sending valid field information ('field1=')?  See the documentation on Update a channel feed to make sure your format is correct.  

Also you should try using your browser or POSTMAN to update your channel.  This will help you ensure the format is correct for the request.  You can use the format shown on the API keys page on the right:

GET https://api.thingspeak.com/update?api_key=WRITE_API_KEY&field1=#xxxx  (dont use the GET if you paste it into your browser window)

Tonibco6 on Wrong Value ThingSpeak

$
0
0

What do this 5 digits mean "#xxxx" on the browser address?

https://api.thingspeak.com/update?api_key=WRITE_API_KEY&field1=#xxxx

Since I have got a '0' value on my Write keys, so maybe it is the reason it is sending constantly '0' values to my channel.

https://api.thingspeak.com/update?api_key=WRITE_API_KEY&field1=0

If I am sending Humidity and Temperature values to different fields but same channel from a DHT_11 sensor, how can I manage to send it properly?
Field1 = Temperature 
Field 2 = Hmidity

Many thanks!

cstapels on Wrong Value ThingSpeak

Viewing all 172 articles
Browse latest View live