Propose changes for ESP32 and a CustomSensor to be used as simple switch sensor. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Someone asked me it it is possible to read the state of a reed switch with Pybricks so I searched for a way to create a custom LEGO compatible sensor, just a simple switch for a start, and found your library. Great work!!
I don't master Arduino, C++ or ESP32 but I managed to use it with a NodeMCU-ESP32 board I already had. Will try a Raspberry Pi Pico later since the ESP32 is overkill.
I am proposing the changes I made - it would help with issue #2
I only tested TiltSensor, it worked (just a typo in exemple). So I copied it and created a CustomSensor, it is basically just the TiltSensor Mode 0 with a different name ('MYOWNSWITH') and just one byte value. I am using Type ID 36 because it's not associated with any known LEGO device (tried higher values but didn't work with Pybricks - https://github.com/orgs/pybricks/discussions/2132).
I am proposing this new device with an example. You can see it working in this video: https://youtu.be/7tQd6HiykZE
In the video I am using a Technic Hub with Pybricks firmware and PUPDevice() class, then read(0)[0] to read mode 0.
Again, I am not a programmer so please excuse me if my code doesn't follow conventions or guidelines. Feel free to change it or even refuse it, I just want to contribute. I appreciate you mentioning me on your project and I also wanted to thank you because your worked helped me and I believe it will also help others.