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

BeeWare on missing data points

$
0
0

I am using an arduino uno wifi to post 4 sensors to 1 channel, and It looks like I am missing data points. why am I missing data points?


Vinod on missing data points

$
0
0

Please post your code so someone can look into it to provide suggestion.

A few things to check in your code:

  • Are you updating your channel faster than the maximum update rate for your user type? Free user accounts can update a channel once every 15s, a paid ThingSpeak license enables you to update a channel every second.
  •  Are you updating one field at a time for a channel, rather than updating all fields in a single shot? If so, there is a very high likelihood that you are violating the above mentioned aspect
  • Have you tried connecting to a serial port from a computer and using serial.print() to print out the return code you get from ThingSpeak? That will usually give you a good idea of what is going on.

BeeWare on missing data points

$
0
0

below is my loop code, so do i need to put a delay in between each of my uploads instead of 30 seconds t the end?

 

void loop()
{
dTemp.requestTemperatures();

String uri = "/update?api_key=";
uri += APIKEY;

uri += "&field1="; //populates field 1 on ThinkSpeak Website
uri += String(dTemp.getTempF(Probe01)); //gets temperature from probe 1

uri += "&field2="; //populates field 2 on ThinkSpeak Website
uri += String(dTemp.getTempF(Probe02)); //gets temperature from probe 2

uri += "&field3="; //populates field 3 on ThinkSpeak Website
uri += String(dTemp.getTempF(Probe03)); //gets temperature from probe 3

uri += "&field4="; //populates field 4 on ThinkSpeak Website
uri += String(scale.get_units()); // get weight on scale in lbs

Ciao.println("Send data on ThingSpeak Channel");

CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty()){
Ciao.println( "State: " + String (data.get(1)) );
Ciao.println( "Response: " + String (data.get(2)) );
}
else{
Ciao.println("Write Error");
}

delay(30000); // 30 seconds delay

}

Vinod on missing data points

pedretexksi on Problem updating data counter

$
0
0

Hi everyone,
I´m new with IoT. I have an arduino connected to thingspeak and i want to send the number of times that a push button is activated.
The problem is that at the begining the arduino sends the first data to my chanel but then it stops.
If I use the fuction "delay" it sends the information but I can´t use this because the program is stopped during this seconds so I´m trying a timer library. I hope someone could help me to fix this. Thanks
Here is my code:

int BUTTON_PIN = 2;
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
unsigned long myChannelNumber = XXXXXXX;
const char * myWriteAPIKey = "XXXXXX";

#include <TimerOne.h>
#include "ThingSpeak.h"
#define USE_ETHERNET_SHIELD
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;

void setup() {

Timer1.initialize(180000000); // 18 s
Timer1.attachInterrupt(Thingspeak) ;
pinMode(BUTTON_PIN, INPUT_PULLUP);

//Serial.begin(9600);
Ethernet.begin(mac);
ThingSpeak.begin(client);
}

void loop() {

int buttonState = digitalRead(BUTTON_PIN);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
buttonPushCounter++;
//Serial.print("Counter: ");
//Serial.println(buttonPushCounter);

}
// Delay a little bit to avoid bouncing

delay(150);
// save the current state as the last state,for next time through the loop
noInterrupts(); // Suspende las interrupciones
lastButtonState = buttonState;
interrupts();

}

void Thingspeak() {
ThingSpeak.setField(1,buttonPushCounter);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
//ThingSpeak.writeField(myChannelNumber, 1, buttonPushCounter, myWriteAPIKey);
//Serial.print("Enviando datos ");
//Serial.println(buttonPushCounter);
}

s161025 on Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak

$
0
0

Hello, everyone!

I am not a programmer as you will realise, but I set up a program for measuring weight with HX711 load cell for a uni project, and I would like to upload the measurments to my TS channel. The arduino UNO WiFi Dev board is connected to a WiFi network but I can't manage to make it work.

Before Setup, I defined the weight (3 decimals) and led (reading from A1)

#define CONNECTOR "rest"
#define SERVER_ADDR "api.thingspeak.com"

