Arduino Mega with yun shield | Arduino | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Arduino Mega with yun shield
Avatar
Luis_Filipe
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
1
July 3, 2016 - 1:39 pm
sp_Permalink sp_Print

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

Avatar
jpsabo
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
2
July 4, 2016 - 11:45 pm
sp_Permalink sp_Print sp_EditHistory

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

Avatar
Luis_Filipe
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
3
July 7, 2016 - 7:05 pm
sp_Permalink sp_Print

OK, solve the issue, Thanks a lot!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: cstapels, jacktheripper125
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

Nsneilotof

angieus2

goldiepw11

BinanceoSt

gnarender123@gmail.com

edenderest

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee