Black Lives Matter - Action and Equality.
0

DigitalOutput Example, Help?
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.

DigitalOutput Example, Help?

by grady56 on Thu Apr 09, 2020 8:53 pm

Hello everyone, new around here so if this is the wrong section for this topic that's my bad!

I'm having a lot of trouble getting Adafruit IO's DigitalOutput(built-in) example to work with my AIRLIFT M4 EXPRESS.

Specifically, I've gone through the guide and have installed all requisite libraries and board(s), followed it to the tee using provided code BUT: My LED won't light up.

This sounds really simple but I've spent about 3-4 hours haunched over my laptop trying to figure out what I did wrong!

I've tried obvious things like:

- Using a different LED and also tried using without a current-limited resistor
- Completely re-installing Arduino IDE and mentioned libraries/boards(making sure leftover files where also deleted)
- Using a different 2.4GHz network
- Taking the #define LED_PIN statement and changing it to "LED_PIN = 5;" and changing to an alternate pin just incase for some reason pin5 was borked( it isn't, I tested it with a known working LED)
- And some other stuff that I don't even remember doing, just out of frustration. I know I restarted my PC, even tried using Ubuntu instead of Windows to no avail.

Some insight or help would be greatly appreciated from the community.

Thanks!

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by brubell on Fri Apr 10, 2020 9:51 am

Specifically, I've gone through the guide and have installed all requisite libraries and board(s), followed it to the tee using provided code BUT: My LED won't light up.

This sounds really simple but I've spent about 3-4 hours haunched over my laptop trying to figure out what I did wrong!


Sorry to hear this, I'd like to help troubleshooting your project.

[*] Please post a picture of your wiring setup, clearly showing all the connections between the breadboard and your airlift m4.
[*] What happens in the Arduino Serial Monitor when you change the state of the LED from the Adafruit IO Dashboard? (See this page for example output: https://learn.adafruit.com/adafruit-io- ... utput/code). Could you copy and paste the serial monitor's output below?

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: DigitalOutput Example, Help?

by grady56 on Fri Apr 10, 2020 3:42 pm

Thanks so much for the prompt response!

I have a video of my wiring and a small run-through of what im doing on my end.

Additionally, I've included the output of the Serial Console.

https://drive.google.com/file/d/1Or76RJixYTI0WZK_VGiaSnhdIVoO5Ryz/view?usp=sharing

https://drive.google.com/file/d/1fjrdpcap6HKcUpvjIs6RI_-8WpZ0BiLM/view?usp=sharing

Thanks again!

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by grady56 on Thu Apr 16, 2020 11:49 am

Anyone have any insight on this?

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by brubell on Sat Apr 18, 2020 9:54 am

Could you please attach a clear photo of your wiring setup?
Additionally, can you please copy and paste the code into this thread? Thanks.

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: DigitalOutput Example, Help?

by grady56 on Mon Apr 20, 2020 2:10 pm

brubell wrote:Could you please attach a clear photo of your wiring setup?
Additionally, can you please copy and paste the code into this thread? Thanks.


20200420_135443.jpg
20200420_135443.jpg (804.83 KiB) Viewed 43 times


Digital_Out_Code:
Code: Select all | TOGGLE FULL SIZE
// Adafruit IO Digital Output Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-digital-output
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

#include "config.h"

#define linkLED 9
#define LED_PIN 8

void handleMessage(AdafruitIO_Data *data) {

  digitalWrite(LED_PIN, data->toPinLevel());

  Serial.print("received <- ");

  if(data->toPinLevel() == HIGH)
    Serial.println("HIGH");
  else
    Serial.println("LOW");

}

// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("digital");

void setup() {
 
  pinMode(LED_PIN, OUTPUT);
  pinMode(linkLED, OUTPUT);
 
  Serial.begin(115200);

  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();

  digital->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());
  digital->get();

}

void loop() {

  io.run();

  // This while loop blinks an LED on/off while Adafruit IO is connected
  while(io.status() == AIO_CONNECTED) {
   
    digitalWrite(linkLED, HIGH);
    delay(500);
    digitalWrite(linkLED, LOW);
    delay(500);
   
    }
}

Config.h(Sensitive Info Omitted):
Code: Select all | TOGGLE FULL SIZE
// Adafruit IO Digital Output Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-digital-output
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************ Adafruit IO Config *******************************/

// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME ""
#define IO_KEY ""

#define WIFI_SSID ""
#define WIFI_PASS ""

// uncomment the following line if you are using airlift
#define USE_AIRLIFT

// uncomment the following line if you are using winc1500
// #define USE_WINC1500

// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) ||         \
    defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define NINA_ACK 9    // a.k.a BUSY or READY pin
#define NINA_RESETN 6 // Reset pin
#define NINA_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
                   NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by brubell on Tue Apr 21, 2020 9:33 am

If you run the blink example (file->examples->basics->blink) and change LED_BUILTIN to 8, does the LED blink?

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: DigitalOutput Example, Help?

by grady56 on Tue Apr 21, 2020 9:43 am

In an attempt to resolve the problem myself I uninstalled arduino using RevoUninstaller. I am now getting all kinds of cryptic errors, the main one of which states: "fatal error: avr/pgmspace.h: No such file or directory"

I have no idea whats wrong with my settings/IDE. I reinstalled using the arduino website so im guessing its the official software.

Did revo delete something it shouldnt have?

I cannot compile any code right now due to this error :(

Thanks for all your help thus far Brubel!

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by brubell on Tue Apr 21, 2020 9:50 am

After uninstalling and re-installing, go thru this page to install all the arduino libraries and board support files: https://learn.adafruit.com/adafruit-met ... wifi/setup

btw - what is on top of the SAMD21:
m4_top.png
m4_top.png (316.4 KiB) Viewed 39 times

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: DigitalOutput Example, Help?

by grady56 on Tue Apr 21, 2020 9:59 am

That is a tiny heatsink: Not that it needs one, but I had a few on hand and thought it would look "slick" :)

Ill uninstall the old-fashioned way and use the guide provided by you, if that doesnt work ill update you here. Most likely im just going to do a system reformat or repartition and install ubuntu OS just for doing arduino developement-related tasks.

UPDATE: Yea, after uninstalling and reinstalling folllowing the guide receiving the same error, this is really frustrating: "fatal error: avr/pgmspace.h: No such file or directory"

At a loss here, I dont know enough about MCU's/Arduino IDE to debug this error. A cursory google search reveals a few results with either complicated solutions or no solution at all :(

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Re: DigitalOutput Example, Help?

by grady56 on Tue Apr 28, 2020 10:56 am

Issue solved Via reformatting my Linux Ubuntu OS. I think the problem was that I had multiple WiFiNINA libraries installed in different locations that I could not access or couldnt locate via a simple search or using Terminal. The IDE's console always barked a message relating to "multiple WiFiNINA libraries". I think it was trying to call the wrong library and hence was throwing all kinds of errors.

As soon as I installed Adafruits WiFiNINA .zip from GitHub everything works.

Another note: The ESP32 on my Airlift completely refuses to work without the while(! Serial) and Serial.begin(baud) statements. Is this inherent to the design of the ESP32? Does it REQUIRE a serial interface to communicate with the M4 or do things "Over-the-Air"? It seems so.

Either way, issue is fixed with some insight gained! Consider this thread archived/closed!

Thank you for your help Brubell!

grady56
 
Posts: 10
Joined: Mon Feb 17, 2020 12:54 pm

Please be positive and constructive with your questions and comments.