Gemma v2 does not work in Arduino Sketch

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Ilayda
 
Posts: 3
Joined: Tue May 17, 2022 7:48 am

Gemma v2 does not work in Arduino Sketch

Post by Ilayda »

I recently got the Adafruit Gemma v2 to use in a wearable project. However, although I followed every step in the 'Setting up gemma with Arduino' page, I keep getting an error. For the board I choose Adafruit Gemma and for the programmer; USBTinyISP. The error I get is below:


avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : usb
Using Programmer : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
AVR Part : ATtiny85
Chip Erase delay : 400000 us
PAGEL : P00
BS2 : P00
RESET disposition : possible i/o
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
An error occurred while uploading the sketch
eeprom 65 12 4 0 no 512 4 0 4000 4500 0xff 0xff
flash 65 6 32 0 yes 8192 64 128 30000 30000 0xff 0xff
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00

Programmer Type : USBtiny
Description : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec

avrdude: error: usbtiny_transmit: libusb0-dll:err [control_msg] sending control message failed, win error: A device attached to the system is not functioning.



avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude: error: usbtiny_transmit: libusb0-dll:err [control_msg] sending control message failed, win error: A device attached to the system is not functioning.




avrdude done. Thank you.

User avatar
Ilayda
 
Posts: 3
Joined: Tue May 17, 2022 7:48 am

Re: Gemma v2 does not work in Arduino Sketch

Post by Ilayda »

NVM I figured it out :))

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Gemma v2 does not work in Arduino Sketch

Post by Franklin97355 »

You can help others by telling us what you discovered.

User avatar
Ilayda
 
Posts: 3
Joined: Tue May 17, 2022 7:48 am

Re: Gemma v2 does not work in Arduino Sketch

Post by Ilayda »

Yes of course, basically, I just had to turn my Bluetooth off because it read the serial port as COM 3 instead of USB. Although now my gemma works, I have a problem using the code I obtained from https://learn.adafruit.com/buzzing-mindfulness-bracelet. I assume my circuit is correct because the motor vibrates when I first plug into my PC and I just followed the circuit shown in the Adafruit page, however, once I upload the code to the Gemma nothing happens. Any help would be highly appreciated! Thanks in advance :)
The code is;

Code: Select all

const uint32_t           // These may be the only lines you need to edit...
  onTime   =  2 * 1000L, // Vibration motor run time, in milliseconds
  interval =  60 * 1000; // Time between reminders, in milliseconds
                         // It gets progressively geekier from here...

// Additional power savings can optionally be realized by disabling the
// power-on LED, either by desoldering or by cutting the trace from 3Vo
// on the component side of the board.

// This sketch spends nearly all its time in a low-power sleep state...
#include <avr/power.h>
#include <avr/sleep.h>

// The chip's 'watchdog timer' (WDT) is used to wake up the CPU when needed.
// WDT runs on its own 128 KHz clock source independent of main CPU clock.
// Uncalibrated -- it's "128 KHz-ish" -- thus not reliable for extended
// timekeeping.  To compensate, immediately at startup the WDT is run for
// one maximum-duration cycle (about 8 seconds...ish) while keeping the CPU
// awake, the actual elapsed time is noted and used as a point of reference
// when calculating sleep times.  Still quite sloppy -- the WDT only has a
// max resolution down to 16 ms -- this may drift up to 30 seconds per hour,
// but is an improvement over the 'raw' WDT clock and is adequate for this
// casual, non-medical, non-Mars-landing application.  Alternatives would
// require keeping the CPU awake, draining the battery much quicker.

uint16_t          maxSleepInterval;  // Actual ms in '8-ish sec' WDT interval
volatile uint32_t sleepTime     = 1; // Total milliseconds remaining in sleep
volatile uint16_t sleepInterval = 1; // ms to subtract in current WDT cycle
volatile uint8_t  tablePos      = 0; // Index into WDT configuration table

