Hacker News new | past | comments | ask | show | jobs | submit login

I picked up an ESP32 devboard recently. I've always been intrigued by embedded but don't have a background in it at all.

I have no idea what my first project should be. Any ideas?




The barrier to entry has never been lower. Last night I prototyped some code in Python on my Mac to talk to a Bluetooth peripheral, and then had ChatGPT translate it to Arduino C++ code for a $5 ESP32, and it mostly worked on the first go.

You can even run Python on microcontrollers these days. See Adafruit's https://circuitpython.org for which they publish modules for many (almost all?) of the sensors they sell. The modern microcontroller frameworks hide much of the complexity of Wi-Fi, Bluetooth, filesystems, etc. so you can do complicated things with minimal effort. You can really cobble something together in an afternoon.

The "hello world" of microcontrollers is making an LED blink. Then figuring out how to print a message out over serial (print debugging is invaluable). Then maybe figure out how to make a Wi-Fi connection and an HTTP request. Then go on a shopping spree on Adafruit or SparkFun for $9 sensors that spark your imagination and figure out how to talk to them; Adafruit publishes zillions of tutorials you can copy from: https://learn.adafruit.com


Make an LED blink.

Then, connect an RGB LED and experiment with PWM signal generation.

Then, experiment with network programming, accepting a UDP packet to the ESP32 that sets the color of the RGB LED.


Alternatively, you can go high-level immediately - instead of accepting a UDP packet to set the color, run a webserver on it with functionality to change the RGB LED color that you can access from any browser. Modern microcontrollers have enough resources to just spend them like that.


Are we talking lightweight servers like minihttp and shizaru, mid-level lighttpd , or big-ass Apache and nginx?


We're talking lighter than minihttp and shizaru - instead of a separate process on an OS, you'd use library that allows your firmware to respond to http requests, but that still allows you to run all the relatively complex UI/UX code on the user's computer or phone, with the microcontroller only handling the physical functionality; and reduces the need to have and manage more physical buttons/lights/screens/etc on the device itself; but you can do that without writing a separate app to generate some custom command&control messages - as in the grandparent post example of encoding RGB light control in an UDP packet, it would probably need three times the amount of code both on sending and receiving side compared to a http-based rgb control, which can probably be done in ten or so lines of your own code.


Oh, that's pretty neat. Basically trimming the server down to the routing itself.

    1. accept HTTP
    2. check for valid endpoint
    3. if yes, do thing and exit
    4. if no, 'error'
Client side has fancy UI for essentially templating per-HTTP request or command sent to the device.

I guess the only issue I see is you'd need some sort of firewalling or security. Otherwise any rando could fire HTTP requests at the thing and make it do stuff.

How would you structure this on the device's side? If a webserver's too big, then I imagine an init system is also too big.


You generally don't structure it as having a webserver, you'd structure it as an app (you run a single app on the device, there's no separate OS involved) that can react to HTTP requests - i.e. my mental model is that you don't run a webserver on the device, but instead that the device becomes a webserver.

You can structure the on-device app as 'slaved' to the web requests, where it simply waits for requests in a loop and only does stuff in response to a request - for example, take a measurement from some sensors and send them back with some surrounding HTML.

Authentication/authorization is an issue, but it has all the same issues and solutions as webapps - login+session cookies; or whitelisting IP ranges; or TLS client certificates; etc.


Pretty barebones but working web servers are possible. Example: https://randomnerdtutorials.com/esp32-web-server-arduino-ide...


ugh.. arduino.

Better to start with ESP-IDF, there's a pretty full featured well documented web server, and a lot more.

https://github.com/espressif/esp-idf/tree/master/examples/pr...


Just install ESPHome on it :)


It seems to have gone out of favour for some reason I don’t understand, but subscribing to an MQTT topic from an ESP is easy and performant.


Depending on the board and language support, a good first time project is syncing a real-time clock to NTP. At least that was my first one, followed by a wifi signal scanner. I was using MicroPython which is fast and easy, C is a little more work obviously.


Have a look at https://docs.toit.io/tutorials (using Toit).

I wrote lots of easy to follow tutorials there.

It depends a lot on the sensors you have. That said, even without any (or few) sensor(s) you can still have fun with network related applications like a Telegram bot.


There are a lot of interesting sensors out there. A good start can be by picking a sensor you're interested in and use it for monitoring. It can be as basic as temperature monitoring, or gas/CO2.


I tried making a small servo tester as a first small project on the esp32. I obviously took the servo testing code from somewhere else but yeah, the control part was useful.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: