Author Topic: Digispark and Woes  (Read 5181 times)

evapilot01

  • Newbie
  • *
  • Posts: 3
Digispark and Woes
« on: September 03, 2016, 07:30:35 am »
First of lets set the tone. I LOVE DIGISPARK!
Its tiny, It can run off a usb power bank, Its all I really need.

That being said. I am currently stumped (haha pun not intended).

Here is my understanding. Digispark does not use the SoftwareSerial.h, Instead it uses SoftSerial.h instead.
I am trying to link the digispark to a DFPlayer. Specifically I want to do this

Press button once, Play sound 1
Press button twice, Play sound 2
Press button trice, play sound 3

DF Player command library requires the use of the SoftwareSerial.h

Has anyone manage to get these two to work together? I tried searching online for 2 days. Cant find a thing.

RC Navy

  • Jr. Member
  • **
  • Posts: 54
  • When you like, even too much, it is not enough!
Re: Digispark and Woes
« Reply #1 on: September 03, 2016, 09:33:46 am »
Hi,

if you are using the DFRobot library, https://github.com/DFRobot/DFPlayer-Mini-mp3, you shall use either HardwareSerial (eg Serial) either SoftwareSerial.
Digispark CAN use SoftwareSerial.
SoftSerial is equivalent to SoftwareSerial but SoftSerial shares the "pin change interrupt vector" of the AVR. This allows to use simultaneously a software serial port and pin change interrupt to catch events on the pins. This is impossible with SoftwareSerial.
Currently the DFRobot DFPlayer library doesn't support SoftSerial.
However, it's not so difficult to add this support to DFPlayer.

Regards,

evapilot01

  • Newbie
  • *
  • Posts: 3
Re: Digispark and Woes
« Reply #2 on: September 03, 2016, 10:07:49 am »
Thanks RC Navy,

I hope you dont mind. Would you mind running me through how to either
a) get the softwareserial to work properly on my project/find out what i am doing wrong
b) config the DF Player to work.

I know its asking a lot but I have tried changing one thing after another and it doesnt seem to work

(I am very new to arduino this is my first project and I am while excited. Totally lost on what I am doing)

So far this is what I have done.



/*
 * Copyright: DFRobot
 * name:  DFPlayer_Mini_Mp3 sample code
 * Author:  lisper
 * Date:  2014-05-30
 * Description: sample code for DFPlayer Mini, this code is test on Uno
 *   note: mp3 file must put into mp3 folder in your tf card
 */
 
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
 
void setup () {
 Serial.begin (9600);
 mp3_set_serial (Serial); //set Serial for DFPlayer-mini mp3 module
 mp3_set_volume (10);
}
 
void loop () {       
 
 mp3_play (1); //play 0001.mp3
 delay (10000); //10 sec, time delay to allow 0001.mp3 to finish playing
 
 mp3_play (2);
 delay (5000);
 
 mp3_play (3);
 delay (5000);
 
}

I get this error






In file included from C:\Users\EvaPilot01\Documents\Arduino\DFPlayer\DFPlayer.ino:13:0:

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:78:22: error: variable or field 'mp3_set_serial' declared void

 void mp3_set_serial (HardSerial &theSerial);

                      ^

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:78:22: error: 'HardSerial' was not declared in this scope

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:78:34: error: 'theSerial' was not declared in this scope

 void mp3_set_serial (HardSerial &theSerial);

                                  ^

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:81:22: error: variable or field 'mp3_set_serial' declared void

 void mp3_set_serial (SoftSerial &theSerial);

                      ^

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:81:22: error: 'SoftSerial' was not declared in this scope

C:\Program Files (x86)\Arduino\libraries\DFPlayer_Mini_Mp3/DFPlayer_Mini_Mp3.h:81:34: error: 'theSerial' was not declared in this scope

 void mp3_set_serial (SoftSerial &theSerial);

                                  ^

C:\Users\EvaPilot01\Documents\Arduino\DFPlayer\DFPlayer.ino: In function 'void setup()':

DFPlayer:17: error: 'mp3_set_serial' was not declared in this scope

  mp3_set_serial (Serial); //set Serial for DFPlayer-mini mp3 module

                        ^

exit status 1
'mp3_set_serial' was not declared in this scope


RC Navy

  • Jr. Member
  • **
  • Posts: 54
  • When you like, even too much, it is not enough!
Re: Digispark and Woes
« Reply #3 on: September 04, 2016, 05:08:59 am »
Hi evapilot01,

I have added the support of SoftSerial to the DFRobot_Mini_Mp3 library.
You can find it here: https://github.com/RC-Navy/DigisparkArduinoIntegration/tree/master/libraries/DFPlayer_Mini_Mp3

Now, DFRobot_Mini_Mp3 library supports transparently, HardwareSerial, SoftwareSerial and SoftSerial because this version of library uses the concept of stream. So, any serial object implementing the "Stream" class can be used.

There is an example for the SoftSerial of the Digispark here: https://github.com/RC-Navy/DigisparkArduinoIntegration/blob/master/libraries/DFPlayer_Mini_Mp3/examples/DFPlayer_DigisparkSoftSerial/DFPlayer_DigisparkSoftSerial.ino
It compiles fine, but not tested: up to you!

Remember to replace the DFRobot_Mini_Mp3 library in your arduino IDE by this version https://github.com/RC-Navy/DigisparkArduinoIntegration/tree/master/libraries/DFPlayer_Mini_Mp3 .

Regards,
« Last Edit: September 04, 2016, 05:11:18 am by RC Navy »

evapilot01

  • Newbie
  • *
  • Posts: 3
Re: Digispark and Woes
« Reply #4 on: September 04, 2016, 08:30:59 am »
OMG. Thank you so much. I will dig through the modded file to learn what you have done. It is definitely appreciated with many many thanks.


RC Navy

  • Jr. Member
  • **
  • Posts: 54
  • When you like, even too much, it is not enough!
Re: Digispark and Woes
« Reply #5 on: September 04, 2016, 12:26:28 pm »
Hi evapilot01,

You're welcome. ;)
Did you succeed to compile and make the DFPlayer_Mini_Mp3 library work with Digispark?