#define APIKEY_THINGSPEAK " " //Insert your API Key

float weight = 0.000;

int led;

and in Loop

weight = scale.get_units();
pump = analogRead(A1);

String uri = "/update?api_key=";
uri += APIKEY_THINGSPEAK;
uri += "&field1=";
uri += String(weight);
uri += "&field2=";
uri += String(led);

Ciao.println("Send data on ThingSpeak Channel");

CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty()) {
Ciao.println( "State: " + String (data.get(1)) );
Ciao.println( "Response: " + String (data.get(2)) );
}
//delay(30000); // Thinkspeak policy
else {
Ciao.println("Write Error");
}

The delay is commented because I use different time-step code.

The thing is that I can Serial.print the values of weight and led but not to upload them. However, when I give specific values to them it uploads without problem. Any help would be much appreciated.

JasonW on Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak

$
0
0

It looks like you are declaring an int led in the first part.  But then in the looped code, you use a variable called pump to read the analog input.

Then further down you use  uri += String(led);

Since led hasn't been assigned a value, adding it to the uri string will have unexpected results. 

Try this:

change int led to int pump

change uri += String(led); to uri += String(pump); 

s161025 on Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak

$
0
0

My bad. I meant led = AnalogRead(A1);

This seems consistant. I think that the problem is somewhere else.


habapa on What is wrong with I2C on edison with HTU21DF or MPL3115A2 or BMP280 ?

$
0
0
Hi everybody,

 

I am trying to build an teaching IoT-micro-weatherstation and I am facing problems with I2C sensors  or more probably Edison I2C behavior. I had faced some hardware problems few weeks ago so I have bought a new Edison mini-breakout and a set of new sensors from isweek:

HTU21DF

BME280

MCP9808

SI1145

MPL3115A2

BMP280

(I have also some other ones that are not involved in this question...)

 

First of all I am pretty sure that some months ago I have been abl to easily handle an HTU21D-F sensor with mraa and upm, then came the change in mraa that added a check on the communication between the Edison and the device that we overcome. But now the problem is worse the HTU21D-F is not detected any more !

 

I am using a level shifter to be shure to provide 1.8v signal on SDA and SCL pins of my minibreakout.

I am as sure as possible that my wiring is correct because I am using a breadboard with

SI1145 / MCP9808 / BME280 that are detected (I have not tried yet to get measurements)

on I2C bus 6 or BUS 1  I have activated bus 6 with these instructions:

echo 28 > /sys/class/gpio/export 

echo 27 > /sys/class/gpio/export 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

 

i2cdetect -y -r 6

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- 77                       

 

If I try to wire any of The three others one by one or in any combination I getno detection

i2cdetect -y -r 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --                 

 

Same result on bus 6 or 1 !!

 

I have tested the sensors on an arduino, they perform very well, I have tested HTU21D-F on an arduino breakout it does not work with the adafruit IDE test program and sends the message no sensor detected. With the demo program the sensor is detected but the values read are wrong (probably empty buffer).

 

I have read a little bit the forum and have seen that there are many questions dealing with I2C  buses, I can proove that "in many cases" everything works as expected but in some cases  the communication situation seems locked between the sensor and the edison. It is just like if the Edison was not able to "bring the sensor to communicate with him" To confirm this hypothesis I removed the

MPL3115A2 and left it away, after some minutes when I plugged it back It was detected without changing anything  :

 

i2cdetect -y -r 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --     

 

Just if the sensor came back spontaneously to a good state... I tried to plug the BMP280 and....It was detected!!!!!!!

 

i2cdetect -y -r 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- 77

 

I am getting mad on this question, do you have any suggestion, as this is for teaching  K9-12 teachers I cannot resonably tell them : "unplug, wait for 4'47", then plug again it will work...."

 

Any help will be greatly appreciated, if needed I can do some tests and in teh meantime I will write the code to reas and compare measurements between sensors...

Thanks in advance and many thanks to all contributors and intel facilitators in this nice community.

 

G.

mohamedali1993 on Strings in Arduino IDE

$
0
0

Hello,

From what I am seeing in the online documentation, we can write integers in the Arduino IDE using ThingSpeak.setField then ThingsSpeak.writeFields(), but can we write strings? Can we send data that doesn't need to be graphed?

 

Thank you,

Mo

narkase on arduino + ajax + hml and ThingSpeak

$
0
0

Hey all,

 I want to make a remote control system and display sensors parameters so I'm using ThingSpeak to plot graphs and some buttons to control leds, seperatly everything works perfect, but when I add them together ThingSpeak doesnt get a data.
There is a html code:

<html>
    <head >
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>title</title>
       
        strLED3 = "";
        strLED4 = "";
        var LED3_state = 0;
        var data_val=0;
        var num_updates = 0;    // number of 200ms periods used to calculate time to send data to ThingSpeak
        
          function GetArduinoInputs()
        {
           nocache = "&nocache=" + Math.random() * 1000000;
            var request = new XMLHttpRequest();
            request.onreadystatechange = function()
            {
                if (this.readyState == 4) {
                    if (this.status == 200) {
                        if (this.responseXML != null) {
                        
                        
                        document.getElementById("input4").innerHTML =
                               this.responseXML.getElementsByTagName('analog1')[0].childNodes[0].nodeValue;
                                
                                                  data_val=this.responseXML.getElementsByTagName('analog1')[0].childNodes[0].nodeValue;
                                
                                if (this.responseXML.getElementsByTagName('LED')[0].childNodes[0].nodeValue === "on") {
                                document.getElementById("LED3").innerHTML = "ON (TURN OFF)";
                                LED3_state = 1;
                            }
                                else {
                                document.getElementById("LED3").innerHTML = "OFF (TURN ON)";
                                LED3_state = 0;
                                     }
                                
                                
                                if (this.responseXML.getElementsByTagName('LED1')[0].childNodes[0].nodeValue === "on") {
                                document.getElementById("LED4").innerHTML = "ON (TURN OFF)";
                                LED4_state = 1;
                            }
                                else {
                                document.getElementById("LED4").innerHTML = "OFF (TURN ON)";
                                LED4_state = 0;
                                     }
                                
                                
                                
                                
                        
                                
                                if (num_updates >= 100) {
                                    num_updates = 0;
                                    // send voltage to ThingSpeak
                                    ThingSpeakSend("XXXXXXXXXXXXX",data_val);    // insert your ThingSpeak Write API Key here
                                }
                                num_updates++;
                        }
                        
                    }
                }
            }
            request.open("GET", "ajax_inputs" + nocache, true);  //request.open("GET", "ajax_inputs" + strLED3 + strLED4 + nocache, true);
            request.send(null);
            setTimeout('GetArduinoInputs()', 200);
            strLED3 = "";
            strLED4 = "";
        }
        
        
        function GetButton1()
        {
            if (LED3_state === 1) {
                LED3_state = 0;
                strLED3 = "&LED3=0";
            }
            else {
                LED3_state = 1;
                strLED3 = "&LED3=1";
            }
        }
        
        function GetButton2()
        {
            if (LED4_state === 1) {
                LED4_state = 0;
                strLED4 = "&LED4=0";
            }
            else {
                LED4_state = 1;
                strLED4 = "&LED4=1";
            }
        }
        
            // function to send data to ThingSpeak
        function ThingSpeakSend(api_write_key, data)
        {
            var ts_req = new XMLHttpRequest();
            // GET request string - modify if more fields are needed
            var req_str = "http://api.thingspeak.com/update?key=" + api_write_key + "&field1=" + data;
            ts_req.onreadystatechange = function()
            {
                // not doing anything with response from ThingSpeak
            }
            // send the data to ThingSpeak
            ts_req.open("GET", req_str, true);
            ts_req.send(null);
        }
        
        
        
    </head>
    
        
         <body onload="GetArduinoInputs()">
        
        
        
         <button  type="button" id="LED3" onclick="GetButton1()"> OFF (TURN ON) </button>
        
         <button  type="button" id="LED4" onclick="GetButton2()"> OFF (TURN ON) </button>
        
        
                   src="https://thingspeak.com/channels/235349/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=7&title=%C5%BDem%C4%97s+dr%C4%97gm%C4%97&type=line&xaxis=Data&yaxis=%25&yaxismax=100&yaxismin=0">
        
        
        
          </body>

How I figured out its a problem with a GET message, when I simply write:
request.open("GET", "ajax_inputs" + nocache, true);
graph  is plotted, but when I add to this request strings which keep LED states values it doesnt work.
[code]request.open("GET", "ajax_inputs" + strLED3 + strLED4 + nocache, true);
 [/code]

So maybe you could help me?

Sintra Air on DSM501a - Arduino

$
0
0

 Hello comunity, I'm new here.

 

Have been able to post DHT readings to my channel with no problems at all.

Recently, I've been trying, with no any success to post data from a dust sensor, the DSM501a.

So, I can read the sensor on Arduino serial, but once I try to implement it on the sketch that I'm using to upload DHT sensor, this part of the code seems to stop everything 🙁

void setup ()

// Initialize DSM501
dsm501.begin(MIN_WIN_SPAN);

// wait 60s for DSM501 to warm up
for (int i = 1; i <= 60; i++)
{
delay(1000); // 1s
Serial.print(i);
Serial.println(" s (wait 60s for DSM501 to warm up)");
}

Any ideas?

rw950431 on DSM501a - Arduino

$
0
0

Does it print anything to Serial?

 

The code you posted is missing a closing }- I assume there is one in the real code.

Sintra Air on DSM501a - Arduino

$
0
0

Hey!

 

It was printing.

 

Problem "kinda" solved.

It started posting information, but sometimes it just stops for radom 20 or 30min periods.

Maybe now related with the power supply, I think. Or arduino's memory. 

Next step: debug power supply.

 

I moved that part of the code on the void setup () 

to after all the ethernet operations before sending.

I think it might be related with timeouts.

 

//------ENC28J60----------
//if correct answer is not received then re-initialize ethernet module
//changed from 220 to 2800
if (res > 220){
initialize_ethernet();
}

res = res + 1;

ether.packetLoop(ether.packetReceive());

