Seesaw blink works with 32u4 but not m0

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Hey guys

I’ve got a puzzler for you.

If I run the seesaw digital blink example with it attached to a feather 32u4, the seesaw pin toggles between 0v and 3.3v as expected.


When I use a feather M0 board, pin 15 will only toggle from 0v to 3.3v if the serial port is open. If the serial port is closed, pin 15 sits at 2.8v and doesn’t toggle.

I added two lines to have the M0 pin 13 led turn on and off in sync with the seesaw pin just to ensure the code was still running without the serial window, the M0 led blinks but the seesaw pin sits at 2.8v.

Why would the M0 require the serial port to be open to toggle the seesaw pin and the 32u4 would not?

I have video of this occurring if it would help diagnose.

I’ll attach a screenshot of the code below.
B4B79677-CDCE-4824-9734-5CB32526B50A.jpeg
B4B79677-CDCE-4824-9734-5CB32526B50A.jpeg (630.52 KiB) Viewed 107 times

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Here's a video of what I'm seeing with the M0 board:

https://youtu.be/9x-Kx6plpBY

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

With all the other items attached, it could be something else. Can you recreate this issue with a very simple breadboard setup that is nothing but the Feather M0 and seesaw breakout?

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Same issue with only seesaw and M0 attached. I used the Adafruit example code with a digital blink and only the M0 and seesaw wired up. The pin only toggles when the serial window is open. With the 32u4 it operates find whether the serial window is open or closed.

I worked with some guys on the discord chat and it seems the seesaw library has a bug when trying to work with the M0 board.

The work around solution is to change all serial commands to serial1.begin.

If the serial commands are completely removed or the serial window isn’t open when serial commands exist, the seesaw board doesn’t work with the M0.

Switching all serial commands to serial1 allows the seesaw to function without a serial window open as expected so I could power the board from the wall or battery.

Appears the backend code needs a little adjustment. At least the Adafruit discord guys were able to find a work around. :)

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

Can you post a photo of your simple breadboard setup. Also paste in the code listing for the sketch you are running. We can try and recreate it here.

Since seesaw uses I2C, it seems odd that serial would play into it. The "only works with serial open" behavior is usually when there is a while(!Serial) in begin(). But that doesn't appear to the case here though.

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Sure,

I'm basically using the seesaw digital blink example code:

Code: Select all

/*
/*
 * This example shows how to blink a pin on a seesaw.
 * Attach the positive (longer lead) of the LED to pin 15 on the seesaw, and
 * the negative lead of the LED to ground through a 1k ohm resistor.
 */

#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

void setup() {
  Serial.begin(9600);
  delay(5000);
  if(!ss.begin(0x4c)){
    Serial.println("ERROR!");
    while(1);
  }
  else Serial.println("seesaw started");

  ss.pinMode(15, OUTPUT);
  pinMode(13,OUTPUT);
}

