Arduino Mega with yun shield | Arduino | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.

Please consider registering

sp_LogInOut Log In sp_Registration Register

6   +   1   =  

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
New Member
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"
#include "ThingSpeak.h"
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0

#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() {
WiFi.begin(ssid, pass);


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
New Member
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 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:

Arduino Mega250Image Enlarger

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

OK, solve the issue, Thanks a lot!

June 3, 2019
1:57 pm
New Member
Forum Posts: 1
Member Since:
June 3, 2019
sp_UserOfflineSmall Offline indicated that you have added that jumper, and that the Yun can talk to the Mega in this state. But now you want to upload sketches to the Mega, and that requires use of the USB interface.
Obviously, with the USB interface held in reset, you will not be able to connect to the Mega using the USB interface. It simply won't be detected by your computer, and there will be no serial port created for it.
So, it would seem that the solution is to remove the jumper that is holding the USB interface in reset. This will allow the USB interface to be detected by the computer, and the IDE will attempt to download a sketch. However, just as the USB interface can interfere with the Yun Shield's communications with the Mega, the Yun Shield can interfere with the USB interface's communications with the Mega.

printed circuit board assembly

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
35 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457