ESP32-WROOM-32
Tristan M. (2946) 1039 posts |
Using a hub is good advice. The esp32 can have some brutal current spikes. https://github.com/espressif/esp32-doom I saw the larger memory models on AliExpress yesterday. |
Steve Pampling (1551) 8170 posts |
I have a vague memory of being told by Sprow that one of the differences in the build environments was related to the use of ADR vs. ADRL and I’ve certainly come across differences in macros where stuff called in different versions expects different numbers of parameters (but the latter kicks up errors that abort the compilation so that wouldn’t be it) |
Rick Murray (539) 13840 posts |
A little bit about the ESP32, and how to get the Arduino IDE stuff running under XP. https://www.heyrick.co.uk/blog/index.php?diary=20190119 Now time to microwave a kebab (sorry Gavin! ☺) and head for bed… it’s nearly 1am here! |
Colin (478) 2433 posts |
Moved to Rick’s Blog. |
Rick Murray (539) 13840 posts |
OMG. So I got myself an MP3 decoder chip (VS1302 or somesuch). It uses SPI and can decode loads of things. I got myself a 16×2 LCD as well, with IIC driver board. I think all-in it came to a little over a tenner from Amazon, and since I’m Prime, I ordered it on Sunday and it arrived today. ;-) The idea? To use the ESP32 to receive and play Eagle 80s (instead of my phone). Just make a self-contained player that I can power up when I want to listen. Took forever to build the ESPRadio firmware the first time (don’t know how long, I was doing other things), only to find out that it is broken. It set up an AP for my phone to connect to (to give it the details of my Livebox), but as soon as my phone tried to connect, it flaked out with an unhandled event error. Nothing was going to get it to work… So I built a program for the ESP32 to push the configuration directly into NVRAM. Now I’m rebuilding the ESPRadio firmware. It’s been 40 minutes so far… If it works, it’ll be a pretty simple plug’n’play way to make an internet “radio” for about twenty five euros all in. If it works. That’s a big if. ;-) That said, I wonder how much the software can be hacked at. It supports MTQQ (or something – no idea what that actually is) plus playback of music stored on an SD card. All that can be cut out to make it a simple “do this and do it well” project. |
Rick Murray (539) 13840 posts |
God I hate lame-ass programming. So it installed, I got the web interface up, and it found Eagle 80s. Thing is, it kept telling me that my audio chip was incorrectly installed. Probably something to do with the configuration, given that all the GPIO pins appear to be configurable. So I went to the configuration screen and set things to match the guide that I had followed and… I don’t want to sit through the time it takes to reconfigure plus the time it takes to rebuild the entire ESPradio firmware too many more times, so I’m going to shortcut the AP configuration and just hardware the details of my Livebox so at least it’ll manage to connect to that. But for now, quiche and yog(ho)urt and bed. I’ve already wasted nearly an hour and a half waiting for that Arduino IDE to do what it does. To hell with doing it a third time… |
Steve Pampling (1551) 8170 posts |
I’m hiding my efforts then. |
Rick Murray (539) 13840 posts |
BIG SMILE I dug up libraries for the LCD and one for the VS1053 audio decoder. Bolting it all together gave me a basic but functional internet radio player in a few dozen lines of code… Basically I connect (as done before) and read the data in 32 byte chunks and toss it to the audio chip.
They’re enjoying True Faith by New Order. There’s a lot more to do – support redirection (because the base URL goes via a redirect for load balancing), support buttons for changing volume and/or station, and parsing the track titles out of the stream so I can display something useful on the LCD. Oh, and probably put it in a box. ;-) But, hey, even in this state I can plug the stuff into a single USB supply and get my favourite radio station in about fifteen seconds. So in that respect, mission accomplished. The two Playmo girls are doing air guitar to REO Speedwagon…….. [just a shame the dev environment is such rubbish – that I can make a cup of tea and feed the cat in a stable 200 metres away across the field in the time it takes to build such a short program is, honestly, mind numbingly slow] One thing I will say, being used to RISC OS and doing stuff “the hard way”, it was quite a change to create an HTTP fetcher by defining an instance of “WiFiclient”, to create the audio player by defining an instance of VS1053, calling some routines to initialise them, and then… the entire source file runs to around 180 lines. That’s including comments scattered around, plus lots of commented out calls to dump stuff to the serial port to track what’s going on at each step. That’s physical lines, by the way, so includes whitespace. Maybe it would be better if I said the entire source was about 5K… |
Tristan M. (2946) 1039 posts |
Although arguably worse for speed, have you tried Visual Studio Code? It has lots of plugins, including (IIRC) Arduino, esp, STM etc etc. |
Rick Murray (539) 13840 posts |
This is probably going to be my final post on this. I don’t plan any more work with the ESP32. This is for two reasons. Firstly, mission accomplished. I worked over the weekend to do the extra stuff I wanted, and it’s now done. So to my program. “Rick’s NetRadio”. I tried two. One was over the top complex and didn’t work correctly, one worked but it barely did anything more than read data and chuck it at the audio chip. So I rolled my own from scratch. It connects to an AP (hardcoded in the code), then it will start playing the first radio station (for me, that’ll be Eagle ‘80s). It will show what it’s going on the LCD, and if there is title/artist information in ICY metadata, this will be displayed on the LCD. Here is a video of the device in operation: https://www.youtube.com/watch?v=tsaSWCB1t4M To point out, my ESP32 never connects to the AP “from cold”, so I have a timeout that will simply cause a reset. That works. I’ve ordered some nylon bolts from Amazon so I can mount everything into a tupperware box (a bit like I did with the Beagle). Once that’s done, it’ll be fait accompli (unless I want to tweak anything). Okay, that’s it then. I wanted an internet radio for a long time and wondered why it wasn’t possible to go into a supermarket and buy one (but one can buy billions of bluetooth speakers and analogue FM radios…?). I just never expected that I’d build one! It wasn’t actually that difficult. The hardest part was getting the IDE working on XP, and all the thumb twiddling as it did its stuff in slow-mo. One final thing, the source is 715 lines (22K), including comments and debug-to-serial stuff. Written in C++ (my code is C, but there are C++ style library functions), it was not so hard to put together. It works, even without a buffer (!), and does exactly what I wanted it to do. And since it wasn’t written in assembler (which would be insane), I didn’t need to learn a new architecture and write piles of code from the ground up. Indeed, the entire http fetcher is a library that I use. Ditto talking to the LCD, and the VS1053 codec chip. Indeed, all I actually needed to do was write the logic to call all the bits in the right way at the right times. That’s why an entire NetRadio with buttons and display can fit into 715 lines. Most streams are 128kbit, so there’s enough overhead to read the data in 32 byte chunks to hand to the audio chip, and there’s enough overhead to drop out once in a while to handle button presses and metadata decoding. In other words, absolutely no benefit to writing this in assembler, but plenty of downsides if I did, such as the issue of testing and debugging an unfamiliar architecture (I don’t even know what’s inside this thing – some sort of Xtensa CPU?), plus the problem of maintainability. Oh, and it would take a heck of a lot longer than a weekend to get it built (from scratch). Anybody who thinks writing in assembler can outpace HLL is talking bollocks. Okay, that’s it. Enjoy the rubbish video. ;-) |
Tristan M. (2946) 1039 posts |
The toolchain is written in Java? Oh wow. That explains so much. Including why there is no port for aarch64 yet. Java is C++ if it were created by a politician. Great work on the Web radio! That’s a great project. It’s kind of a shame that the esp32 uses a proprietary CPU. It has lots of neat stuff including an MMU. |
Steffen Huber (91) 1953 posts |
Politicians would create something simpler? I don’t think so… C++, apart from its initial complexity which vastly outruns Java, has grown into something extremely complex with C++17, and it will get mindnumbingly complex with C++20. |
Steve Pampling (1551) 8170 posts |
I think that was a reference to over complicating the items in the background in order to provide a nice political front.
So we go to the old saying “horses for courses” – which is a reference to some things being better for different circumstances. Java is capable of far more than it is being asked to do in this instance and is what the English refer to as “a sledgehammer to crack a nut” In the instance described in this thread Java is there because the vendors couldn’t be arsed doing a set of platform specific developer tools for a developer ‘toy’ |
Steffen Huber (91) 1953 posts |
Let’s see.
This is one of the many facets of Java. It does not explain at all why “Java is C++ if it were created by a politician.”
Anyone lumping C into the same bag as C++ should be met with extreme sceptism. Both C and C++ are not platform specific. Depending on the job to do, they come with a small or a large amount of baggage. I’m afraid I can still not see your point, partly because “baggage” does not necessarily translate into slowness or complexity or whatever Tristan referred to with his politician comparison. I’m skipping Assembler as that is not the point of this discussion.
C and C++ are also capable of far more. And C++ is much much more complicated than Java, so could be described as an even bigger sledgehammer where aiming is even more difficult.
That may or may not have been Rick’s point – he conveniently forgot to tell us why he thinks that the Java solution was somehow inherently leading to something overcomplicated and/or slow. However, I have not commented on Rick’s point, but on Tristan’s point which I still don’t understand at all. Fact is that Java is a lot less complex than C++. That is not the direction of complexity that usually results in politicians’ involvement. Maybe Tristan is a big fan of politics, and thinks that politicians are people who reduce complexity, come up with good ideas for more elegant solutions and generally streamline things? |
Steve Pampling (1551) 8170 posts |
I think he was working on the basis that Java implementations in general tend to be slow to do the same task that other implementations do more swiftly and with less cpu/memory resource. To me the logical conclusion is that either:
Note: As with politicians and corruption not all programmers fit one box. |
Rick Murray (539) 13840 posts |
Depends on what you are trying to do. For a compiler that will read from files and output to other files, that ought to be more or less possible with the standard library and whatever glue is necessary to translate stuff from the expected architecture to the one in use. For a multitasking program, somewhat less portable, yes. ;-)
Seriously? Above: [just a shame the dev environment is such rubbish – that I can make a cup of tea and feed the cat in a stable 200 metres away across the field in the time it takes to build such a short program is, honestly, mind numbingly slow] Above that: But for now, quiche and yog(ho)urt and bed. I’ve already wasted nearly an hour and a half waiting for that Arduino IDE to do what it does. To hell with doing it a third time… To put it into context, on my Pi2, I can build RISC OS from scratch faster than the Arduino IDE and ESP compiler can compile a 280K program on a 2.8GHz P4 XP box. All this stuff is running under Java, according to a quick look at ProcessExplorer, so it’s a reasonable guess to assume it’s written in Java. That’ll probably explain it’s cross-platform-ness. As for slow, it is extremely obvious that anything that isn’t native code will run slower than native code. The question is by how much? Well, by quite a lot it would seem.
Any competent C++ compiler is completely capable of compiling C.
And BASIC is less complex than either of them. And?
Maybe it’s more to do with waffle and bluster taking a lot of resources to do an inferior job? That would probably count for every politician in the UK at the moment. I would say “just look at Brexit”, but that’s gone so far beyond parody that there aren’t really words for it…
Possibly this. :-) It’s possibly not a surprise that, on Android where time and power consumption are important, the sort-of-Java-like apps are translated to native code (for the device in question) while the app is being installed. [that’s why after about Android 4 installation suddenly got slower] |
Tristan M. (2946) 1039 posts |
This is too interesting. I don’t want to say who was closest to my intended meaning any more. |
Steffen Huber (91) 1953 posts |
I guess you didn’t have an intended meaning at all and just wanted to invoke an interesting discussion :-) |
Tristan M. (2946) 1039 posts |
I did, but I’m starting to feel that I asked why a raven is like a writing desk. |
Steffen Huber (91) 1953 posts |
And that basis looks like a rotten basis to me. There are many many Java implementations that are both fast and use little cpu and memory resources. In modern times, it is even not easy to find out if something is implemented in Java or not.
That cannot possibly the case, e.g. the best PDF/AFP viewer out there is written in Java. And the best Srpite viewer, too :-)
Java is probably the most-used language for writing software, so it is likely that you will – in absolute numbers – encounter more slow/bloated Java software than software written in other languages. If you find out which language the software is written in. An alternative logical conclusion would be that your experiences go right back to the dark ages of Java and you don’t like to challenge your prejudice. Or you are working in an area where large monopolists shove badly written software down the throat of their “users”, and these happen to be written in Java. Cisco and Oracle spring to my mind. Believe me, they would produce appalling software in any language you choose. |
Steve Pampling (1551) 8170 posts |
You could say I go back to the dark ages of computing so there’s a fair chance of the experience being the same.
I just keep find slow clunky stuff and it turns out to be Java or…
… I could agree with you totally on at least one point. |
Rick Murray (539) 13840 posts |
I have knowingly used two large projects written in Java – Arduino IDE and Eclipse. Both were memory hogs and tediously slow. I don’t make much use of Java (my browser has been told to not even attempt to load it) so my experience really is those two IDEs.
My PC runs XP (so not struggling), it’s a P4 clocking 2.8GHz. Compiling the ~300K of ESP32WebRadio (the fancy one on GitHub) takes longer than a Pi2 building its ROM from scratch. I have no specific prejudices for or against Java. As far as I’m concerned, it’s a “sort of C++-like language” that (usually? always?) outputs code for a virtual machine rather than native executable. It will be slower due to the JVM overheads, and it will use more resources because of the JVM underneath, however on the other hand it does offer the ability to run the same software on various machines – anything capable of running the JVM. What I noticed was that the IDE was ridiculously slow. Then I noticed it was written in Java. Maybe it is directly related, maybe it isn’t. I don’t know. It’s slow in a way that makes you lose the will to live. As Steve said:
My experience is not great, however… slow and clunky stuff does indeed turn out to be Java… and if it is slow and clunky and big then it’s probably something oddball like Python with its own portable interpreter included… I could also talk about the horrific performance of J2ME on feature phones, and the same thing in the early days of Android (why apps are now ‘compiled’ to native code upon installation). :-)
That’s a possibility too. Remind me, who is responsible for the official Windows JVM these days? Maybe it’s not a lousy IDE or a lousy language but simply but a lousy JVM? … While we’re here, since you seem to be the local Java guy… ARM implemented hardware Java of some description in Jazelle, but as far as I’m aware it was never publicly documented. Are you aware of anything making use of this, or it is mostly there for embedded mobile phone environments? |
Rick Murray (539) 13840 posts |
Tell me about it. The power consumption is directly related to the WiFi transmit power – I can say that because when the WiFi is good in my room (around -80dBm), the module runs fairly smoothly with only minor flickering of the LCD. When WiFi is not good (around -90dBm), the LCD flickers like crazy and more than once the module will simply crash. It seems like it’s a rather crap WiFi implementation (my Vonets doesn’t behave like that and it’s in close proximity so has a similar sort of signal strength). I’ve added capacitors to the +5V and +3.3V, 330µF 16V – biggest I have handly – which helps a little… |