Go Down

Topic: Using WiFi, LCD, and encoder (Read 1 time) previous topic - next topic

slashy42

I'm trying to do a project where I am using a the built in wifi, Adafruit LCD (https://www.adafruit.com/product/181), and a rotary encoder. My issue is that I cant seem to use any combination of pins that allow me to use all of these devices, and I can not seem to find the pinout data for the wifi radio. Does it touch any of the MKR1000s externally accessible pins? Am I barking up the wrong tree? The WiFi works when I disable the encoder and LCD, and the LCD and Encoder work either way. Currently I'm starting the encoder and LCD with the following lines, but I've tried nearly every combination I can think of.

Encoder myEnc(4, 5);
LiquidCrystal lcd(6, 3, 7, 1, 0, 2);

ballscrewbob

You really need to post ALL your code but PLEASE PLEASE USE CODE TAGS.

Not many of us using the MKR but we are lucky to have a couple of mods and developer gurus in this section.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

slashy42

OK, Sure. The code never gets past the initWiFi call in the setup phase. Specifically it hangs at WiFi.begin(ssid, pass) != WL_CONNECTED.

Code: [Select]

#include <Encoder.h>
#include <LiquidCrystal.h>
#include <WiFi101.h>
#include <WiFiSSLClient.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <AzureIoTHub.h>
#include "simplesample_http.h"

char ssid[] = "*************";
char pass[] = "*************";
long oldPosition  = -9999;

Encoder myEnc(4, 5);
LiquidCrystal lcd(6, 3, 7, 1, 0, 2);

WiFiSSLClient sslClient;

AzureIoTHubClient iotHubClient(sslClient);


void setup() {
  initSerial();
  initWifi();
  initTime();
  iotHubClient.begin();
}

void loop() {
  encoderUpdate();
  simplesample_http_run();
}

void initSerial() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
}

void initWifi() {

  // check for the presence of the shield :
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  Serial.print("Attempting to connect to SSID: ");
  Serial.println(ssid);

  // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    // unsuccessful, retry in 4 seconds
    Serial.print("failed ... ");
    delay(4000);
    Serial.print("retrying ... ");
  }

  Serial.println("Connected to wifi");
}



sandeepmistry

Hi @slashy42,

The WINC1500 pins are connected internally to the SAMD21 within the ATSAMW25 module.

See variants/mkr1000/variant.h in the SAMD core for more info:

Code: [Select]

#define WINC1501_RESET_PIN   (30u)
#define WINC1501_CHIP_EN_PIN (31u)
#define WINC1501_INTN_PIN    (33u)
#define WINC1501_SPI         SPI1
#define WINC1501_SPI_CS_PIN  PIN_SPI1_SS


Maybe your issue is not all pins are interrupt enabled? See the attachInterrupt() reference for more info.

Have you tried a sketch with just the Encoder and LCD? It could be the board is running out of RAM as well.

slashy42

#4
Sep 23, 2016, 03:18 pm Last Edit: Sep 23, 2016, 03:24 pm by slashy42
Yep, Encoder and LCD alone work just fine. The only pins that need an interrupt are the encoder's, and they are on pins with interrupts.

Ram had not crossed my mind. Is there an easy way to check for that?

Edit: Forgot to thank you for answering the question about the WiFi pins! That's a big help!

slashy42

I did some more excluding, and it works with the LCD enabled, but not when the encoder is enabled.

Go Up