3

I want to use the Arduino IDE serial monitor with my Digispark ATtiny85 over USB.

I can without problems upload this code(Digispark CDC example):

#include <DigiCDC.h>
void setup() {                
  SerialUSB.begin(); 
}
void loop() {  
  SerialUSB.println(F("TEST!"));
 //SerialUSB.delay(10);
}

In a terminal, I can confirm, that it indeed creates a new devise:

ll /dev/*usb*
crw-rw-rw-  1 root  wheel   21,  89 27 Sep 10:36 /dev/cu.usbmodem1411
crw-rw-rw-  1 root  wheel   21,  88 27 Sep 10:36 /dev/tty.usbmodem1411

When trying to start the Arduino serial monitor, I get the error:

 Error opening serial port '/dev/cu.usbmodem1411'. (Port busy)

I have confirmed that there are no open files or processes using the USB port. I have the same problem trying to use cu or screen in the terminal.

I have googled the problem, and found that several people has the same problem on new mac computers, but I have not been able to find a solution. -any ideas?

  • Digispark Rev3 (Chinese clone - with bootloader firmware 1.6 (1.06))
  • Arduino IDE 1.8.7
  • Mac OSX High Sierra 10.13.6
hpekristiansen
  • 201
  • 1
  • 11
  • I don't know about OS X, but I do know that the ATTiny85 doesn't have a USB interface - so it's all done in software. TBH you're lucky it gets as far as it does. I have never been a fan of bit-banged USB like that. It's nasty. – Majenko Sep 27 '18 at 09:19
  • @Majenko I can use the Digispark as a USB HID keyboard, so the banging of the bits do work :o) – hpekristiansen Sep 27 '18 at 10:25
  • You can only bit-bang low-speed USB. Low-speed is only intended for use with keyboard and mouse. CDC/ACM really requires full- or high-speed, so trying to use it over low-speed is "undefined". – Majenko Sep 27 '18 at 10:26
  • @Majenko: I appreciate the support. I would be happy with any low speed way of sending a string from my computer to the Digispark. If it is not possible, do you know of a chip, that I can add to the ATtiny85 to give it hardware USB? – hpekristiansen Sep 27 '18 at 15:11
  • Unfortunately, it's a known [issue](https://github.com/digistump/DigistumpArduino/issues/41) on mac os that has no solution at the moment. [digiUSB](https://github.com/digistump/DigisparkExamplePrograms/tree/master/Python/DigiUSB) is mentioned on one forum as a workaround. However, sending and receiving is done via python scripts with this method of communication. If you want hardware USB in the same board format, you can try ATMega32U4-based "beetle" boards available for ~5 USD on ebay. – ex-punctis Sep 27 '18 at 19:42
  • Don't use `DigiUSB`! It's deprecated using old *usblib0* (new is `libusb-1.0`) and the highly dysfunctional `libusb-win32`. Also if you use that, you have to be careful not to overwrite the internal V-USB, perhaps by disabling your own after some time. Apparently DigiCDC is the followup of that. – not2qubit Jan 24 '19 at 17:57
  • @not2qubit: I do not understand. What is `DigiUSB`? How am I using it? Actually I do not understand what you are writing at all. What am I doing wrong, and what can I do instead? – hpekristiansen Jan 24 '19 at 21:44
  • From [DigiUSB](https://digistump.com/wiki/digispark/tutorials/digiusb): `This library has been deprecated in favour of:` [DigiCDC](https://digistump.com/wiki/digispark/tutorials/digicdc). `With DigiCDC the Digispark will show up as a COM port and the Arduino Serial monitor can be used normally. DigiUSB requires communication to the Digispark through a seperate application.` – not2qubit Feb 01 '19 at 13:05
  • @not2qubit: Ok - I have now come to the conclusion, that you have not read my question at all, and you have no idea about the problem on a mac. – hpekristiansen Feb 01 '19 at 17:54
  • Oh, sorry, I was merely responding to the comments above. Do you have `lsof` on the mac? If so try `lsof |grep "/dev/cu.usbmodem1411"`. It should in theory show you what process is using that device. You can also try various options to `ps`. – not2qubit Feb 01 '19 at 20:45

1 Answers1

1

SoftSerial and a real serial port on the mac will work. Or if you are careful use the DigiKeyboard and print the debug to the HID keyboard REMEMBERING to switch to a notepad equivalent window on the mac to receive and display the debugging text and not have it overwriting the arduino sketch by mistake. DigiCDC is a kludge that does not work properly on modern operating systems sorry!

  • Thanks for your input, but I do not understand what you mean by " ...a real serial port on the mac ..."? Do you mean something like this https://plugable.com/2011/07/12/installing-a-usb-serial-adapter-on-mac-os-x/ ?What debug are you referring to? HID works perfectly, but I want serial communication from and *to* the Digispark. – hpekristiansen Oct 16 '18 at 15:26
  • presumably no modern Mac has a builtin RS232 interface so you'd need a USB to RS232 interface yes like in that article you link to. There are a few common chips that are used in the devices PL2303, CH340/CH341, FT232RL and so on. There is a software serial emulation library that works on the Attiny85 digispark boards and uses 1 or 2 or the IO pins obviously there are certain limitations with software emulation but it does work adequately. Serial is often used to output debugging messages with arduinos when developing sketches. – tech-head-uk Oct 17 '18 at 22:54