//200 res = 10 seconds (50ms each res)
if (res == 200) {

//_____________ TIME for DESPERATED MEASURES
dsm501.begin(MIN_WIN_SPAN);
dsm501.update();
int p=(dsm501.getPM25()/100);

// field1=(Field 1 Data)&field2=(Field 2 Data)&field3=(Field 3 Data)&field4=(Field 4 Data)&field5=(Field 5 Data)&field6=(Field 6 Data)&field7=(Field 7 Data)&field8=(Field 8 Data)&lat=(Latitude in Decimal Degrees)&long=(Longitude in Decimal Degrees)&elevation=(Elevation in meters)&status=(140 Character Message)
byte sd = stash.create();
stash.print("field1=");
stash.print(t);
stash.print("&field2=");
stash.print(h);
stash.print("&field3=");
stash.print(p);
stash.save();

 

I have lots of ideas, the problem is putting them to the practice.

Fortunately there are so many possibilities nowadays, and there is internet, the biggest library in the world =D

Sintra Air on DSM501a - Arduino

$
0
0

So, I was powering everything from arduino uno board.

 

Today I repurposed an old Sat Receiver's power supply, which supplies multiple voltages (3.3, 5, 7 and 12V, all with common groud), and powered everything (ethernet shield 3.3v, DSM501a 5v, dht11 5v and the arduino itself with 7v.
still to add a gas sensor, as soon as it arrives at my location.

The insane behaviour seems to have stopped.

Although, I had one 20min pause, in about 5 hours of sending data every minute. Not perfect, but can't complain. It could be internet connection, or even a thingspeak problem. 

Can't debug live, because the device is far away from home.

Will be now for a 48h run to check for stability.

 

BTW, channel here: https://thingspeak.com/channels/230655 Laugh


Sintra Air on DSM501a - Arduino

$
0
0

So, conclusion, just in case someone is in the same situation:

 

It was a program problem. It still is, but I found a way out.

SRAM, as far as I understood was being corrupted, making the arduino behave strange and random.

Using the comand: asm volatile ("  jmp 0");  after the last action performed by the program, helped a lot.

It "clears" all the volatiles and the system runs smooth with no problems at all.

 

Might be a dirty way to do the thing speak forever with no interruptions, but the fact is that it works like a charm.

Griwen on ThingSpeak problems with upload

$
0
0

Hello!
I have Arduino Uno WiFi, and the temperature sensor DHT21. Problem starts when I try to upload my values from sensors to ThingSpeak. When I try to upload more than two fields in rest uri, it's not working, when its two or one field i can upload this values without problems.

#include "DHT.h"
#include <Wire.h>
#include <UnoWiFiDevEd.h>

#define CONNECTOR "rest"
#define SERVER_ADDR "api.thingspeak.com"

#define APIKEY_THINGSPEAK "****************" //Insert your API Key

#define DHTPIN 2 // modify to the pin we connected
#define DHTPINN 3 // modify to the pin we connected
#define DHTTYPE DHT21 // AM2301
DHT dht(DHTPIN, DHTTYPE);
DHT dhtt(DHTPINN, DHTTYPE);

short hum = 60;
short temp = 22;
short hum1 = 65;
short temp1 = 25;

void setup() {
Ciao.begin(); // CIAO INIT
Serial.begin(9600);
dht.begin();
dhtt.begin();
}

void loop() {
int h = dht.readHumidity();
float t = dht.readTemperature();
int ha = dhtt.readHumidity();
float ta = dhtt.readTemperature();

Ciao.println(h);
Ciao.println(t);
Ciao.println(ha);
Ciao.println(ta);

String uri = "/update?api_key=";
uri += APIKEY_THINGSPEAK;
uri += "&field1=";
uri += String(h);
uri += "&field2=";
uri += String(t);
uri += "&field3=";
uri += String(ha);
uri += "&field4=";
uri += String(ta);

Ciao.println("Send data on ThingSpeak Channel");

CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
if (!data.isEmpty()){
Ciao.println( "State: " + String (data.get(1)) );
Ciao.println( "Response: " + String (data.get(2)) );
}
else{
Ciao.println("Write Error");
}

delay(30000); // Thinkspeak policy

}

 

When I put only two fields it works:

String uri = "/update?api_key=";
uri += APIKEY_THINGSPEAK;
uri += "&field1=";
uri += String(h);
uri += "&field2=";
uri += String(t);

 

Console:

Send data on ThingSpeak Channel
Write Error
29
26.10
25
26.40
Send data on ThingSpeak Channel
Write Error
29
26.20
30
26.40
Send data on ThingSpeak Channel
State: 400
Response:

rw950431 on ThingSpeak problems with upload

$
0
0

Perhaps you can try to print the url to console or maybe just the length to see how long it is?  Perhaps you are exceeding some kind of buffer length somewhere..   You could also experiment by adding  "&status=xxx" then gradually increasing the length until you trigger the error.

 

Maybe you could also add a delay between the write and the isdataEmpty() to make sure there is no timing problem.

Griwen on ThingSpeak problems with upload

$
0
0

In console with two value it works from sensors:

Send data on ThingSpeak Channel
/update?api_key=**********&field1=22&field2=36
State: 200
Response: 131

In console three sensors but not float

Send data on ThingSpeak Channel
/update?api_key=**********&field1=22&field2=36&field3=24
State: 200
Response: 142

It works

From 4 sensors it doesnt work
Send data on ThingSpeak Channel
/update?api_key=**********&field1=22&field2=36&field3=30&field4=13
Write Error
Send data on ThingSpeak Channel
/update?api_key=**********&field1=22&field2=36&field3=30&field4=12
State: 400
Response: 

So the problem can be the length, but i need to upload two float values like 10.09 and two short values line 50.
 
 










Vinod on ThingSpeak problems with upload

Viewing all 172 articles
Browse latest View live