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

hickse on Not all DS18B20 sensors present on ThingSpeak

$
0
0

I got the WriteMultipleVoltages sketch to produce 8 fields so it has something to do with the digital reads..... Damn.  DS18B20's are more accurate than TMS36s.


rw950431 on Not all DS18B20 sensors present on ThingSpeak

$
0
0

Thats weird.. maybe its a memory corruption problem or something with the Thingspeak arduino client. Or maybe the total length of the data being sent exceeds some preset limit and gets chopped off.

Is it that it only sends field1 to field5 or will it work with, say, field3 to field8?

 

Unfortunately Thingspeak doesnt have a debug console so you can view.  You might try saving the return code from writeFields() and printing it out to see if you can spot a pattern

 

Otherwise you might be forced to hack into the source code. According to https://github.com/mathworks/thingspeak-arduino/blob/master/src/ThingSpeak.h if you locate the file ThingSpeak.h on your computer and add

#define PRINT_DEBUG_MESSAGES

Near the other define statements it might produce some helpful comments.

jpsabo on Arduino Mega with yun shield

$
0
0

I believe you just need to remove these:

  • #include
  • WiFi.begin(ssid, pass);

I use a Yun Shield on a Mega2560 as well. The Yun Shield connects to my local network and then sends results either to ThingSpeak.com or to a local install of ThingSpeak.

Also, did you put a jumper across the very first pair of pins (directly below from the mounting hole in the board on the top left side) for the ICSP for 16U2 USB interface when the Yun Shield is mounted to the Mega2560? That pair of pins need to be jumpered for the Yun Shield to work with the Mega2560. You will then compile your sketch and save the .hex file to disk, and then log into the Yun Shield and upload that .hex file from the directory where it was placed (same as the location of the .ino file). 2 versions of the .hex file will be created, 1 with a boot loader and 1 without. I use the one without the boot loader and it seems to work okay.

More details can be found here: http://wiki.dragino.com/index.php?title=Yun_Shield#Connect_to_Arduino_Mega2560

Arduino Mega250Image Enlarger

HydroponicsMAC on Multiple 1 Wire Bus on Digital Pin ....

$
0
0

Here's the code I'm using which is doing something similar.

#include "ThingSpeak.h"
unsigned long myChannelNumber = 123456789;
const char * myWriteAPIKey = "ABCDEFGHIJK";

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //DE:AD:BE:EF:FE:ED, Internal static IP is 192.168.0.52
EthernetClient client;

#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(3);
DallasTemperature OneWire_Sensors(&oneWire);

#include "DHT.h"
#define PLANT_DHTPIN 2
#define DHTTYPE DHT11
DHT Plant_dht(PLANT_DHTPIN, DHTTYPE);

#define RAIN_SENSOR_DIGITAL 4

float fltEnviromentTemp = 0, fltPlantTemp = 0, fltReservoirTemp = 0;
int i, intPlantHumidity = 0, intSensorAlarm = 0, intRainAlarm = 0;
boolean blnRainAlarmNotified = false;

