-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino Library? #3
Comments
Hi, thanks for your interest in using this library! Releasing an Arduino library actually hasn't crossed my mind yet. I'd like to look into how feasible porting this library would be. However, the API exposed by Espressif's Arduino implementation is vastly diffrent from the ESP-IDF framework. Next to that, I'd probably need to rewrite this library's API as well in order to conform to the Arduino API style guide. Because of these differences, it would be most sensible to create a new repository if I ever come around to porting it to Arduino. Don't expect it anytime soon though, but I'll try to make some time to create an Arduino library. I'll keep this issue open so you'll get notified whenever I get around to creating the Arduino library :) |
Same here, it would be great to have a port into arduino. There is nothing off the self so far and it is highly demanded..... |
This would be great! I remain in hopeful expectation... |
Good news! As it turns out, adding support for the Arduino IDE wasn't so hard after all. I didn't even have to create another repository for it, as it works quite nicely together with the ESP-IDF! Now I need your help!Before releasing it as an official Arduino library, I want to polish things up a little. In the mean time, though, I could use your help in testing this library, to see if it suits your needs. Does it work properly? Does it miss any features? Would you prefer other naming schemes for the functions and variables? Maybe you can think of a better name for the library? Let me know what you think. Installing the ESP32 boards In case you haven't yet, you can add the ESP32 boards to your Arduino IDE by adding them to the Boards Manager: Open
Open the Boards Manager with Finally, select the ESP32 board you have with Installing the Ps3Controller library You can download the Arduino library from the development branch: esp32-ps3-develop.zip. Then, in the Arduino IDE, you can import the library with Running an example sketch The example sketches should be immediately available in the IDE. Try to connect to the PS3 controller first with the Ps3Connect sketch: Don't forget to properly pair the PS3 controller as described here. Hope this helps! |
When I try to complie you sketch I get the following error Message: _In file included from C:\Users\Sniperblue\Documents\Arduino\libraries\esp32-ps3-develop\src\ps3_spp.c:6:0: C:\Users\Sniperblue\Documents\Arduino\libraries\esp32-ps3-develop\src\include/ps3_int.h:29:2: error: #error "The selected Bluetooth controller mode is not supported by the ESP32-PS3 module" #error "The selected Bluetooth controller mode is not supported by the ESP32-PS3 module"_ I use Arduino Version 1.8.9 with ESP Version 1.0.1 installed and try to compile withESP32 Dev Module and DOIT ESP32 Dev V1 selected. The ESP32 says this ESP32 SDK Version: v3.2-dev-39-gaaf12390 Hope this helps to get an idea about the root cause..!? |
Thanks for trying it out! Unfortunately, I am unable to replicate your problem. I just tried to execute the steps I described above on a fresh Windows install, using Arduino Version 1.8.9 with ESP Version 1.0.1 installed, just like you described. Even with the DOIT ESP32 Dev V1 board selected it compiles just fine for me. Could you try to restart the Arduino IDE, or even your computer, and try again? Have you changed any configuration settings using Could you share how you've set up your Arduino environment? |
I can't rember that I changed any configuration settings using make menuconfig. What do you mean with share how you've set up your Arduino environment, preferences.txt file from the ...AppData\Local\Arduino15 folder or something like that? Compiling the with same Arduino IDE delivered BLE sketch BLE client compiles at my Win7 without any issues? |
With sharing your setup I meant how you installed the Arduino IDE and the ESP SDK. But yes, seeing your The error you get means a misconfiguration in the sdkconfig file, where BTDM_CONTROLLER_MODE is set to BLE, while it should be set to any of the other options which enables the Classic Bluetooth ('Both' or 'BR/EDR Only'). The default config shipped with the ESP32 boards should be adequate in this regard, which is why I think it is really strange this is happening to you! |
ESP32 was installed in a standart was as described here: Here are the BT extract form the sdkconfig file:
Here are the sdkconfig: Here are the preferences: |
Strange... This is exactly what I'm testing for in ps3_int.h:26. One thing you could try is to reinstall the ESP32 boards:
Now try to compile the example sketch again. If this fixes your problem then Espressif has released updates to the same |
Unfortunately seems to be reinstalling ESP32 did not solve the issue. Still sthe same error! Nevertheless when I uncomment your check sequence (see below) the sketch works and I get an connection after changing the MAC Adress to
By the way could you also change the MAC Adress in the example to I try also your PS3Data sketch and this works also :-) |
Yes, this is exactly what I have as well! I still can't really wrap my head around this issue yet, but maybe someone else can chime in with their experiences.
Maybe I will just disable the checks when it's used as an Arduino library, as it would not really be needed anyway.
I don't quite understand what you mean with this. Did you have to put
Glad to hear that! |
Concerning Meanwhile I playing a litte bit around with the lib and had a few question: I pimped a little bit your data example attached you'll find my test code: |
You can simply set the LED to 0. I might add an enum or something to make this more obvious. Your code would look like this: Ps3.setLed(0);
The accelerometer and gyroscope values should be provided automatically, but I haven't tested this yet. You can read the values like this: Ps3.data.sensor.accelerometer.x;
Ps3.data.sensor.accelerometer.y;
Ps3.data.sensor.accelerometer.z;
Ps3.data.sensor.gyroscope.z;
Unfortunately, this hasn't been implemented in the Arduino library yet. In the mean time, you could just use the following snippet: ps3_cmd_t cmd;
cmd.rumble_left_intensity = 0xff;
cmd.rumble_right_intensity = 0xff;
cmd.rumble_right_duration = 100;
cmd.rumble_left_duration = 100;
ps3Cmd(cmd);
Thanks! I had planned to include a bigger example sketch to showcase all of the data you can access, and this helps a lot! |
I include your information into the test sketch. Here are the test results: Rumble functionality
Battery functionality
LED functionality
Accelerometer functionality
Gyroscope functionality
But maybe I do some misstakes during conding and the above mentioned weaknesses are no Lib issues! |
Oh on the contrary, I'm quite sure my library is to blame here :) I actually haven't ever tested the accelerometer and gyroscope data, I just included what should be their data, but apparently I'm wrong with that.
Yes, actually, the Arduino library doesn't support having multiple LEDs turned on at once right now. To change the LED, it is therefore not required to first reset all the LEDs, you can immediately switch to LED 2: // LED 1 == ON | LED 2 == OFF
Ps3.setLed(1);
// LED 1 == OFF | LED 2 == ON
Ps3.setLed(2);
The data to control the LEDs and to control the rumble is actually in the same packet sent to the PS3 controller. So when you sent the command to rumble, the LEDs were turned off. When I add the function You can do this too right now: ps3_cmd_t cmd;
cmd.led1 = true;
cmd.rumble_left_intensity = 0xff;
cmd.rumble_right_intensity = 0xff;
cmd.rumble_right_duration = 100;
cmd.rumble_left_duration = 100;
ps3Cmd(cmd);
I actually noticed this too today, this is a bug and needs to be fixed.
My PS3 controller rumbles on both sides when I use the snippet I provided, so maybe your controller is broken. To summarize this thread so far, I still need to fix the following things on the Arduino library before I can release it:
Do I miss anything? I'll probably have some spare time next weekend to work off this list! Edit: I have opted to simply support setting the LEDs to up to 10 players instead of fiddling around with Enums. I did try it, but it just didn't feel right. |
Hi, thanks for working on the Arduino port, its very exciting! I'm looking forward to much better development ergonomics and compatibility with other libraries. Unfortunately, I was not able to get the Ps3Connect example to work, which is strange as I'm able to use your esp-idf version. I followed all the steps including uninstalling and reinstalling the esp board for arduino. I am able to run other esp32 examples such as the webserver so I believe the esp32 was set up correctly.
There is a new version 1.0.2 available now, but I installed 1.0.1 to keep the steps the same as @Sniperblue. My configuration files match exactly. I also tried @Sniperblue's fix to comment out some of the #ifdefs but that didn't fix it for me. |
Could you describe what is going wrong? Do you get the same compilation errors? Or does the PS3 controller simply refuse to connect?
Would you be willing to test the ESP-IDF version on the development branch of this repository? Maybe I messed something up in the meantime...
The reason to select |
The code compiles and the "Ready." message prints but it never connect after that. I have updated the arduino esp version to 1.0.2 but that doesn't fix it.
For the esp-idf version everything works against the latest master branch commit: 06ab5e7 From one of your posts to sniperblue:
my menuconfig is set up to work with your esp-idf version. I assume that would not cause problems. Thanks |
@jvpernis Concerning your working list, which had not to be finished within next week ;-) |
the esp-idf version also works against the latest devel commit. |
Thanks for checking! That rules a few things out at least.
Just to sanity check:
uint8_t new_mac[8] = {0xb4,0xe6,0x2d,0xee,0x7b,0xfd};
ps3SetBluetoothMacAddress(new_mac);
ps3Init();
Ps3.begin("b4:e6:2d:ee:7b:fd"); Could you try to run the example sketch with the debug level set to 'Debug'? Maybe this will give some insight as to why it fails to connect. |
it works great to me! first time right! hurra!
El jue., 1 ago. 2019 a las 8:37, Jeffrey van Pernis (<
[email protected]>) escribió:
… Good news!
As it turns out, adding support for the Arduino IDE wasn't so hard after
all. I didn't even have to create another repository for it, as it works
quite nicely together with the ESP-IDF!
*Now I need your help!*
Before releasing it as an official Arduino library, I want to polish
things up a little. In the mean time, though, I could use your help in
testing this library, to see if it suits your needs. Does it work properly?
Does it miss any features? Would you prefer other naming schemes for the
functions and variables? Maybe you can think of a better name for the
library? Let me know what you think.
*Installing the ESP32 boards*
In case you haven't yet, you can add the ESP32 boards to your Arduino IDE
by adding them to the Boards Manager: Open File -> Preferences, and paste
the following URL in the Additional Boards Manager URLs field:
- https://dl.espressif.com/dl/package_esp32_index.json
Open the Boards Manager with Tools -> Board: "xxx" -> Boards Manager,
look for esp32 (probably the last one in the list), and click install.
Finally, select the ESP32 board you have with Tools -> Board: "xxx" under
the section ESP32 Arduino (I have ESP32 Dev Module selected).
*Installing the Ps3Controller library*
You can download the Arduino library from the development branch:
esp32-ps3-develop.zip
<https://codeload.github.com/jvpernis/esp32-ps3/zip/develop>.
Then, in the Arduino IDE, you can import the library with Sketch ->
Include Library -> Add .ZIP Library..., and selecting the downloaded
esp32-ps3-develop.zip file.
*Running an example sketch*
The example sketches should be immediately available in the IDE. Try to
connect to the PS3 controller first with the Ps3Connect sketch: File ->
Examples -> Ps3Controller -> Ps3Connect.
Don't forget to properly pair the PS3 controller as described here
<https://github.com/jvpernis/esp32-ps3#pairing-the-ps3-controller>.
Hope this helps!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=AMD6T7FKJNWAO2MLFLSRQMTQCKAA3A5CNFSM4IF3GSJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3JPIEY#issuecomment-517141523>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMD6T7GDL5WH6XQ5UWGQAPLQCKAA3ANCNFSM4IF3GSJQ>
.
|
I've fixed it. In the esp-idf version I did not set the bluetooth address using
In the arduino version I had:
The fix was to use the sixaxis tool to set the address to "00:12:34:56:78:90" and update the
This probably doesn't matter any more but I was not able to get debug mode working even after changing the debug level. I had a look online to try and get debug info and added:
This also didn't work, but the problem is fixed now so everything is fine. Thanks for your help! |
False alarm, when I added some bad code code I get debug messages. E.g.:
I guess the non connection state was not enough to log a debug message. |
I've crossed a few items off my list, such as investigating the accelerometer values. They appear to be working just fine with me. To debug this, I created an example sketch to display the accelerometer data. Could you try it out? You can simply download the esp32-ps3-develop.zip again and replace the old one. This is what I get when I run the sketch and lifting the controller once, holding it in the air: |
My controller model CECHZC2U A1 still shows -4 0 16 by using your updatet lib. Maybe controller issue... |
Thanks for making this library for Arduino too! I love it, I only wished it would work for ps4 controllers as all my ps3 controllers are broken...... I can connect my esp32 to the ps4 controller, but I get strange readings from the digital buttons and the analog sticks. But thanks for your work so far, its the best alternative I've found so far!! |
Thanks for the kind words! There is actually a PS4 controller owned by a friend of mine on my desk waiting for me to implement it in this library! The next big challenge after finding some spare time to work on this would be to find a name that better suits this library, though :) |
Awesome! Please let me know if you need help betatesting it! I'm not good with software, but I will help with what I can. I tried to connect the ps4 controller to my d2-mini-esp32 with this library, and it kinda works. Its just the parsing/button mapping that is totally wrong to make it work with basic functions. The library should be called "The best and only library you will need in the world". There is a lot of people looking for a way to connect the ps4 controller to the esp32, you will be a hero for many! :-D |
Not sure if this is direct result of the library, but when I'm running Ps3.begin() I'm getting the error:
The function works as expected when running in a small program but when running in a more complex program it's throwing these errors. |
Hello, Thanks for your work, I want to remote my ballancing robot with a PS3 controller. Here are the logs Did I have to use ESP-IDf to modify the bluetooth protocol BLE=>BR/EDR ? Thank you very much The controller is working fine with my PS3. Have you any idea ? |
Hello, I have gotten your library working on my esp, and the four buttons work perfectly (cross, triangle, circle and square). I am just wondering about the functions for the analog sticks on the ps3 remote and the other buttons as well. I am not sure where I would find these functions as I am quite new to Arduino IDE. Any help would be greatly appreciated. |
It has been done! I have requested this library to be included in the Arduino Library Manager. You can follow this request in Arduino issue #9663. I will close this issue once the library is available from within the Arduino IDE. |
how can I make the ps3 controller vibrate by sending commands from esp32. |
The code looks like this:
|
when to use ps3_cmd_t cmd; and ps3Cmd(cmd); in the code? |
I wonder if we can control the 4 lights on the controller ,if yes how? |
See line 213 of Ps3Demo in the Examples. There is an Example sketch for the rumble feature in the Examples. |
Respected sir, I am unable to connect my ps3 controller to esp32.What's happening is all 4 leds blink simultaneously and still never get connected. If you could explain how the connection between the two is made and how to read the ps3 data. As I am an amateur if you the could provide the necessary lines of code to establish connection and read data and able to rumble and change led lights which can be written in the arduino IDE, would be of great help. I request you sir please help me with this. Thank you, |
Hi, is it scheduled to release also a modify Library based on this Espressif one which works with Arduino IDE. Up to now I think there is nothing around like this in the net. Unfortunaley I'am not such a Bleutooth specialist to do this by myself :-(
The text was updated successfully, but these errors were encountered: