1:39 pm

July 3, 2016

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
11:45 pm

June 30, 2016

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
7:05 pm

July 3, 2016

1:57 pm

June 3, 2019

Hi...you 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.
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, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457