Skip to content
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 Port #65

Merged
merged 55 commits into from
Jul 4, 2022
Merged

Arduino Port #65

merged 55 commits into from
Jul 4, 2022

Conversation

ggerganov
Copy link
Owner

@ggerganov ggerganov commented May 15, 2022

ref #62

Porting ggwave for Arduino microcontrollers

TODO:

  • Optimize memory usage
  • Reduce code duplication (lots of copy-paste, easier to get things running)
  • Create optimal Tx/Rx protocols for Arduino
  • Add DSS support
  • Add Mono-Tone protocols
  • Remove ggwave-mod
  • Update bindings
  • Add DSS tests
  • Add Tones tests
  • Remove std::vector
  • Remove std::initializer_list and ArduinoSTL.h dependency
  • Try to reduce memory footprint of protocols
  • Start using the F() macro for constant strings (Arduino)
  • Use malloc instead of new
  • Enable all MT and DT protocols in arduino-rx example
  • Move DSS data to PROGMEM (Arduino)
  • Compute required memory and allocate single buffer
  • Add Tx example for Arduino Uno
  • Add Tx/Rx example for Arduino RP2040
  • Add Tx/Rx example for ESP32

Examples

All examples below can be compiled with Arduino IDE. You can use the ggwave-cli tool to communicate with the microcontroller from your PC. The microcontrollers use the fixed-length setting of ggwave (i.e. transmission without sound-markers where the payload length is known in advance) due to memory limitations, so make sure that your payloadLength parameter is the same on both the sending and receiving sides. For example, using payloadLength = 16 and [MT] Fastest protocol with DSS:

$ ./bin/ggwave-cli -t11 -l16 -s
Usage: ./bin/ggwave-cli [-cN] [-pN] [-tN] [-lN]
    -cN - select capture device N
    -pN - select playback device N
    -tN - transmission protocol
    -lN - fixed payload length of size N, N in [1, 64]
    -s  - use Direct Sequence Spread (DSS)
    -v  - print generated tones on resend

Found 2 playback devices:
    - Playback device #0: 'Starship/Matisse HD Audio Controller Analog Stereo'
    - Playback device #1: 'SRS-XB10'
Found 1 capture devices:
    - Capture device #0: 'Starship/Matisse HD Audio Controller Analog Stereo'
Initializing playback ...
Attempt to open playback device 0 : 'Starship/Matisse HD Audio Controller Analog Stereo' ...
Obtained spec for output device (SDL Id = 2):
    - Sample rate:       48000 (required: 48000)
    - Format:            32784 (required: 32784)
    - Channels:          1 (required: 1)
    - Samples per frame: 16384 (required: 16384)
Attempt to open capture device 0 : 'Starship/Matisse HD Audio Controller Analog Stereo' ...
Obtained spec for input device (SDL Id = 3):
    - Sample rate:       48000
    - Format:            33056 (required: 33056)
    - Channels:          1 (required: 1)
    - Samples per frame: 1024
Available Tx protocols:
      0 - Normal
      1 - Fast
      2 - Fastest
      3 - [U] Normal
      4 - [U] Fast
      5 - [U] Fastest
      6 - [DT] Normal
      7 - [DT] Fast
      8 - [DT] Fastest
      9 - [MT] Normal
      10 - [MT] Fast
      11 - [MT] Fastest
Selecting Tx protocol 11
Enter text: hello world!
Sending ...
Enter text: 

The new Mono-tone (MT) protocols are designed to work with microcontrollers, so make sure to use them. The other protocols might not work, depending on your hardware (chip + mic) parameters.

Arduino Tx demo

examples/arduino-tx

With this example, you can transmit data from the Arduino using a simple buzzer or speaker.

Supported microcontrollers

  • Arduino UNO
  • Arduino RP2040

Sample board

IMG_0257

arduino-tx-3-github.mp4

Arduino Rx demo

examples/arduino-rx

Supported microcontrollers

  • Arduino RP2040
  • Arduino Nano 33 BLE Sense (not tested yet)

This example demonstrates how to receive data with an Arduino.

Sample board

The mic is built-in, so you don't need any other elements. Just upload the arudino-rx sketch to the microcontroller and observe the Serial output.

IMG_0262 (1)

ESP32 Rx demo

examples/esp32-rx

Supported microcontrollers

  • ESP32

This example demonstrates how to receive sound data with an ESP32 chip. The example uses the built-in ADC to sample data from analog microphone. The example was tested with a MAX9814 microphone, but should work with other mics too. Upload the esp32-rx.ino sketch via Arduino IDE and observe the Serial output.

Sample board

IMG_0351

No longer needed since the core ggwave lib now supports mono-tone
protocols
uint8_t does not work so well for some reason. Probably we lose
precission, although it's not obvious why
- faster FFT implementation
- built-in Direct Sequence Spread option
- remove <map> dependency from implementation
- update arduino-rx example
@ggerganov ggerganov merged commit ee6d615 into master Jul 4, 2022
@ggerganov ggerganov deleted the arduino branch July 4, 2022 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant