I am currently working on a project which uses an ESP8266, accelerometer sensor and Raspberry Pi 4. The ESP module has to send the accelerometer data to the Raspberry Pi and the data has to be stored in the Raspberry Pi memory card in Excel or .csv format. I want the system to be portable so that there is no setting up process required when I take the system somewhere else. Just by switching on the Raspberry Pi and sensor, it automatically connects and starts sending data to the Raspberry Pi...

Is there a way to achieve this?

I am a beginner to Raspberry Pi and IoT, but I have basic knowledge in Arduino.

On the next level, I want multiple ESP modules to connect to a single Raspberry Pi (8). Is it possible?

  • Ah yes, your post is confusing. First of all, ESP8266 is a WiFi controller, so it cannot earn a living without connected to the internet. Now Rpi can connect to the Internet through a (wireless) WiFi router or (wired) Ethernet. Now suppose your e 3-in-1 whole thing, ie Rpi + accelero + ESP8266 is moved outside, away from your, say, home, which has the home WiFi router and Ethernet connected to your ISP (Internet Service Provider). Then you can now only rely on the small guy ESP8266. Anyway, now fun begins: ESP8266 can now start its WiFi job (don't ask me how, I am only a ESP newbie!:).
    – tlfong01
    Commented Jan 24, 2020 at 9:03
  • 2
    @tlfong01: Nope. WiFi is a local network connection, doesn't require access to the Internet at all: the ESP8266 can operate as WiFi client, and a RPi can operate as a WiFi AP (hotspot). Direct link, no internet required. Commented Jan 24, 2020 at 12:49
  • @Piskvor left the building, many thanks for pointing out wrong concept. I think I need to google and read more before thinking deeper.
    – tlfong01
    Commented Jan 24, 2020 at 13:15
  • 1
    For a university robotics project, we once grabbed a cheap wi-fi router and hacked together a way to power it from our robot's battery. That would be a fun idea if the Pi couldn't already do it. Commented Jan 24, 2020 at 18:14

2 Answers 2


You could have the Raspberry Pi behave like a WiFi access point (using hostapd and dnsmasq, introductory documentation from the Foundation is here) with a static IP and then have the ESP8266 join the hosted network and send the data to the Pi's IP address. The advantages are that you can also connect to the Pi from a PC or mobile device if you need to and it's relatively simple to add more ESP8266 modules with extra sensors if you needed to in the future (as far as the hardware is concerned anyway).

I think you could also do it the other way around: the ESP8266 could be the WiFi AP that the Pi joins and collects data from but I've not so much experience with the ESP so could not tell you if this would be a better or worse way of doing it.

  • 1
    Can we program the system so that the ESP gets connected automatically to the Pi when both are switched on? Is it possible? Commented Jan 24, 2020 at 10:23
  • 3
    Yes, I believe the ESP code can be configured to keep trying to connect to the specified WiFi network so should connect as soon as the Pi becomes available. I'll not go into details (as this is a Raspberry Pi specific site) but there are plenty of examples out there: e.g. 42bots.com/tutorials/esp8266-wifi-tutorial-arduino-ide Commented Jan 24, 2020 at 10:38
  • 1
    Sending data to the pi requires using Udp or mqtt protocol right? Which one is required in this case? Commented Jan 24, 2020 at 11:21
  • 3
    Pro's and Con's of which protocol you use for your project is going to be a matter of opinion and has nothing to do with the original question. I suggest you ask that question on another forum with more details on what you're trying to achieve and your background knowledge/experience: you are unlikely to get an answer here as it's a matter of opinion and not Raspberry Pi specific (see raspberrypi.stackexchange.com/tour for why). Commented Jan 24, 2020 at 12:19

There are different ways to sent data from an ESP 8266 or ESP32 to a Raspberry. For the ESP see amongst others ESPEasy, Tasmota, and hass.io. Transport is with MQTT, for data to a CSV file see for example https://github.com/nhonchu/mqttspooler. With (micro)python on the ESP module, there are other possibilities too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.