Arduino Mega with yun shield | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Arduino Mega with yun shield
No permission to create posts
July 3, 2016
1:39 pm
Avatar
Luis_Filipe
New Member
Members
Forum Posts: 3
Member Since:
July 3, 2016
sp_UserOfflineSmall Offline

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

July 4, 2016
11:45 pm
Avatar
jpsabo
New Member
Members
Forum Posts: 4
Member Since:
June 30, 2016
sp_UserOfflineSmall Offline

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

July 7, 2016
7:05 pm
Avatar
Luis_Filipe
New Member
Members
Forum Posts: 3
Member Since:
July 3, 2016
sp_UserOfflineSmall Offline

OK, solve the issue, Thanks a lot!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

BarryMaync, ThomasRougs, DonaldGen, prince, JrGordon, Elamsweems

Administrators: Hans: 387, lee: 457