Flash with Arduino IDE


#1

H there,

Is there anyway to program the esp32 with Arduino IDE? (I use a Mac, but that should not matter)


#2

Well, nobody? :smiley:


#3

This should be a good starting point https://github.com/espressif/arduino-esp32


#4

Thnx for the reply, but I already did that :wink:

The problem is actually: How can I connect my Voice to my mac (or pc or whatever is used) so that it will show up on /tty/S0 and which board should I select ?


#5

Sure, thats the hard part :slight_smile:

I see two options:

  1. Just getting the hex file after building the arduino ino programm, copying that to the Pi and then flashing the ESP32 from there. I found this example

  2. Actually sharing the Serial connection frmo the Rasp Pi to your computer and just using the Arduino IDE to flash. check out here

PD: I havent tested any pf this. Please, let me know how this goes.

-Yoel


#6

Those are actually good leads! Thanks, I will update my results :smiley:

In the meanwhile I have found another way, use the ESP demo and build it.
In the build folder there will be 2 bin files.
From your IDE, export the bin and rename it to match the demo bin. Make deploy :slight_smile:

I will post a more detailed version


#7

Nice … Looking forward to seeing the progress


#8

I have had some good results over the weekend, but I want to try other methods as well.

The way this worked for me at this point:

  • First build an example from the esp32 examples, follow the instructions :slight_smile:
  • Create a new arduino sketch, I have create a simple startup which just connects to my wifi
  • In Arduino IDE, export compiled library.
  • From the esp32 example, copy build/bootloader/bootloader.bin and build/partitions_singleapp.bin to the export folder of the arduino sketch. There should be 3 bin files then
  • I have examined what the deploy.mk command does, it pipes a tar file to the Pi via ssh, untars it and then flashed those bins. I have refactored it a bit.
  • My command was tar cf - *.bin | ssh pi@192.168.178.81 ‘tar xf - -C /tmp;sudo voice_esp32_reset;voice_esptool --chip esp32 --port /dev/ttyS0 --baud 115200 --before default_reset --after hard_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 /tmp/bootloader.bin 0x10000 /tmp/matrix_voice.ino.esp32.bin 0x8000 /tmp/partitions_singleapp.bin’
  • adapt the matrix_voice.ino.esp32.bin to fit your sketch and execute it.
  • Voice is flashed!

After the first succes I went on and the sketch now also lights up the leds and MQTT.
The MQTT was the main reason I wanted to try this, the libraries on c++ gave me some troubles when I subscribed to a topic which sends wav files. When the esp32 received such a large buffer, it rebooted, regardless of my max packet size (2000, while a message of 46000 or so is being received)
Then I saw the implementation of PubSubClient for arduino also has implemented streams and other differences, so I wanted to try that.

The voice now can handle these large messages without rebooting, so that looks promising :slight_smile:

edit: also reboots… back to the drawing board. I think I will try sharing the serial port of the Pi to my mac with socat :slight_smile:


#9

I was thinking about why the Voice keeps rebooting and then I thought the incoming message from the Snips platform was just to big to handle (it publishes a wav file)
That would kill the incoming memory buffer, so I started looking for others solutions.

On of those was trying to implement a ring buffer of some kind, but it suddenly struck me that I needed another type of mqtt client, namely an ASYNCH client.

I am having great succes by using this: https://github.com/marvinroger/async-mqtt-client
The only thing I need is that the Voice does not reboot and post a message to a playFinished topic.
This is working now :sunglasses:

I am now implementing the use of the everloop on hotword detection, but if someone from the team reads this:

  • would really, really, really be happy when the audio jack outputs will work and if there is a small example on how to use it standalone

Repo of my new code:


#10

Victory :slight_smile:

I have got a fully functional Snips Audio Server now, with green leds on hotword detection and blue on idle!
I have got some ideas, one of them being able to play the bytes received through the headphone output.
Any news on it? I assume we cannot use dacWrite at this point?


#11

I also created a version that can be used with OTA.
Very nice because you do not need the Voice attached to the Pi anymore.

I will be implementing some ideas over the next weeks, but the feature I really want to implement is using the headphone jack to output the sounds.
While that is still under development, I will also try and print a nice case for it to build a Echo Dot like device :slight_smile:


#12

Follow up!

Current features:

  • Runs standalone, NO raspberry Pi is needed after flashing this program
  • Ledring starts RED (no wifi connection), then turns BLUE (Idle mode, with wifi connection)
  • Ledring turns GREEN when the hotword is detected, back to BLUE when going to idle
  • Uses an asynchronous MQTT client for the playBytes topic (large messages which cannot be handled by synchronous clients)
  • Uses a synchronous MQTT client for the audiostream. (async leads to errors)
  • OTA Updating
  • Dynamic brightness and colors for idle, hotword, updating and disconnected
    -example: Example: {“brightness”:20,“idle”:[240,210,17,0],“hotword”:[173,17,240,0],“update”:[0,255,255,0]}
    -with this, it is possible to adjust the brightness when the room is dark or bright (day/night)
  • Reboot device by sending hashed password

I also implemented a task with a rotation animation, but that is not used yet.

Is there any news about the audio output?
I also would like to now that when that is fixed, it will also be possible to use the small left /right connectors?


#13

While waiting for audio output, I have managed to flash this program to the Voice:

And it paired and played the wave file on my bluetooth headset!
So the next big step will be to play audio via Bluetooth!


#14

Small update for anyone who finds it interesting.
After a couple of days struggling, I can now save the MQTT wave message as a raw audio file which plays on the BT speaker :slight_smile:

I could not get it to work yet with only memory, so I tried first to save the message as a file.
Still a lot to do, but also made quite some progress