Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Yun's Labour's Lost....
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Yun's Labour's Lost....

by erix_inc on Wed Feb 17, 2016 4:39 pm

Hello Folks,

I've had a Yun for almost 2 years. I've never gotten it to work. I bang on it for a few hours and then put it away with the other wireless boards that I can't get to work (like particle and imp and....). It's sad really.

So, chuffed off the success of my Feather datalogger application, I decided to have yuet another bash at Yun and try to publish data to adafruit.io

I'm working with the Adafruit_MQTT library and the mqtt_yun example. I've gone through the steps in this tutorial: https://learn.adafruit.com/mqtt-adafrui ... u/overview but I'm not getting data up to adafruit.io.

The example code isn't very clear about how the data from the pins is to make its way through the ether and display on adafruit.io so I reused some code off my last successful experiment. I've connected a photocell and pull down to A1. I've added the following code where (I think) appropriate:
Code: Select all | TOGGLE FULL SIZE
#define photocellPin 1          // the LDR and 10K pulldown are connected to A1

int photocellReading;                 // the analog reading from the analog resistor divider

void loop() {
....
  // Now we can publish stuff!
  Console.print(F("\nSending photocell val "));
  Console.print(x);
  Console.print(photocellReading);                       //print the value of the LDR
  Console.print("...");
  if (! photocell.publish(x++)) {
    Console.println(F("Failed"));
  } else {
    Console.println(F("OK!"));
  }
...


Connected to the Serial Monitor (via WiFi) I get this:

Code: Select all | TOGGLE FULL SIZE
Unable to connect: retrying (1)...
Unable to connect: retrying (2)... connected!
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed


ad infinitum...

So! How many things are wrong here? ;)

Is the Yun connected to Adafruit.IO or not? I think not as when I run the "HttpClient" example I get this on the serial monitor:
Code: Select all | TOGGLE FULL SIZE
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.4.2</center>
</body>
</html>


But the "WiFiStatus" example shows I'm connected to our network and I can flash the Yun via WiFI. Maybe I'm connected to it but it isn't connected to the internet?

Second, is the " Console.print(photocellReading);" the proper way/command to push data to adafruit.io? If not, what part of the code in the example is sending the photocell data?

Thanks for any help you can give!

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Re: Yun's Labour's Lost....

by adafruit2 on Wed Feb 17, 2016 6:10 pm

plz try turn on MQTT debugging, run the example without any changes

adafruit2
Site Admin
 
Posts: 19223
Joined: Fri Mar 11, 2005 7:36 pm

Re: Yun's Labour's Lost....

by erix_inc on Wed Feb 17, 2016 6:17 pm

Will do!

But how?

Also, I would need to modify it with my username and key, wouldn't I?

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Re: Yun's Labour's Lost....

by adafruit2 on Wed Feb 17, 2016 6:20 pm

uncomment MQTT_DEBUG In adafruit_mqtt.h

yes of course put in your username, but dont make modifications to the code to change pins or how data is sent,etc

adafruit2
Site Admin
 
Posts: 19223
Joined: Fri Mar 11, 2005 7:36 pm

Re: Yun's Labour's Lost....

by erix_inc on Wed Feb 17, 2016 7:18 pm

ok!
debug is on, the serial monitor (via wifi) reads:
Code: Select all | TOGGLE FULL SIZE
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Failed to subscribe
Retrying MQTT connection in 5 seconds...


Where would the debug info be displayed?

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Re: Yun's Labour's Lost....

by erix_inc on Wed Feb 17, 2016 7:21 pm

i typed too soon! Bringing up the serial monitor on the COM port brings up:
Code: Select all | TOGGLE FULL SIZE
Connecting to: io.adafruit.com
Connect result: 1
MQTT connect packet:
  [0x10], D [0x44],   [0x00],   [0x04], M [0x4D], Q [0x51], T [0x54], T [0x54],
  [0x04],   [0xC2],   [0x01], , [0x2C],   [0x00],   [0x04], M [0x4D], Q [0x51],
T [0x54], T [0x54],   [0x00],   [0x08], e [0x65], r [0x72], i [0x69], x [0x78],
_ [0x5F], i [0x69], n [0x6E], c [0x63],   [0x00], ( [0x28], 4 [0x34], e [0x65],
3 [0x33], 3 [0x33], 0 [0x30], 1 [0x31], 2 [0x32], 1 [0x31], 8 [0x38], 9 [0x39],
f [0x66], 7 [0x37], c [0x63], c [0x63], 9 [0x39], b [0x62], e [0x65], 0 [0x30],
e [0x65], 7 [0x37], 9 [0x39], 0 [0x30], 1 [0x31], 3 [0x33], 0 [0x30], 8 [0x38],
d [0x64], a [0x61], 7 [0x37], 7 [0x37], 6 [0x36], 4 [0x34], 1 [0x31], b [0x62],
0 [0x30], c [0x63], a [0x61], c [0x63], 1 [0x31], a [0x61],
sendPacket returned: 70
MQTT disconnect packet:
  [0xE0],   [0x00],
sendPacket returned: 2


over and over again...

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Re: Yun's Labour's Lost....

by erix_inc on Wed Feb 17, 2016 7:30 pm

I tried pinginig io.adafruit.com and got 0 out of 5 packets returned.
I got 5 out of 5 when pinging openwrt so I'm thinking the Yun is connected to the internet.

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Re: Yun's Labour's Lost....

by adafruit2 on Thu Feb 18, 2016 11:13 am

ping is turned off on io
not sure what the deal is but you're getting bumped by the server.
i dont have a yun myself but will ask if someone else has one and can try the code.

adafruit2
Site Admin
 
Posts: 19223
Joined: Fri Mar 11, 2005 7:36 pm

Re: Yun's Labour's Lost....

by erix_inc on Thu Feb 18, 2016 11:22 am

Thanks!

Tech being what it is - obsoleted before the solder cools - I know better dev boards are out there that would probably be easy to configure, connect, and do the work.

However this Yun has been in my project box for far too long! I'd just like to get it doing SOMETHING useful!

erix_inc
 
Posts: 31
Joined: Mon Dec 08, 2014 8:41 am

Please be positive and constructive with your questions and comments.