void setup() {
Serial.begin(9600);

pinMode(RAIN_SENSOR_DIGITAL, INPUT);

Serial.println(F("v." __DATE__ ", " __TIME__ "
"));

Serial.print(F("Starting network"));
Ethernet.begin(mac);

Serial.print(F(", ThingSpeak"));
ThingSpeak.begin(client);

Serial.println(F(" and sensors."));
OneWire_Sensors.begin();
Plant_dht.begin();
}

void loop() {
Serial.println(F("
Reading sensors"));

// Rain sensor
if (!(digitalRead(RAIN_SENSOR_DIGITAL))) {
Serial.println(F("WARNING: Rain detected, ALARM activated"));
intRainAlarm = 1;
blnRainAlarmNotified = true;
} else {
intRainAlarm = 0;
blnRainAlarmNotified = false;
}

//Onewire sensors
OneWire_Sensors.requestTemperatures();
fltEnviromentTemp = OneWire_Sensors.getTempCByIndex(0);
fltPlantTemp = OneWire_Sensors.getTempCByIndex(1);
fltReservoirTemp = OneWire_Sensors.getTempCByIndex(2);

//DHT11 sensor
intPlantHumidity = Plant_dht.readHumidity();

Serial.print(F("Environment = "));
Serial.print(fltEnviromentTemp);
Serial.println(F("*C"));
Serial.print(F("Plant = "));
Serial.print(fltPlantTemp);
Serial.println(F("*C"));
Serial.print(F("PlantHumidity="));
Serial.print(intPlantHumidity);
Serial.println(F("%"));
Serial.print(F("Reservoir = "));
Serial.print(fltReservoirTemp);
Serial.println(F("*C"));
Serial.print(F("RainAlarm = "));
Serial.println(intRainAlarm);

if ((fltEnviromentTemp == -127.00) || (fltPlantTemp == -127.00) || (fltReservoirTemp == -127.00) || isnan(intPlantHumidity) || (intPlantHumidity == 0))
{
Serial.println(F("WARNING: Sensor problem, ALARM activated"));
intSensorAlarm = 1;
} else {
Serial.println(F("Sensors are OK"));
intSensorAlarm = 0;
}

ThingSpeak.setField(1, fltEnviromentTemp);
ThingSpeak.setField(2, fltPlantTemp);
ThingSpeak.setField(3, intPlantHumidity);
ThingSpeak.setField(4, fltReservoirTemp);
ThingSpeak.setField(5, intRainAlarm);
ThingSpeak.setField(6, intSensorAlarm);

Serial.println(F("Updating ThingSpeak"));

ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); // ThingSpeak only accept updates every 15 seconds

Serial.println(F("Finished updating"));

Serial.println(F("Sleeping for 15 minutes"));

for (i = 0; i < 45; i++) { //15 minutes = 45 * 20,000 = 900,000
delay(20000); //Wait 20 seconds
Serial.println(F("Checking for rain"));

if (!(digitalRead(RAIN_SENSOR_DIGITAL)))
{
Serial.println(F("WARNING: Rain detected, ALARM activated"));

if (blnRainAlarmNotified == false)
{
Serial.println(F("Updating ThingSpeak"));
ThingSpeak.writeField(myChannelNumber, 5, 1, myWriteAPIKey);
Serial.println(F("Finished updating"));

blnRainAlarmNotified = true;

} else {
Serial.println(F("Already updated ThingSpeak"));
}
}
}
}

Luis_Filipe on Arduino Mega with yun shield

$
0
0

OK, solve the issue, Thanks a lot!

ElsyKhong on Not all DS18B20 sensors present on ThingSpeak

$
0
0

Hi..i am a new user here. By profession i am a hardware design engineer. As per my knowledge you shouls try the setting DWHTempIn to a fixed value and testing if that updates correctly.  Are you sure you have enabled channels 4 and 5 on your thingspeak channel and that the value is within the range you set?Does it work if you disable the DHT11 and send only the DS1820 temps?

aelizondo on GSM Shield updates only once

$
0
0

Hi,

I am using an Arduino Mega and a GSM Shield (M10 modem) to send data to ThingSpeak. I found some examples that show how to send one or more parameters after a given time period that work well, as long as I don't modify the loop code.

If I add the examples code as part of a longer/bigger program the data is updated in Thingspeak ONLY the first time that the program runs.

Has anyone have such issues before? I can post the code I used to update ThinSpeak.

Thanks in advance!

pramod on GSM Shield updates only once

$
0
0

aelizondo said
Hi,

I am using an Arduino Mega and a GSM Shield (M10 modem) to send data to ThingSpeak. I found some examples that show how to send one or more parameters after a given time period that work well, as long as I don't modify the loop code.

If I add the examples code as part of a longer/bigger program the data is updated in Thingspeak ONLY the first time that the program runs.

Has anyone have such issues before? I can post the code I used to update ThinSpeak.

Thanks in advance!  

Yes I also have same problem. I was able to see it also on mobile app ThingView. Then suddenly it stopped I see entries and last update information but no data on field chart. I see the chart records when I first connected .I can see total 139 entries. now no updates


Vinod on GSM Shield updates only once

$
0
0

Can you test connectivity from your GSM shield? Are you sure the GSM shield is not going into some sort of hibernate mode? Before you send data to thingspeak, can you program your device to ping http://www.thingspeak.com or http://www.mathworks.com? 

To troubleshoot, It would help if you linked your sketch here.

pramod on GSM Shield updates only once

$
0
0

This is my code which is copied from " GSM-ParticulateSensor" example

void thingspeakPost() {

 
 
  char itoaBuffer[8];

  char end_c[2];
  end_c[0] = 0x1a;
  end_c[1] = '\0';

// PM25 int to char
  char data25[50];
  String str25;
  str25 = String(Pm25);
  str25.toCharArray(data25, 50);
 
// PM10 int to char  
  char data10[50];
  String str10;
  str10 = String(Pm10);
  str10.toCharArray(data10, 50);

if (inet.connectTCP(thingSpeakAddress, 80)) {

   Serial.println("connected to thingspeak");

   

    gsm.SimpleWrite("POST /update HTTP/1.1
");
   
    gsm.SimpleWrite("Host: api.thingspeak.com
");
    gsm.SimpleWrite("Connection: close
");
    gsm.SimpleWrite("X-THINGSPEAKAPIKEY:");
 
    gsm.SimpleWrite(writeAPIKey);
    gsm.SimpleWrite("
");
    gsm.SimpleWrite("Content-Type: application/x-www-form-urlencoded
");
    gsm.SimpleWrite("Content-Length: ");
   
   sprintf(sentMsg, "field1=%s", data25);
   itoa(strlen(sentMsg), itoaBuffer, 10);
 
    
    gsm.SimpleWrite(itoaBuffer);
    //inet.httpPOST("api.thingspeak.com", 80, "/update?key=B325M1U9WB2JGC9Z&field1= itoaBuffer");
  //gsm.SimpleWrite("PUT https://api.thingspeak.com/channels/137269/api_key=K9WNHI32J4346GL6");
   // gsm.SimpleWrite(" api_key=K9WNHI32J4346GL6");
   // gsm.SimpleWrite(" name=Updated Channel");
    
     //gsm.SimpleWrite(Pm25);
     gsm.SimpleWrite("

");

     gsm.SimpleWrite(sentMsg);

     gsm.SimpleWrite("

");

     gsm.SimpleWrite(end_c);
   delay(20000);
    Serial.println("update to thingspeak");

Vinod on GSM Shield updates only once

$
0
0

It appears that your code has some debugging statements it prints to the serial port. You should be able to program your arduino and monitor the output on the serial port to look at the messages are being printed. That will help you isolate the problem. Your starting point is to see what messages are being printed to the arduino serial monitor (Ctrl+Shift+M) in the Arduino IDE when your sketch is running. Try to write out some more messages using Serial.println() as debugging aids between the different steps. If your sketch is based on this one, are you seeing "failed" messages in your serial monitor? This would indicate that the connection is being dropped. etc.

Note that based on just this code snippet, depending on how often you call this function, you could be trying to post to http://www.thingspeak.com every 0.02 seconds. This is likely just wasting your GPRS data as the current data rate to http://www.thingspeak.com is one write per channel every 15 seconds.

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

$
0
0

hi all.

 

i try to read last values of 3 field set  of thhingspeak channel.

like that:-

after setting up client with these libraries

#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspServer.h>
#include <WiFiEspUdp.h>

#include <ThingSpeak.h> ////<<<<<<<<<<<<<<

etc.

etc.

 

void loop() {

int field1 = ThingSpeak.readIntField(141045,1);
Serial.println();
delay(1000);
Serial.print("field 1 is: ");
Serial.print(field1);
Serial.println();
int field2 = ThingSpeak.readIntField(141045,2);
Serial.println();
delay(10000);
Serial.print("field 2 is: ");
Serial.print(field2);
Serial.println();
int field3 = ThingSpeak.readIntField(141045,3);
Serial.println();
delay(10000);
Serial.print("field 3 is: ");
Serial.println(field3);
Serial.println();

delay(10000); // Note that the weather station only updates once a minute

;};

 

 

PROBLEM:

I set the data to be   600 , 600,600 

i get unstable readings (of same line wihch i try to read for testing purposes over the loop),

as follows  over the arduino  mega serial terminal 

 

field 1 is: 0
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600 

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 607
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

[WiFiEsp] Connecting to api.thingspeak.com

field 1 is: 600
[WiFiEsp] Connecting to api.thingspeak.com
[WiFiEsp] TIMEOUT: 605
[WiFiEsp] Disconnecting 0

field 2 is: 0
[WiFiEsp] Connecting to api.thingspeak.com

field 3 is: 600

 

 

any body can explain  whats wrong here ?

 

is it low memory of arduino as one suggested  somewhere  ?

 

wifi is strong , and all results come ok over http terminal .

 

thanks  

Oded,

aelizondo on GSM Shield updates only once

$
0
0

Hi,

Thanks for the recommendations and sorry about my delayed reply Vinod. I was using a different code than the one posted by pramod and I found the problem on mine. There were a couple of validations made every time the code ran, reading data from the website I was trying to connect to and then validating whether the client was still connected.

The example I used as a baseline made updates every 5 minutes and in my case I needed to send the udpates that were event triggered, so I got read of the two validations, forcing the client to connect when the event took place and diisconnect right after the update was made.

I hope this makes sense.

Alonso

ryinsf on ThingSpeak Communication Library for Arduino

$
0
0

Hi Rob - I'd like to use an Adafruit Feather M0 Wifi (ATSAMD21G18 like the Arduino Zero plus ATWINC) with ThingSpeak. The ThingSpeak Arduino Communcation Library refuses to compile because the Feather M0 is not in it's platform list. I have seen a couple of ThingSpeak users say they have the library working with this board, but have been unable to get more info from them. Can you shed some light on if this library will work with the Adafruit Feather M0 Wifi and if it will, how do you get the library to compile with that board?

Thanks for any help you can provide.

HydroponicsMAC on A couple of handy snippets of code for debugging

$
0
0

Hello All,

I thought I would share a couple of handy code fragments that I've been using while developing Arduino apps with ThingSpeak.

My use case is to have the Arduino out in the field running 24x7 which makes debugging difficult, so I have opted for a Raspberry Pi connected to the serial port (USB) of the Arduino to collect the serial output and debug what's going on.  My solutions means I can terminal into the PI from anywhere in the world and debug / reprogram it. 

So on to the handy Lunix command...connect the Arduio to the PI via a USB port then run the following command to capture its Serial.print output into a log-file on the PI with each entry prefixed with a datestamp:

cat /dev/ttyUSB0 | while IFS= read -r line; do echo "$(date) $line"; done >> logfile.txt 

//That's /dev/ttyUSB0 ZERO not oh

//Additionally - if you want this to run continually just like a service simple add a & symbol after ... $line"; done >> logfile.txt &

The second tip is to automatically reboot the Arduino should it stop running, again this is handy if your use case is in the field and you can't spend all day monitoring it.

As the Arduino is running you can call on its 'WatchDog' capability which as the name suggests monitors the Arduino and if it stops responding automatically reboots it.  Essentially what the below code does is turn on the WatchDog with wdt_enable(WDTO_8S); and tell it to wait 8 seconds before rebooting.

You now have 8 seconds to tell the WatchDog within your code that all is well and RESET the 8 second timer using wdt_reset();

If after 8 seconds you don't reset the timer the Arduino will automatically reboot.  For more information see this...

#include <avr/wdt.h>  // You can just add this line as the library is included with every Arduino IDE

void loop() {

       wdt_enable(WDTO_8S);  // Start the WatchDog

       // Do something which must finish before 8 seconds is up

      wdt_reset();   // Reset the timer, all is well

}

Happy codingSmile


rw950431 on A couple of handy snippets of code for debugging

$
0
0

Does your setup work properly if the power goes off and both the RPi and Arduino reboot?   I tried a similar setup a few years ago (see my stackexchange question) but found the arduino wasnt recognised after the RPi was power cycled.

That was using an original RPi, so perhaps the later models behave better.

HydroponicsMAC on A couple of handy snippets of code for debugging

$
0
0

I haven't experience the same non-recognition problem with the Raspberry Pi 3 and Arduino Mega that I'm using.  I'm powering the Arduino via a 9v power adaptor so its USB port is just used for serial output to the Pi.

At at guess when the power goes off/on the Arduino will be up and running before the Pi, then when Pi starts logging the Arduino's serial output the Arduino will reboot again (which can be disabled with some hardware mods)

http://stackoverflow.com/questions/16224816/preventing-reset-on-serial-monitor-connect 

rickylee64 on upload data from thingspeak to pvoutput

$
0
0

I'm using an ESP8266 to upload data to thingspeak. I'd like to load this data from thingspeak to PVOutput. Can thingspeak code be written do this?

Reason being, it is easy to use a MCU to upload data in real time to thingspeak. It is more complex with PVOutput, as time & date stamps are required with each data upload, which means time retrieval from an NTP server, plus interval measurement in my microcontroller, or a RTC in my hardware.

My programming skills are only at Arduino IDE level. I suspect thingspeak could do what I want, but I don't know how.

Any help appreciated Smile

rw950431 on upload data from thingspeak to pvoutput

$
0
0

Possibly you can set up a React which triggers a ThingHTTP to push to PVOutput every time data is inserted into Thingspeak.

Karthikraja Nagendran on how to read the Digital Pin

$
0
0

Hi Guys,

 

I have the capacitive type Proximity sensor that sensor operates at 12volts and output only NO and NC (digital Output ). How to send the Thinkspeak Fields... Already I send the temprature data pressure data fileds using Arduino Uno .... Please guide me 

Viewing all 172 articles
Browse latest View live