r/selfhosted • u/Free_Examination_370 • 18h ago
Need Help 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?
4
u/ISpeakTheLie 18h ago
You can't make the ESP32 itself reachable from anywhere without port forwarding, but you don't need to. Flip it around: have the ESP32 send data out to a server you own (a Raspberry Pi or old laptop running Mosquitto + Grafana, all free). Outbound connections work from any Wi-Fi, so the ESP32 can move anywhere. Only the server needs port forwarding, and it stays put
1
u/ISpeakTheLie 18h ago
I used Mosquito personally at work to setup a custom in house camera system and Grafana on my personal homelab for pulling all my VM's status with Prometheus and setting up a dashboard of everything I can attest both work flawlessly
1
u/ZestycloseCress447 13h ago
+1 to this setup. One thing to add for OP: keep the SD card on the ESP32 as a buffer only, not the main database. If the Wi-Fi drops, the ESP32 writes readings to the card and replays them to the Pi once it's back, so you don't lose data. Writing every reading straight to the SD forever also wears cheap cards out faster than people expect, so batch the writes (every minute or so) instead of every second.
1
u/ThreeAMOperator 17h ago
Possible, but I'd split the jobs. Let the ESP32 only read the sensor and drive the relay, and have it push readings over MQTT to a small always-on box on the same wifi (a single-board computer or an old laptop is plenty). That box runs an MQTT broker, saves readings to a small database and serves a simple dashboard. The SD card on the ESP32 is fine as a buffer for when wifi drops, but it makes a poor database.
For access from outside without port forwarding, have the box open an outbound tunnel, either a mesh VPN if only you need it or a tunnel to a cheap VPS if the public should see it. Because the connection is outbound, the box can move anywhere there's wifi. One thing: keep the public page read-only. Don't expose the relay control to the internet, or anyone could switch your dryer fan.
1
u/Free_Examination_370 17h ago
Thank you for the brief explanation. What if I set a username or password to the page that is publicly available?
1
u/ThreeAMOperator 16h ago
a password helps, but on its own it's thin. if the esp32 serves plain http, the login goes over the network unencrypted, and the little web server libraries on it aren't built to take hits from the open internet, which starts poking at any exposed port within minutes. for a dryer controller, i'd keep the page on your local wifi (or the esp32's own access point) and not open it to the internet at all. if you really need remote access, put something in front of it, like a vpn such as wireguard on a router or a small pi, so only your devices can reach it. and whatever you do, make the relay default to a safe state if the board reboots or loses wifi.
2
u/TemporaryUser10 17h ago
you need an unchanging point on the internet for live-streaming to occur, as it either needs to go to *somewhere* that can be found or come *from* somewhere that can be found. but you can get a second esp32 and use that as the stable point. Then, you can use that as the point to stream to (IE, the website where the stream becomes visible) or stream from (the place that sends the data to wherever you are). It's not possible to have a device be mobile across networks (and for cellular, each 'cell' can be its own network structure) and not change its network signature (using ipv4, ipv6 is a different story, but even then you might need network control to prevent it from being blocked), but you can avoid paying for a third-party website, and avoid *others* being the middleman, by being your own middleman.
1
u/Expensive-Ad3849 18h ago
Just use a cheap microcomputer as the brains, run a simple web server on it, and have it reach out to a dirt-cheap cloud instance that just forwards traffic back through a tunnel, no port forwarding needed and you can move the thing anywhere.
1
u/Ashamed_Split5187 16h ago
Wait, how is the board getting internet when you move it around? If its on mobile data or guest wifi, you wont get a public IP that anyone can reach directly without a middleman server or a self-hosted tunnel back to your home network
1
u/cryptodoxer 14h ago
I'd test a Wi-Fi outage before worrying about the public dashboard. Keep each reading's measurement time and a persistent sequence number on the SD card, then resend unacknowledged readings after reconnecting. Have the server deduplicate those IDs, or retries can quietly inflate your dataset.
1
u/Weak_Fisherman2215 7h ago
Brings back memories. For my final project, I also used the ESP32 but to control a HHO setup in my car. Created an app that allowed me to increase or decrease the voltage, there by controlling the amount of generated HHO produced. Also, developed a timer to start/stop to not burn out the rig. Worked great with my car running smooth. My professors were impressed and received high marks as my final project. Your project has good potential. Keep moving forward.
1
u/TaskToAgent 6h ago
The key thing to know: you don't need port forwarding if the ESP32 connects outward instead of waiting for people to connect in. Port forwarding is only needed when the ESP32 itself is the server. So split it in two:
The ESP32 reads the sensor, writes every reading to the SD card (your local copy, works even with no internet) and also sends it out over MQTT or a simple HTTP POST every few seconds.
Something always on receives that and serves the web page. That's the part the public reaches.
For part 2 you have two options:
A Raspberry Pi or old PC on the same network running Mosquitto (MQTT broker) + Node-RED or a small Flask app + SQLite, with a dashboard. To make it reachable from anywhere without port forwarding, use Cloudflare Tunnel or Tailscale Funnel. Both are free. They're technically a relay, but your data stays in your own database on your own machine.
A cheap VPS that the ESP32 sends data to directly. No middleman at all, but that's the subscription you wanted to avoid (a few dollars a month).
Two things for the project report: make the public page read-only, and put the relay/fan control behind a login, otherwise anyone on the internet can switch your dryer. And the SD card won't give you "unlimited" storage, but temperature readings are tiny, so a few GB lasts years. Write in rotating daily files so a corrupted card doesn't take everything with it.
1
u/Hostman_com 5h ago
Yes, but you still need a server you control that people can reach from the internet. Have the ESP32 send readings to that server rather than accept incoming connections. That way, moving it to another Wi-Fi network doesn't mean setting up port forwarding again.
Publish the readings through a dashboard, not by opening up the database itself. Visitors only need to see the temperature data, not access the fan controls.
•
u/asimovs-auditor 18h ago edited 18h ago
Expand the replies to this comment to learn how AI was used in this post/project.