Hello,
I have an Arduino Nano ESP32 which receives temperature readings from another device. I want to send/forward these readings to my Windows laptop. Thing is, my Arduino and laptop, although both connected to the internet, are not on the same WiFi or any other common network. Is it possible to achieve this without having to pay for services like AWS etc.? I feel like there must be a free way to do this.
Thanks!
If both devices are connected to the internet, then they are indeed on a "common network" and can in principle be made to communicate.
Provide the needed information, so that people can offer informed suggestions.
Thank you and yeah, that's true. Sadly though as a networking newbie I don't know what other information would be needed other than what I've shared. What else needs to be known? As I said, I have an Arduino Nano ESP32 and a Windows laptop. Both connected to the internet via WiFi, but no direct WiFi/Ethernet/other network connection between them. The nano receives sensor readings from another device via BLE, and I want to forward these readings to my laptop.
I've Googled and ChatGPTd quite a bit but all the solutions revolve around using a middle server be it AWS, MQTT, or the sorts. These tend to be paid though, and I'm looking for a non-paid way.
The solutions that we have mentioned (numbered packets, send with CRC error checking and acknowledge receipt, etc.) are perfectly standard and have been in use for many decades.
Forum members are unlikely to write the code for you, so your job is to learn about these techniques and look for or write ESP32 code that implements them.
Or, choose another MCU/radio platform for which standard packet based file transfer is already available.
Thank you.
The solutions that we have mentioned
Where are these mentioned? I checked if I was missing any posts here but I can't see any other messages.
1 Like
Sorry, I was thinking of another similar thread.
Both connected to the internet via WiFi, but no direct WiFi/Ethernet/other network connection between them.
Please describe the exact nature of the connections. What/who provides the WiFi network(s)? Home, work, coffee shop? Two different WiFi connections in different physical locations?
How are the WiFi routers connected to the internet, via which provider(s)?
My laptop is on my home WiFi network and I'm using a local provider for that. As for my Arduino Nano ESP32, I have a Raspberry Pi using a SixFab LTE Hat and I use hotspot to create a WiFi network for my Arduino Nano to connect. And like you said, these are two different WiFi connections in different physical locations. Naturally, this also means my Arduino Nano and laptop are in different physical locations too.
Hope I was able to share enough info. Thanks!
OK. This is not an Arduino problem.
In order for two computers to communicate via the internet, their IP addresses must be known and accessible, and the computers must have an operating system with application software, or simply be running code that supports data transfer.
The first step is to set up both nodes on each WiFi router to be remotely accessible. There are plenty of "How To" tutorials, such as this one: https://www.howtogeek.com/66438/how-to-easily-access-your-home-network-from-anywhere/
Naturally, this is a risky undertaking, because countless hackers are probing the network constantly.
1 Like
Or send yourself a data email from one device, and access that email from the other.
Thank you! Looks promising. I'll create an account and give it a try.
This is a really good idea too actually, nice and simple. That would be a bit too many emails but that's alright. I'll give this a shot. Thanks!
So Adafruit IO worked exactly as I wanted. If I put the Arduino Nano ESP32 on my home WiFi network with the below sketch, I am able to forward the temperature readings the Arduino receives to the Adafruit IO cloud.
But when I try the same (same sketch -except different WLAN ssid and pw-, same task, same everything) with the Arduino on my Raspberry Pi's WiFi hotspot ("sharing" its SixFab LTE Hat's mobile internet), although the Arduino gets assigned an IP, it's not able to transmit data to the Adafruit IO cloud and I get "Network disconnected" printed in from the while loop in my below sketch.
One might think maybe it's my Raspberry Pi's LTE Hat's setup that's causing the issue, but I'm also able to connect my phone and computer to the RPi's hotspot and they all connect to the internet without issues. So the sketch seems to work, IO cloud seems to work, LTE hotspot seems to work, but it doesn't work when I try to put the Arduino on the RPi's hotspot. Any idea why this could be?
Here's how I create the hotspot on the Raspberry Pi (4B, latest bookworm 64bit):
sudo nmcli device wifi hotspot ssid MyNetwork password MyPassword ifname wlan0
Only sharing the setup() function for simplicity. The sketch I'm running on the Arduino Nano ESP32:
#include <ArduinoBLE.h>
#include <AdafruitIO_WiFi.h>
// WiFi credentials
#define WLAN_SSID "MyNetwork"
#define WLAN_PASS "MyPassword"
//
// Adafruit IO credentials
#define AIO_USERNAME "MyUserName"
#define AIO_KEY "MyKey"
//
// BLE information
const char* deviceName = "BLE Central #0100";
const char* deviceServiceUUID = "MyUUID1";
const char* deviceCharacteristicUUID_Temperature = "MyUUID2";
//
// Create an instance of AdafruitIO_WiFi
AdafruitIO_WiFi io(AIO_USERNAME, AIO_KEY, WLAN_SSID, WLAN_PASS);
// Define the feed
AdafruitIO_Feed* AdafruiIOTemperatureFeed = io.feed("temperature");
void setup() {
Serial.begin(9600);
while (!Serial);
BLE.setLocalName(deviceName);
BLE.advertise();
// Connect to Adafruit IO
Serial.print("Connecting to Adafruit IO");
io.connect();
// Wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.println(io.statusText());
delay(500);
}
// Connection successful
Serial.println();
Serial.println(io.statusText());
}
That appears to be contrary to what you originally wanted.
My RPi will physically be with my Arduino at all times, at a location away from my home wifi network and laptop (that is connected to my home wifi network). So I do indeed what the Arduino to be able to use the RPi's hotspot. The Arduino is able to get an IP assigned when on the RPi's hotspot, and the sketch connects to the IO cloud just fine when I'm on my home wifi, but not when on the RPi's hotspot.
RPi will physically be with my Arduino at all times
I would have the Arduino send the data to the RPi via serial, over a couple of wires, and skip the wireless hassle. Or, more likely, just use the RPi for both activities, and skip the Arduino.
What worked was to use the Arduino IoT Cloud instead of the Adafruit IO Cloud. I seem to be setting up MQTT just the same but for some reason it doesn't work when I do it myself with Adafruit IO but does when Arduino's IoT library does it.