To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Today we tried to solve the issue we had last week to make the DFplayer work with the ESP32:
following this tutorial : (8650) DFPlayer Mini Interface with ESP32: Audio Playback Tutorial | Add voice to ESP32 - YouTube
here is the code from the video:
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 25; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 27; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
// Create the Player object
DFRobotDFPlayerMini player;
void setup() {
// Init USB serial port for debugging
Serial.begin(9600);
// Init serial port for DFPlayer Mini
softwareSerial.begin(9600);
// Start communication with DFPlayer Mini
if (player.begin(softwareSerial)) {
Serial.println("OK");
// Set volume to maximum (0 to 30).
player.volume(20);
// Play the first MP3 file on the SD card
player.play(1);
} else {
Serial.println("Connecting to DFPlayer Mini failed!");
}
}
void loop() {
}
However, I get an error message :
#include "DFRobotDFPlayerMini.h"
DFRobotDFPlayerMini player; // Create the Player object
void setup() {
Serial.begin(9600); // Init USB serial port for debugging
Serial2.begin(9600); // Init serial port for DFPlayer Mini
// Start communication with DFPlayer Mini
Serial.println("Connecting to DFplayer");
while (!player.begin(Serial2))
{
Serial.print(".");
delay(1000);
}
Serial.println(" DFplayer connected!");
player.volume(20); // Set volume to maximum (0 to 30).
}
void loop() {
player.play(1);
delay(3000);
player.play(2);
delay(3000);
player.play(3);
delay(3000);
}
but I get the same error message.
SO, I tried another code from another source :
#include <DFPlayer_Mini_Mp3.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
SoftwareSerial mySerial(25, 27); // RX, TX
void setup() {
mySerial.begin(9600);
mp3_set_serial(mySerial);
mp3_set_volume(15); // fixe le son (30 maximum)
mp3_set_EQ(0); // equalizer de 0 Ã 5
}
void loop() {
mp3_play(); // joue mp3/0001.mp3
delay(5000); // pause de 5 secondes
}
and another one:
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
SoftwareSerial mySerial(25, 27); // RX, TX
//
void setup () {
Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial); //set softwareSerial for DFPlayer-mini mp3 module
mp3_set_volume (15);
}
//
void loop () {
mp3_play (1);
delay (6000);
mp3_next ();
delay (6000);
}
However, the libraries involved might only work for Arduino and give this type of error message with the ESP32:
Then, I tried reinstalling the libraries, re-setting up the ESP32, and did all the updates.
But nothing works I still get this error message:
DEBRIEF :
I still have the same error message, the ESP32 set-up does not seem faulty, the last 2 libraries don't work for ESP32, something is still not clear in the first 2 codes
We also worked on the design of the ball and made a paper prototype to make sure that the dimensions are right and the ball would be nice looking.
We are still hesitating about the final material we'll use for the final version (either leather or cardboard with fabric covering it).
Today, we received our whole order:
We decided not to order the cable so that we could create our own, with the voltage and length desired.
(the box was too fancy not to show it so enjoy)
We also tried to modelise the circuit of this video : https://www.youtube.com/watch?v=9w_AaIwlsE4 with this website https://wokwi.com/projects/new/esp32 .
However, it did not work as there is no MP3 dfplayer, so we tried the ESP32 we used in the first semester but they were all over heating, so we tried to de-soulder them.
Today, we did the final bill of materials and this it was we ordered under our budget:
We mostly ordered our components on Mouser and Gotronic.
Today, we checked different ways of putting sound into the M8B.
We started to simulate it.
We also started the list of components, but we changed a lot and took a long time to find the easiest to connect components so we haven't finished it.
This is what we did today:
Today we finally managed to correct the code and ensure that when we shake the gyroscope, text appears on the screen:
#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <LiquidCrystal.h>
Adafruit_MPU6050 mpu;
const int rs = 15;
const int en = 13;
const int d4 = 32;
const int d5 = 33;
const int d6 = 25;
const int d7 = 26;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println("Adafruit MPU6050 test!");
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
Serial.print("Accelerometer range set to: ");
switch (mpu.getAccelerometerRange()) {
case MPU6050_RANGE_2_G:
Serial.println("+-2G");
break;
case MPU6050_RANGE_4_G:
Serial.println("+-4G");
break;
case MPU6050_RANGE_8_G:
Serial.println("+-8G");
break;
case MPU6050_RANGE_16_G:
Serial.println("+-16G");
break;
}
lcd.begin(8, 2);
Serial.begin(115200);
lcd.clear();
}
void loop() {
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
Serial.print("Acceleration X: ");
Serial.print(a.acceleration.x);
Serial.print(", Y: ");
Serial.print(a.acceleration.y);
Serial.print(", Z: ");
Serial.print(a.acceleration.z);
Serial.println(" m/s^2");
Serial.print("Rotation X: ");
Serial.print(g.gyro.x);
Serial.print(", Y: ");
Serial.print(g.gyro.y);
Serial.print(", Z: ");
Serial.print(g.gyro.z);
Serial.println(" rad/s");
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" degC");
if (abs(g.gyro.x) > 1 || abs(g.gyro.y) > 1 || abs(g.gyro.z) > 1) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(getRandomMessage());
lcd.setCursor(0, 1);
lcd.print("UwU");
delay(3000);
lcd.clear();
}
The next step is reducing the sensitivity of the gyroscope. We don't want to text to appear as soon as the person picks up the ball.
Here is the new code:
#include <Wire.h>
#include <LiquidCrystal.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
const int rs = 15;
const int en = 13;
const int d4 = 32;
const int d5 = 33;
const int d6 = 25;
const int d7 = 26;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Adafruit_MPU6050 mpu;
void setup() {
lcd.begin(8, 2);
Serial.begin(115200);
while (!Serial) {
delay(10); // Wait for Serial Monitor to open
}
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}
void loop() {
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
float accelerationMagnitude = sqrt(pow(a.acceleration.x, 2) + pow(a.acceleration.y, 2) + pow(a.acceleration.z, 2));
// Adjust this threshold value to change the sensitivity
float threshold = 60.0;
if (accelerationMagnitude > threshold) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(getRandomMessage());
lcd.setCursor(0, 1);
lcd.print("UwU");
delay(3000);
lcd.clear();
}
}
String getRandomMessage() {
String messages[] = {
"Go ahead",
"Fuck it.",
"WTF?!",
"OOPS",
"Possibly",
"Fate.",
"Nauwr",
"Shut up",
"RIP",
"Nope"
};
int index = random(10);
return messages[index];
}
What we did today:
Things to do next time:
This is our action plan for our improved Magic 8 Ball:
And to improve our user's guide:
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates