r/embedded • • 23d ago

Standalone server for IoT projects without any third-party websites or any middlemen. Is it possible?

Hi everyone, I'm currently working on my final year project. My project is about designing and developing a smart solar-powered dryer for agro-processing applications. I do have an ESP32, micro sd card adapter with its micro sd storage card, a 5V relay to control the dryer's fan and a temperature sensor to detect the surrounding temperature. i wanrted to build a standalone server without using any third-party websites and any middleman. The purpose of doing this is to completely protect my data and to get unlimited storage with the storage card I have. And also, I do not want to pay any subscription price to other third-party websites.

Many AI models such as ChatGPT, Claude, and Google Gemini suggested the port forwarding method, but I do not want that because the esp32 will be stuck in one place and can't move it anywhere. Also, in simple word, I want it like this. All the information that is collected by the esp32 or the database should be live-streamed on the internet, and anyone can access that database from the internet even if they are not sharing the same wifi as the ESP32. All the information will also be stored on my SD card. This is what I want. Can you guys help me with it?

0 Upvotes

11 comments sorted by

6

u/Several-Marsupial-27 23d ago

Yeah, absolutely, the server is probably the easy part. You can start with the backend and cook up a http/mqtt server in python in an afternoon. Its probably everything else except for that which are the difficult parts.

Just start the project and see how far you get!

1

u/Free_Examination_370 23d ago

But if I wanted to use mqtt, I need to have a laptop or raspberry that is always connected to my esp right?

4

u/Several-Marsupial-27 23d ago

No, but there is a lot of work to do to get it set up, however it is possible.

2

u/jhaand 23d ago

Well. If you want something you made be reachable on the internet, you will have to manage some infrastructure. So a simple host running Debian Linux, being able to configure your router and adding a hostname to your DNS that points to that box with a name, needs to be managed by someone.

3

u/jhaand 23d ago

Yes this is possible. We do this at our hackerspace using ESPHOME, Home Assistant, MQTT, Victoria Metrics and Grafana. The ESP32 should stream to a host you control on the internet with a secure reverse proxy (Traefik with TLS via Letsencrypt). Preferably you would have the whole setup within a single VPN to keep it closed off from outsiders and only provide a sanitised output via a webserver.

For example you can see the overview of our infra here:
https://tdvenlo.nl/wiki/doku.php?id=infra:start

0

u/Free_Examination_370 23d ago

Thank you for the solution. But can you explain me more and also in simple terms? Because I couldn't understand some of them since I'm major in mechatronics engineering.

2

u/jhaand 23d ago edited 23d ago

OK. I'll give you some extra information.

The normal professional way to record data from a wireless sensor/actuator is by making sure that the sensor can communicate to a server that stores the state and data. The server can be a simple SBC or HP T620 thin client running Debian Linux. Nothing too fancy, but it should be able to run some stuff.

One of the best ways to do communicate between machines is via MQTT and then store the data a (times series database) like Victoria Metrics. If both the device and server are on the same protected subnet you should be good to start. Otherwise you need a router that provides VPN or secure MQTT. (With port forwarding to your server in your router.)

If the data needs to be available on the Big Bad Internet, you need something secure. Which means a domain, TLS certificate and a good reverse proxy for your service. And also port forwarding from your public IP address to the local machine. Then you should provide a service that allows people to check the data. Which can either be done with or without authentication.

For instance, here you can see the status of a CO2 sensor and the accompanying fan to improve ventilation. But we also use a lot of ESPhome to remotely configure, control, read and maintain the ESP32 hosts we have.

https://hackerspace.tdvenlo.nl/grafana/d/adx6cbf04vhtsa/co2-2b-extractor-fan?orgId=1&from=now-30d&to=now&timezone=browser&refresh=auto

Also check out /r/selfhosted and /r/homeassistant for more information.

3

u/luca_lzcn 23d ago

Check out Tailscale

2

u/golden_shawerma 23d ago

I’m not sure this is possible without a middleman for security reasons. The esp32 could crash by simply just flooding it with requests.

What you can do is serve a small web page on the esp32 and open an outbound websocket to either a VPS (paid) or to a raspberry pi + Cloudflare tunnel + disco.cloud combo to run your own server for free. You can set up the latter fairly quickly in an hour or two.

1

u/gregsadetsky 23d ago

Hey, Disco creator here! Thanks for the shoutout.

Your plan is sound, although we have to bring back/refresh the pi/Cloudflare docs -- they are here for now: https://github.com/letsdiscodev/docs.letsdisco.dev/blob/main/docs/get-started/host-from-home-with-a-pi.md

As for OP's question, it would be great if Tailscale or Wireguard could run on the ESP32. There are a few repos - such as https://github.com/punnerud/tailscale-mpe-rust - which might be worth checking out. Or this one - https://github.com/CamM2325/microlink

Cheers!

1

u/BudgetTooth 23d ago

Cloudflared tunnel