To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Message on the screen after shaking the gyroscop.mp4MPEG-4 Video - 2.41 MB - 05/30/2024 at 11:09 |
|
|
Hall Effect Sensor Final Circuit.mp4MPEG-4 Video - 15.26 MB - 05/30/2024 at 09:03 |
|
|
Hall Effect Sensor Circuit - Book.mp4MPEG-4 Video - 6.61 MB - 05/28/2024 at 14:05 |
|
|
Finished Ball.mp4MPEG-4 Video - 25.63 MB - 05/28/2024 at 14:05 |
|
|
Hall effect LED - demo 1.mp4wiring with a Hall effect sensor to turn on the LEDs.MPEG-4 Video - 2.79 MB - 05/23/2024 at 09:36 |
|
Today, we finished assembling the book:
Last tests were made but still inconclusive so we decided to give up. We might try again later, but we cannot present any functional demo at the moment.
We made a brand new book for a more finished look.
BEFORE
AFTER
Over the course of the last two weeks I struggled a lot with my arduino code.
First of all, arduino codes for an ESP32 + TFT screen or codes for ESP32 + gyroscope are practically inexistent. Most of them are designed for arduino uno.
Finding inspiration was hard...
First of all, I decided to use and old code which had been created so that when someone shakes the gyroscope, text appears on a 08x02 screen. It worked in that scenario so I thought that if I changed it for my RB-TFT1.8 screen, it would also work in this case.
What I didn't realise is that our images we wanted to display (instead of text like last semester), would have to be stored in the SD card of our screen... under bmp format.
So I changed all the images size on gimp so that they would fit perfeclty on our screen and converted them to the bmp format. I also learned that in order for our images to be displayed I would have to express their path in my code (eg: D:\Images\1.bmp)
Here are a few examples of codes I tried to modify for them to be adapted for my screen and ESP32:
Code for our screen + arduino Uno
// include TFT and SPI libraries
#include <TFT.h>
#include <SPI.h>
// pin definition for Arduino UNO
#define cs 10
#define dc 9
#define rst 8
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
void setup() {
//initialize the library
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
//set the text size
TFTscreen.setTextSize(2);
}
void loop() {
//generate a random color
int redRandom = random(0, 255);
int greenRandom = random (0, 255);
int blueRandom = random (0, 255);
// set a random font color
TFTscreen.stroke(redRandom, greenRandom, blueRandom);
// print Hello, World! in the middle of the screen
TFTscreen.text("Hello, World!", 6, 57);
// wait 200 miliseconds until change to next color
delay(200);
}"
I tried adapting it for my ESP32:
#include <TFT_eSPI.h>
#include <SPI.h>
TFT_eSPI tft = TFT_eSPI();
void setup() {
tft.init();
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
}
void loop() {
uint16_t color = tft.color565(random(0, 255), random(0, 255), random(0, 255));
tft.setTextColor(color);
tft.setCursor(20, 57); // Adjust the cursor position as needed
tft.print("Hello, World!");
delay(200);
}
It didn't work and after multiple attempts I just gave up, and tried to see if it would work better if I tried to insert the gyroscope as well. And after multiple changes, different codes mashed together and altering the code each time I got an error message I finally got this code which didn't displayed any error messages when I clocked in the tick button:
#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
Adafruit_MPU6050 mpu;
const float shakeThreshold = 2.0;
#define TFT_CS 15
#define TFT_RST 2
#define TFT_DC 17
#define SD_CS 26
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
const char* bmpFiles[] = {
"1.bmp",
"2.bmp",
"3.bmp",
"4.bmp",
"5.bmp",
"6.bmp",
"7.bmp",
"8.bmp",
"9.bmp",
"10.bmp",
"11.bmp",
"12.bmp"
};
const int bmpFileCount = sizeof(bmpFiles) / sizeof(bmpFiles[0]);
void setup() {
Serial.begin(115200);
if (!mpu.begin()) {
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
while (1);
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_2_G);
mpu.setGyroRange(MPU6050_RANGE_250_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_5_HZ);
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
return;
}
Serial.println("SD card initialized.");
}
uint32_t read32(File &f) {
uint32_t result;
((uint8_t *)&result)[0] = f.read();
((uint8_t *)&result)[1] = f.read();
((uint8_t *)&result)[2] = f.read();
((uint8_t *)&result)[...
Read more »
Today, we finished the ball.
We assembled the book structure, soldered the circuit and it works.
The screen has arrived, and I started to familiarise myself with it's features.
I checked it's datasheet and rewied the gyroscopes features as well. Most of the time the way it's supposed to be wired is only indicated for an arduino uno, so I also have to check the pins of my ESP32 in order to understand how to wire my system.
Helpful website for the screen:
ESP32: TFT Touchscreen - 2.8 inch ILI9341 (Arduino) | Random Nerd Tutorials
Helpful website for ESP32 and screen:
Exploiter 1,8 pouce TFT sur ESP-32 Dev Kit C (az-delivery.de)
Pins:
Gyroscope:
ESP32 and RB-TFT1.8 Screen
Schematic:
I have received valuable answers from the forums :
Here is the answer I needed. Figures the only issue I had was the placement of the LED, there is no need for a transistor.
more details here: https://forum.allaboutcircuits.com/threads/trying-to-invert-a-hall-effect-sensor-with-led.200980/
SO, I have obviously tried the circuit and it works as intended !
see file "Hall effect LED - demo 1"
We managed to put the whole ball together.
I tried several options some of them listed here:
But most of them don't work or make the LED switched on no matter what. Whether the magnet is here or not only changes the intensity of the LED.
And I think I have burnt my transistor in the process...
Next try will be this :
found on this website : https://how2electronics.com/hall-effect-sensor-a3144-magnetic-switch/
I have asked on forums, so I am waiting for answers there too
- "get started" example from the "DFRobotDFPlayerMini.h" library
- this one :
- more from : DFPlayer Mini Mp3 Player - DFRobot Wiki
- and several other tries from random YouTube videos I found
But this was not conclusive.
So I moved to the subject of the Hall effect sensor.
The sensor we ordered is : 3524405C (AH3524)
the objective is for a LED to turn on when the magnet is far/not here, and turn off when the magnet is very close.
However, the sensor we ordered has the reverse effect: The LED turns on when the magnet is close to the sensor. Similar to the first example shown in this video :
2 Basic Project with Hall effect Sensor (youtube.com)
So the solution we found is to use a NPN transistor.
Quest to find the transistor : just started.
We also worked on the ball itself, preparing the patreons and cutting the pieces in the cardboard.
The goal is to cover each piece of carbon with a piece of fabric and put them all together like the paper prototype.
We also planned to have a "door" to open the ball.
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 to 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 on the website, so we tried to cable physically the ESP32 we used in the first semester but they were all over heating, so we tried to de-soulder them. However they seem to have decide not to work anymore, the ESPs might be unusable ever again.
Our ball is inspired by Jon Paul's balls. You can find the one we took the measurements of at the following link: JPB AL RIHLA BALL .
1. Prepare your patreons and do a prototype in paper to see if the size of the ball is right for you. Ours
2. Cut pieces in the cardboard
3. Cover each pieces with the fabric
4. Assemble them so that you can have your final ball
5. Cut a hole in one of the triangles according to the size of your screen so it can fit perfectly
6. Make the ball more beautiful by cleaning the edges and the inside when we open it
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