void loop() {
  ss.digitalWrite(15, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(13,HIGH);
  delay(1000);                       // wait for a second
  ss.digitalWrite(15, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(13,LOW);
  delay(1000);  
}
}

So testing it again, things I noticed.

I add the delay(5000); to give myself enough time to start the serial window so I can see the SEESAW STARTED code.

1. Without the delay, if you don't see the SEESAW started because you open the serial window late, the seesaw board pin 15 does NOT toggle.
2. If you open the serial window BEFORE it serial prints SEESAW STARTED, the seesaw pin 15 operates as normal.
3. To confirm that the code is running the LOOP and not stuck initializing the seesaw with the serial window closed, I have it blink the pin 13 led. I also see that the red light on the seesaw blinks when it initializes properly. So I know that step works.

I'll post a picture of the circuit below off my phone, but the pins are as follows:

Feather M0 Pin Seesaw Pin
3V Vin
GND G
SCL 23
SDA 22
16 + 17 ->GND
15 ->open wire to hook to volt meter

open ground wire to hook to negative terminal of volt meter.

Picture posted in a minute.
Attachments
seesaw.jpg
seesaw.jpg (125.86 KiB) Viewed 98 times

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

Thanks. I've got that setup here and it generally seems to be running OK. The serial monitor is *not* open. After 5 seconds, the red LED on the Feather blinks. I've got a multimeter on the seesaw pin 15 and it registers the voltage change.

If I understand correctly, for you that blinks the Feather LED but nothing appears to happen on the seesaw? But if you open the serial monitor, then it starts working?

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

You got it.

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

https://youtu.be/T8iS2zVtJbI

Here’s a better video showing how I create the issue.

That being said, how would I know if the seesaw library had an update? Maybe mine is down level and it’s been fixed or something ?

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

Thanks for the video - very useful.

The way you are running this, there may be a race condition. Since you are unplugging the USB cable from the PC, you are powering down the entire setup. Then, when you plug it back in, both the Feather and the seesaw receive power and come up. So the Feather sketch may be talking to the seesaw before the seesaw is ready. I'd think that would happen with the second test with the serial monitor also. So not entirely sure.

Try these tests:
(1) Leave the USB cable plugged in. Leave serial monitor closed. Upload the sketch, which will push the code and do a software reset of the Feather. Does the seesaw pin still not change?

(2) Leave USB cable plugged in. Press reset on the seesaw board. Repeat the above. Does the seesaw pin still not change?

In terms of getting version info, you can use the getVersion() function. Here's a sketch that decodes and prints the info you can run:

Code: Select all

#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

void setup() {
  Serial.begin(9600);

  while (!Serial);
  
  if(!ss.begin(0x4c)){
    Serial.println("ERROR!");
    while(1);
  }
  else Serial.println("Seesaw Version Info");
 
  uint32_t version = ss.getVersion();
  
  uint16_t datecode = version & 0xFFFF;
  uint16_t product_id = (version >> 16) & 0xFFFF;

  uint8_t year = (datecode >> 9) & 0x7F;   // upper 7 bits
  uint8_t month = (datecode >> 5) & 0x0F;  // middle 4 bits
  uint8_t day = datecode & 0x1F;           // lower 5 bits
  
  Serial.print("Product ID = "); Serial.println(product_id);
  Serial.print("Year = "); Serial.println(year);
  Serial.print("Month = "); Serial.println(month);
  Serial.print("Day = "); Serial.println(day);
}

void loop() {
  // do nothing
}
When I run it, I get this:
Screenshot from 2020-05-05 15-23-13.png
Screenshot from 2020-05-05 15-23-13.png (16.86 KiB) Viewed 96 times

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Both when I push code and when I reset the seesaw result in no pin toggling.

Version shows the same as yours.

So very strange. :/

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

I worked with some guys on the discord chat and it seems the seesaw library has a bug when trying to work with the M0 board.
Can you provide more info on what the theory was here?

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

If you have access to discord, the part where we altered the serial port was in the help with Arduino room yesterday at 2:28pm between me (Jim) and Nis. It was a good hour long convo, but 2:28pm is where he finds the work around.


Basically we switched from serial to serial1 so the M0 could print whatever it wants and isn’t waiting on the usb serial connection. Pin toggles whether plugged into pc, wall usb, or battery. Works every time.

Funny thing is the 32u4 works with the code as I sent it to you whether the serial window is open or not. Something about the m0.

User avatar
Jim2386
 
Posts: 285
Joined: Fri Nov 14, 2014 11:58 pm

Re: Seesaw blink works with 32u4 but not m0

Post by Jim2386 »

Could the back end example library have been changed? Like the seesaw.h file....or one of the files the compiler drags in?

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seesaw blink works with 32u4 but not m0

Post by adafruit_support_carter »

OK, thanks. I think I have found it in the scroll back. I'll give it a read.

Out of curiosity - how are you planning to use the seesaw breakout?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”