void setup() {

  // Unused pins can be set to INPUT w/pullup -- most power-efficient state
  pinMode(0, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);

  // LED shenanigans.  Rather that setting pin 1 to an output and using
  // digitalWrite() to turn the LED on or off, the internal pull-up resistor
  // (about 10K) is enabled or disabled, dimly lighting the LED with much
  // less current.
  pinMode(1, INPUT);               // LED off to start

  // AVR peripherals that are NEVER used by the sketch are disabled to save
  // tiny bits of power.  Some have side-effects, don't do this willy-nilly.
  // If using analogWrite() to for different motor levels, timer 0 and/or 1
  // must be enabled -- for power efficiency they could be turned off in the
  // ubersleep() function and re-enabled on wake.
  power_adc_disable();             // Knocks out analogRead()
  power_timer1_disable();          // May knock out analogWrite()
  power_usi_disable();             // Knocks out TinyWire library
  DIDR0 = _BV(AIN1D) | _BV(AIN0D); // Digital input disable on analog pins
  // Timer 0 isn't disabled yet...it's needed for one thing first...

  // The aforementioned watchdog timer calibration...
  uint32_t t = millis();                       // Save start time
  noInterrupts();                              // Timing-critical...
  MCUSR &= ~_BV(WDRF);                         // Watchdog reset flag
  WDTCR  =  _BV(WDCE) | _BV(WDE);              // WDT change enable
  WDTCR  =  _BV(WDIE) | _BV(WDP3) | _BV(WDP0); // 8192-ish ms interval
  interrupts();
  while(sleepTime);                            // Wait for WDT
  maxSleepInterval  = millis() - t;            // Actual ms elapsed
  maxSleepInterval += 64;                      // Egyptian constant
  power_timer0_disable();  // Knocks out millis(), delay(), analogWrite()
}

const uint32_t offTime = interval - onTime; // Duration motor is off, ms

void loop() {
  pinMode(1, INPUT);        // LED off
  ubersleep(offTime);       // Delay while off
}

// WDT timer operates only in specific intervals based on a prescaler.
// CPU wakes on each interval, prescaler is adjusted as needed to pick off
// the longest setting possible on each pass, until requested milliseconds
// have elapsed.
const uint8_t cfg[] PROGMEM = { // WDT config bits for different intervals
  _BV(WDIE) | _BV(WDP3) |                         _BV(WDP0), // ~8192 ms
  _BV(WDIE) | _BV(WDP3)                                    , // ~4096 ms
  _BV(WDIE) |             _BV(WDP2) | _BV(WDP1) | _BV(WDP0), // ~2048 ms
  _BV(WDIE) |             _BV(WDP2) | _BV(WDP1)            , // ~1024 ms
  _BV(WDIE) |             _BV(WDP2) |             _BV(WDP0), //  ~512 ms
  _BV(WDIE) |             _BV(WDP2)                        , //  ~256 ms
  _BV(WDIE) |                         _BV(WDP1) | _BV(WDP0), //  ~128 ms
  _BV(WDIE) |                         _BV(WDP1)            , //   ~64 ms
  _BV(WDIE) |                                     _BV(WDP0), //   ~32 ms
  _BV(WDIE)                                                  //   ~16 ms
}; // Remember, WDT clock is uncalibrated, times are "ish"

void ubersleep(uint32_t ms) {
  if(ms == 0) return;
  tablePos      = 0;                   // Reset WDT config stuff to
  sleepInterval = maxSleepInterval;    // longest interval to start
  configWDT(ms);                       // Set up for requested time
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Deepest sleep mode
  sleep_enable();
  while(sleepTime && (tablePos < sizeof(cfg))) sleep_mode();
  noInterrupts();                      // WDT off (timing critical)...
  MCUSR &= ~_BV(WDRF);
  WDTCR  = 0;
  interrupts();
}

static void configWDT(uint32_t newTime) {
  sleepTime = newTime; // Total sleep time remaining (ms)
  // Find next longest WDT interval that fits within remaining time...
  while(sleepInterval > newTime) {
    sleepInterval /= 2;                          // Each is 1/2 previous
    if(++tablePos >= sizeof(cfg)) return;        // No shorter intervals
  }
  uint8_t bits = pgm_read_byte(&cfg[tablePos]);  // WDT config bits for time
  noInterrupts();                                // Timing-critical...
  MCUSR &= ~_BV(WDRF);
  WDTCR  =  _BV(WDCE) | _BV(WDE);                // WDT change enable
  WDTCR  =  bits;                                // Interrupt + prescale
  interrupts();
}

ISR(WDT_vect) { // Watchdog timeout interrupt
  configWDT(sleepTime - sleepInterval); // Subtract, setup next cycle...
}

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

Return to “Wearables”