Quite expected but unfortunately still not working
According to the blinking of the light, it seems that the gps is working properly, but the problem is with the mp3, which is not ready to say a word
I will publish the full code again and if there is a brave volunteer to explain to me how I convince the stubborn mp3 to talk I would be very happy
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <DFRobot_DF1201S.h>
#define DF1201SSerial Serial
DFRobot_DF1201S DF1201S;
int RXPin = 12;
int TXPin = 13;
TinyGPSPlus gps;
SoftwareSerial SerialGPS(RXPin, TXPin);
double latitude;
double longitude;
int month;
int tens_of_month;
int ones_of_month;
int day;
int ones_of_day;
int tens_of_day;
int year;
int hour;
int ones_of_hour;
int tens_of_hour;
int minutes;
int ones_of_minutes;
int tens_of_minutes;
void tens_and_ones();
void setup() {
SerialGPS.begin(9600);
DF1201SSerial.begin(115200);
DF1201S.setVol(15);
DF1201S.switchFunction(DF1201S.MUSIC);
delay(2000);
}
void loop()
{
while (SerialGPS.available() > 0)
if (gps.encode(SerialGPS.read())){
showData();
Play_a_month(tens_of_month,ones_of_month);
tens_and_ones(tens_of_day,ones_of_day);
playMultipleSongs("clock");
tens_and_ones(tens_of_hour,ones_of_hour);
playMultipleSongs("and");
tens_and_ones(tens_of_minutes,ones_of_minutes);
playMultipleSongs("minute");
}
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println("GPS NOT DETECTED!");
while(true);
}
}
void showData()
{
if (gps.location.isValid())
{
latitude = gps.location.lat();
longitude = gps.location.lng();
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
Serial.print("Altitude: ");
Serial.println(gps.altitude.meters());
}
else
{
Serial.println("Location is not available");
}
Serial.println(gps.satellites.value());
Serial.print("Date: ");
if (gps.date.isValid())
{
month = gps.date.month();
tens_of_month=month/10;
ones_of_month=month%10;
day = gps.date.day();
tens_of_day=day/10;
ones_of_day=day%10;
year = gps.date.year();
Serial.print(day);
Serial.print("/");
Serial.print(month);
Serial.print("/");
Serial.println(year);
}
else
{
Serial.println("Not Available");
}
Serial.print("Time: ");
if (gps.time.isValid())
{
hour = gps.time.hour()+2;
ones_of_hour=hour%10;
tens_of_hour=hour/10;
minutes = gps.time.minute();
ones_of_minutes=minutes%10;
tens_of_minutes=minutes/10;
if (hour < 10) Serial.print(F("0"));
Serial.print(hour);
Serial.print(":");
if (minutes < 10) Serial.print(F("0"));
Serial.print(minutes);
Serial.print(":");
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(".");
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.println(gps.time.centisecond());
}
else
{
Serial.println("Not Available");
}
Serial.println();
Serial.println();
delay(5000);
}
void Play_a_month(int dozens,int units){
switch (dozens) {
case 0:
if (units==1) {
playMultipleSongs("January");
} else if (units==2) {
playMultipleSongs("February");
}
else if (units==3) {
playMultipleSongs("March");
} else if (units==4) {
playMultipleSongs("April");
}
else if (units==5) {
playMultipleSongs("May");
} else if (units==6) {
playMultipleSongs("June");
}
else if (units==7) {
playMultipleSongs("July");
} else if (units==8) {
playMultipleSongs("August");
}
else if (units==9) {
playMultipleSongs("September");
}
break;
case 1:
if (units==0) {
playMultipleSongs("October");
}
else if (units==1) {
playMultipleSongs("November");
} else if (units==2) {
playMultipleSongs("December");
}
break;
}
}
void tens_and_ones(int tens, int ones){
switch (tens) {
case 0:
if (ones==1) {
playMultipleSongs("One");
} else if (ones==2) {
playMultipleSongs("Two");
}
else if (ones==3) {
playMultipleSongs("Three");
} else if (ones==4) {
playMultipleSongs("Four");
}
else if (ones==5) {
playMultipleSongs("Five");
} else if (ones==6) {
playMultipleSongs("Six");
}
else if (ones==7) {
playMultipleSongs("Seven");
} else if (ones==8) {
playMultipleSongs("Eight");
}
else if (ones==9) {
playMultipleSongs("Nine");
}
break;
case 1:
if (ones==0) {
playMultipleSongs("Ten");
}
else if (ones==1) {
playMultipleSongs("Eleven");
} else if (ones==2) {
playMultipleSongs("Twelve");
}
else if (ones==3) {
playMultipleSongs("Thirteen");
} else if (ones==4) {
playMultipleSongs("Fourteen");
}
else if (ones==5) {
playMultipleSongs("Fifteen");
} else if (ones==6) {
playMultipleSongs("Sixteen");
}
else if (ones==7) {
playMultipleSongs("17");
} else if (ones==8) {
playMultipleSongs("Eighteen");
}
else if (ones==9) {
playMultipleSongs("Nineteen");
}
break;
case 2:
playMultipleSongs("Twenty");
break;
case 3:
playMultipleSongs("Thirty");
break;
case 4:
playMultipleSongs("Fourty");
break;
case 5:
playMultipleSongs("Fifty");
break;
case 6:
playMultipleSongs("Sixty");
break;
case 7:
playMultipleSongs("Seventy");
break;
case 8:
playMultipleSongs("Eighty");
break;
case 9:
playMultipleSongs("Ninety");
break;
}
if (tens == 2 ||tens == 3 || tens == 4 || tens == 5 || tens == 6 ||tens == 7 || tens == 8 || tens == 9){
switch (ones) {
case 1:
playMultipleSongs("One");
break;
case 2:
playMultipleSongs("Two");
break;
case 3:
playMultipleSongs("Three");
break;
case 4:
playMultipleSongs("Four");
break;
case 5:
playMultipleSongs("Five");
break;
case 6:
playMultipleSongs("Six");
break;
case 7:
playMultipleSongs("Seven");
break;
case 8:
playMultipleSongs("Eight");
break;
case 9:
playMultipleSongs("Nine");
break;
}
}
}
void playMultipleSongs(String songName) {
String newSongName = "/"+ songName + ".mp3";
DF1201S.playSpecFile(newSongName);
Serial.println(newSongName);
delay(1500);
}
try add the line to setup()
DF1201S.begin(DF1201SSerial);
this way:
void setup() {
SerialGPS.begin(9600);
DF1201SSerial.begin(115200);
DF1201S.begin(DF1201SSerial);
delay(500);
DF1201S.setVol(15);
DF1201S.switchFunction(DF1201S.MUSIC);
delay(2000);
}
By the way - do you tested your MP3 before ? Is it works?
Yes, I tried all the components and they work great. Updated as of an hour ago..
Wow!!! It seems to work well! It's late here now and I'm going to bed so I'll check thoroughly tomorrow. Anyway, thank you very much for all your efforts today to solve my problem!
My congratulations
Sounds like you and I are in close time zones
Please do not forget to leave the feedback when you tested the code thoroughly and mark the thread as solved.
Good luck!
Now the mp3 and the gps work together, which is excellent progress for me, but for some reason, every time at the end of the loop, there is a current jump (pulse) that can be heard in the speakers, and this causes the exit of the entire program and a new restart of the setup, which is not desirable (every time the mp3 is initialized in the setup, it plays a generic message of "music").
?What could be the reason and how can it be solved
I checked the connections of the wires and they seem to be tightened properly.
I am attaching a video and at the end you can hear the jump of the current and the annoying restart of the "music".
https://drive.google.com/file/d/1rbcY0iZxoMYX29oUNnWJ_zXIslM81Mzj/view?usp=share_link
Please show you FULL code.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <DFRobot_DF1201S.h>
#define DF1201SSerial Serial
DFRobot_DF1201S DF1201S;
int RXPin = 12;
int TXPin = 13;
TinyGPSPlus gps;
SoftwareSerial SerialGPS(RXPin, TXPin);
double latitude;
double longitude;
int month;
int tens_of_month;
int ones_of_month;
int day;
int ones_of_day;
int tens_of_day;
int year;
int hour;
int ones_of_hour;
int tens_of_hour;
int minutes;
int ones_of_minutes;
int tens_of_minutes;
void tens_and_ones();
void setup() {
SerialGPS.begin(9600);
DF1201SSerial.begin(115200);
DF1201S.begin(DF1201SSerial);
DF1201S.setVol(10);
DF1201S.switchFunction(DF1201S.MUSIC);
delay(2000);
}
void loop()
{
while (SerialGPS.available() > 0)
if (gps.encode(SerialGPS.read())){
showData();
playMultipleSongs("clock");
tens_and_ones(tens_of_hour,ones_of_hour);
playMultipleSongs("and");
tens_and_ones(tens_of_minutes,ones_of_minutes);
playMultipleSongs("minute");
Play_a_month(tens_of_month,ones_of_month);
tens_and_ones(tens_of_day,ones_of_day);
playMultipleSongs("2023");
}
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println("GPS NOT DETECTED!");
while(true);
}
}
void showData()
{
if (gps.location.isValid())
{
latitude = gps.location.lat();
longitude = gps.location.lng();
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
Serial.print("Altitude: ");
Serial.println(gps.altitude.meters());
}
else
{
Serial.println("Location is not available");
}
Serial.println(gps.satellites.value());
Serial.print("Date: ");
if (gps.date.isValid())
{
month = gps.date.month();
tens_of_month=month/10;
ones_of_month=month%10;
day = gps.date.day();
tens_of_day=day/10;
ones_of_day=day%10;
year = gps.date.year();
Serial.print(day);
Serial.print("/");
Serial.print(month);
Serial.print("/");
Serial.println(year);
}
else
{
Serial.println("Not Available");
}
Serial.print("Time: ");
if (gps.time.isValid())
{
hour = gps.time.hour()+2;
ones_of_hour=hour%10;
tens_of_hour=hour/10;
minutes = gps.time.minute();
ones_of_minutes=minutes%10;
tens_of_minutes=minutes/10;
if (hour < 10) Serial.print(F("0"));
Serial.print(hour);
Serial.print(":");
if (minutes < 10) Serial.print(F("0"));
Serial.print(minutes);
Serial.print(":");
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(".");
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.println(gps.time.centisecond());
}
else
{
Serial.println("Not Available");
}
Serial.println();
Serial.println();
delay(5000);
}
void Play_a_month(int dozens,int units){
switch (dozens) {
case 0:
if (units==1) {
playMultipleSongs("January");
} else if (units==2) {
playMultipleSongs("February");
}
else if (units==3) {
playMultipleSongs("March");
} else if (units==4) {
playMultipleSongs("April");
}
else if (units==5) {
playMultipleSongs("May");
} else if (units==6) {
playMultipleSongs("June");
}
else if (units==7) {
playMultipleSongs("July");
} else if (units==8) {
playMultipleSongs("August");
}
else if (units==9) {
playMultipleSongs("September");
}
break;
case 1:
if (units==0) {
playMultipleSongs("October");
}
else if (units==1) {
playMultipleSongs("November");
} else if (units==2) {
playMultipleSongs("December");
}
break;
}
}
void tens_and_ones(int tens, int ones){
switch (tens) {
case 0:
if (ones==1) {
playMultipleSongs("One");
} else if (ones==2) {
playMultipleSongs("Two");
}
else if (ones==3) {
playMultipleSongs("Three");
} else if (ones==4) {
playMultipleSongs("Four");
}
else if (ones==5) {
playMultipleSongs("Five");
} else if (ones==6) {
playMultipleSongs("Six");
}
else if (ones==7) {
playMultipleSongs("Seven");
} else if (ones==8) {
playMultipleSongs("Eight");
}
else if (ones==9) {
playMultipleSongs("Nine");
}
break;
case 1:
if (ones==0) {
playMultipleSongs("Ten");
}
else if (ones==1) {
playMultipleSongs("Eleven");
} else if (ones==2) {
playMultipleSongs("Twelve");
}
else if (ones==3) {
playMultipleSongs("Thirteen");
} else if (ones==4) {
playMultipleSongs("Fourteen");
}
else if (ones==5) {
playMultipleSongs("Fifteen");
} else if (ones==6) {
playMultipleSongs("Sixteen");
}
else if (ones==7) {
playMultipleSongs("17");
} else if (ones==8) {
playMultipleSongs("Eighteen");
}
else if (ones==9) {
playMultipleSongs("Nineteen");
}
break;
case 2:
playMultipleSongs("Twenty");
break;
case 3:
playMultipleSongs("Thirty");
break;
case 4:
playMultipleSongs("Fourty");
break;
case 5:
playMultipleSongs("Fifty");
break;
case 6:
playMultipleSongs("Sixty");
break;
case 7:
playMultipleSongs("Seventy");
break;
case 8:
playMultipleSongs("Eighty");
break;
case 9:
playMultipleSongs("Ninety");
break;
}
if (tens == 2 ||tens == 3 || tens == 4 || tens == 5 || tens == 6 ||tens == 7 || tens == 8 || tens == 9){
switch (ones) {
case 1:
playMultipleSongs("One");
break;
case 2:
playMultipleSongs("Two");
break;
case 3:
playMultipleSongs("Three");
break;
case 4:
playMultipleSongs("Four");
break;
case 5:
playMultipleSongs("Five");
break;
case 6:
playMultipleSongs("Six");
break;
case 7:
playMultipleSongs("Seven");
break;
case 8:
playMultipleSongs("Eight");
break;
case 9:
playMultipleSongs("Nine");
break;
}
}
}
void playMultipleSongs(String songName) {
String newSongName = "/"+ songName + ".mp3";
DF1201S.playSpecFile(newSongName);
Serial.println(newSongName);
delay(1700);
}
Immediately after the execution of this command there is an initialization from the "setup":playMultipleSongs("2023");
Is the file "2023.mp3" exists on SD?
Try (for testing purpose) to replace it with:
I noticed another problem: sometimes as soon as I connect the Arduino to a power source (already after the program has been uploaded) it does not play what is needed but repeats in a "loop" playing a silent sound of "nothing" (the mp3 plays a silent recording) and this happens until I am forced to Press several times the "restart" button on the Arduino or alternatively disconnect the Arduino from the power source and reconnect/press the mp3 refresh button.
It exists and you can also hear it in the video I attached...
Can it be a power problems? What the power supply is used, and how it connected to the boards and modules?
You may be right, now it doesn't cause problems anymore but it's a problem that comes and goes from what I've noticed so I guess it's not a code problem.
I sometimes connect it to the computer or the wall with a cell phone charger voltage 5v and current 1A.
I don't see a difference in the results between the 2
On your schematic I see a two DC-DC power converters. What are they powered? Do you use any modules, that needs the power voltage other than 5v? How they are powered?
With this project using motors, a better power supply may be needed and or better Vcc filtering.
OK, so I'll expand a little:
I am an electronics student and work as a hobby on my own project of building a platform for the blind.
This is a device with several auxiliary functions for the blind, the functions are:
❖ Playing the local time and date aloud, this part is based on a GPS sensor, the date and time are information obtained by satellite calculations.
❖ Alert on approaching the location of bus stops or any other predefined location. The alert will be received with increasing beeps as the approach to the location increases. In addition, when approaching the predefined distance, vibration motors will be activated as a warning.
❖ Measuring distance from objects and playing the distance out loud.
❖ Identifying colors of different objects (yes, even the blind are interested in the color of the shirt they chose today to color), the identified color is played aloud.
The voice playback option will be through a speaker or by connecting to headphones (however, it is not pleasant to walk with a loud device on the street...)
Playback will not take place all the time except when the operator touches the TOUCH sensor that will be installed.
The platform is based on the ARDUINO NANO controller and additional sensors that are suitable for each of the functions.
The selection of each of the options will be by pressing one of 4 buttons, next to each button there is an LED light that will light up when the particular function is selected (currently the LEDs are not intended for the blind but for wide use by sighted people as well).
My components in the project consist of: color - TCS3200 color sensor, distance - HC-04 ultrasonic sensor, time and date location - GY NEO6 GPS module, tiny vibration motors, LEDs to indicate the selected function, MP3 module to store all voice recordings, speaker to play all parameters, TOCH sensor for playback timing, voltage stabilizers of 5 volts and 3.3 volts, at the moment it seems that I will only use a voltage of 5 volts but I leave the option of a voltage of 3.3 open).
I plan to put it all on a pcb board in the end to avoid all the massive wire clutter.
I'm still not sure about my power source and I would appreciate it if you could help me figure out which power source I need for the project, whether alkaline batteries 1.5v*4 or any lipo batteries with a voltage higher than 5 volts. The connection of the power source will be by wires that will be connected to a screw terminal.
At the moment I feed the power through the computer or through a cell phone charger connected to the wall but the ultimate goal is for the platform to be mobile.
Which power supply/battery would you recommend me to choose? (Of course, a rechargeable battery is preferred)
Can anyone help me figure out what would be the best power supply/battery for me in the cute project I presented?
Is the choice of linear voltage stabilizers correct in my project or perhaps switching stabilizers, or any other dc-dc voltage converter?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.