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

Luis_Filipe on Arduino Mega with yun shield

$
0
0

Hello guys,

 

I want to collect data to thingspeak by a analog A0 input with WiFi communication, the problem is that I´cannot setup by yun shield to send data.

I test with a ethernet shield and everything is correct, but with the yun shield the data is not be send, look the code:

 

#ifdef SPARK
#include "ThingSpeak/ThingSpeak.h"
#else
#include "ThingSpeak.h"
#endif
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0
#define USE_WIFI_SHIELD

#include "BridgeClient.h"
BridgeClient client;

unsigned long myChannelNumber = 1XX47;
const char * myWriteAPIKey = "XXXXXXXXXXT7SVDMCJ5";

#include <SPI.h>
#include <WiFi.h>
char ssid[] = "MySSID"; 
char pass[] = "MyPASSWORD"; 
int status = WL_IDLE_STATUS;

void setup() {
Bridge.begin();
WiFi.begin(ssid, pass);

ThingSpeak.begin(client);
}

void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);

ThingSpeak.writeField(myChannelNumber, 1, voltage, myWriteAPIKey);
delay(20000); // ThingSpeak will only accept updates every 15 seconds.
}

 

what is wrog, any ideia?

 

Thanks in advance


Viewing all articles
Browse latest Browse all 172

Trending Articles