Arduino to ESP8266 Data With Serial Communication Using Arduino IDE (Mac OSX and Windows)

Sdílet
Vložit
  • čas přidán 7. 08. 2024
  • • $2 for PCB prototype (any color): jlcpcb.com/
    ==========
    • Your support helps me post videos more frequently:
    / acrobotic
    www.paypal.me/acrobotic
    buymeacoff.ee/acrobotic
    BTC: 1ZpLvgETofMuzCaKoq5XJZKSwe5UNkwLM
    ==========
    • Find me on:
    / acrobotic
    / acrobotic
    / acrobotic
    ==========
    • My shops:
    acrobotic.com/shop
    amazon.com/shops/acrobotic
    ==========
    • Description:
    Often times we need to report data collected from sensors to a 'central' location for visualization. Typically, we use cloud services such as Thingspeak, myDevices Cayenne, or Ubidots for this purpose. However, it is possible to dedicate an ESP8266 to carry out these tasks.
    In this video, we configure an ESP8266 to serve data that's collected by an Arduino UNO. Having 5 analog ports, the UNO is able to interface with more sensors (in this case ones that measure gas and distance) than the ESP8266. Using their respective Serial UART ports, the two ICs are able to transmit data. The ESP8266 sends a "request" message formatted in JSON, which once received by the UNO, triggers a response containing the data. Once the data is received by the ESP8266, it is served on a simple webpage via a standard web server ( • ESP8266 Web Server Ste... )!
    ==========
    • Project parts:
    ACROBOTIC Development Board for ESP8266:
    acrobotic.com/products/acr-00018
    amzn.to/2dAZ1mW (affiliate)
    ACROBOTIC Uno (clone) Development Board:
    acrobotic.com/products/ard-00001
    ==========
    • Project code:
    Firmware for the Arduino IDE:
    github.com/acrobotic/Ai_Tips_...
    ==========
    • Related vids:
    Getting started with the ESP8266 using Arduino: • ESP8266 Web Server Ste...
    ==========
    • Tutorials:
    Detailed guide for getting started with the ESP8266 Development Board:
    learn.acrobotic.com/tutorials/...
    Detailed guide for getting started with the Arduino Uno (clone) Development Board:
    learn.acrobotic.com/tutorials...
    ==========
    • Sponsor:
    This video was sponsored by JLCPCB.
    ==========
    • Music:
    Epidemic Sound (epidemicsound.com). Standard CZcams License.
    ==========
    #ESP8266 #Arduino #Tutorial
  • Věda a technologie

Komentáře • 114

  • @madspoulsen4243
    @madspoulsen4243 Před 4 lety +7

    The startup WIFI status output to Serial, generates a invalid response which causes the whole communication to be out of sync. I'm getting "delayed" values, meaning the if I request a web update, then I get the values from the update before.
    I solved it by emptying the serial buffer at the end, ensuring that nothing is left. Insert a Serial.readString(); just after server.send

    • @datasith
      @datasith  Před 4 lety +1

      Great tip, Poul. I'll pin your message for those following the code!

  • @JuanCarlosGarfiasTovar
    @JuanCarlosGarfiasTovar Před 3 lety +2

    This was the tutorial that saved my life, thank you so much. The explanation and steps were great!

  • @kunalsanghvi4280
    @kunalsanghvi4280 Před 2 lety

    Your video actually helped a-lot, thankyou for making a wonderful and instructional video.

  • @paulgibby6932
    @paulgibby6932 Před 5 lety

    Thanks! Another great video and project. All the best

    • @datasith
      @datasith  Před 5 lety

      Thanks so much Paul. I'm glad you liked it!

  • @neilvermeulen1407
    @neilvermeulen1407 Před 5 lety +2

    Nice! Well done. Quick and easy.

    • @datasith
      @datasith  Před 5 lety

      Thanks so much, Neil! After a few years of practice, I might be getting the hang of it :)

  • @Imancu07
    @Imancu07 Před 4 lety

    Excellent video! keep up the good work!

    • @datasith
      @datasith  Před 4 lety

      thanks so much, i'm glad you found it useful!

  • @madspoulsen4243
    @madspoulsen4243 Před 4 lety

    If you're tired of waiting "forever" for the response, speed up things a lot by adding: Serial.setTimeout(20);
    in your Setup method, on both the Arduino and the ESP.
    It will be lightning fast, but perhaps you need to adjust the timeout value. Also running 115200 on the serial port speed is great.
    Thanks for the video by the way, ACROBOTIC. You saved me a lot of time with this simple setup!

    • @datasith
      @datasith  Před 4 lety

      Heya, Poul. Thanks for watching, I'm glad you found the code useful!

  • @tevintemu105
    @tevintemu105 Před 4 lety +1

    Great video , it helped me alot !!

    • @datasith
      @datasith  Před 4 lety

      I'm glad to hear it helped you, thanks for watching!

  • @sibujacob977
    @sibujacob977 Před rokem

    Hi, I like the clarity of the speech....!!

  • @deepakdgreat
    @deepakdgreat Před 2 lety

    Serial.print puts data to serial port and it's a loop then between Arduino and ESP8266. Is there any workaround or just not use Serial.print at all for debug statements ?

  • @neerajgupta7013
    @neerajgupta7013 Před 4 lety

    what changes do I need to make in the code if I don't want the request part in the program?

  • @sinchanagupta
    @sinchanagupta Před 3 lety

    Thank you for the wonderful video. I finally understood serial communication. Is there any way, I can include port number in the server? Because I'm using this code along with Node.js to create an express server.

  • @Latigo1969
    @Latigo1969 Před 5 lety +1

    Muy didáctico, excelente!!!.

    • @datasith
      @datasith  Před 5 lety

      Gracias Cristian, me alegra que te haya gustado!

  • @Leo-vy6fz
    @Leo-vy6fz Před 2 lety +1

    hey can we do this using esp32 instead of esp8266what are code differences

  • @simonlukas1566
    @simonlukas1566 Před 2 lety

    Does this also work if i only have one usb port on my Laptop? What can I do if the esp8266 registered in my network but the local webpage does not Show anything while loading ifinitly?

  • @TheGood59
    @TheGood59 Před 4 lety +1

    Since that esp 8266 uses 3.3v in their ports and Arduino uses 5 V, isn't possible to damange the esp ?

  • @thennz29
    @thennz29 Před rokem

    can i assign tx,rx pin to other pin in arduino bcoz im already using that tx,rx for other purpose.

  • @danielman3531
    @danielman3531 Před 2 lety

    I have a problem when opening the webserver with the IP adress. It takes a few minutes to show the sensor data on the page. What could be the issue?

  • @zee-lab-electronics
    @zee-lab-electronics Před 5 lety

    Great job

  • @HakkiOgrt
    @HakkiOgrt Před 2 měsíci

    Thank you.

  • @jelkabisa
    @jelkabisa Před 3 lety

    Hello,
    Please I really need your help, I want to finalize a project but I'm stuck with sending information from one board to another, could you please help? maybe something is wrong with my code.

  • @jktipan87
    @jktipan87 Před 3 lety

    Excelente mi estimado saludos desde Ecuador, una consulta en el Node MCU esp8266 como envío los datos hacia thingspeak ya qué te permite generar gráficas

  • @TechnoAutomation
    @TechnoAutomation Před 5 lety

    Your tutorials helped me a lot.
    Thanks for making such a wonderful video.
    I am doing project in which I interface Esp12F with Arduino promini.
    I planned to use ASCII code base technique.
    Like. Send character 'Q' for query. & Response Star with 'R' followed by data..
    After watching your video I changed my plane & will try JSON as you have shown.
    My question is what benefits I get if used JSON formated data??

    • @datasith
      @datasith  Před 5 lety

      I'm glad the info in my vids is useful! The main benefit in this case is being able to address your variables by key, for example data["temperature"]. It makes the code more readable and organized. The main benefit overall is that it makes 'chunks of data' easy to parse.

    • @TechnoAutomation
      @TechnoAutomation Před 5 lety

      @@datasith thanks. In my method I have to do lots of character checking in code & chance of error is high.
      So if I use JSON format then codeing time also reduce.
      Thanks for your reply.

  • @CuongBui-se8yb
    @CuongBui-se8yb Před rokem

    i got error when i upload code to esp8266, it say: esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header , how can i fix this

  • @ayushmishra1975
    @ayushmishra1975 Před 2 lety

    How many sensor data can be send through DynamicJson

  • @mb-3faze
    @mb-3faze Před rokem

    I have to disconnect the rx and tx wires each time I upload to either the ESP or the UNO. Otherwise I get a timeout on the upload.

  • @josemanuelbarajasramirez1821

    How could I do the same process but instead Arduino to ESP8266, ESP8266 to Arduino?

  • @eduardoesposito8013
    @eduardoesposito8013 Před 2 lety

    muy buen video!!!, pero lo mejor es la camiseta argetina!!!

  • @user-cc3eu4ng7f
    @user-cc3eu4ng7f Před 4 lety +1

    Thank you
    Please I have question
    Can we use software serial to send data like time and RFID card uid instead of arduinojeson

    • @datasith
      @datasith  Před 4 lety +1

      Yes you can. You can even use ArduinoJson and SoftwareSerial together. ArduinoJson just gives us an easy way to format the data.

    • @user-cc3eu4ng7f
      @user-cc3eu4ng7f Před 4 lety

      @@datasith
      thank you for answering my question .can you please tell me how can i send RFID card UID from Arduino to
      NodeMcu ,i need to know it as soon as possible for my graduation project . if you can't . could you please give me some link for tutorial.

  • @S0K0N0MI
    @S0K0N0MI Před 4 lety

    Very cool, and very close to what I want to do.
    Is there a way you can add buttons to the website so you can interact with your arduino?
    For example I would like to turn on a light with my phone, can you do it with this?

  • @NirzanAkmal
    @NirzanAkmal Před 4 lety

    Hi. Is there any other way to parse the input without typing in the input of the serial monitor?

    • @datasith
      @datasith  Před 4 lety

      Hi! At first, I use to simulate the data sent from one board to the other. But then, I let the two boards communicate between themselves and I only use the Serial Monitor to monitor the communication, so no typing is involved. Thanks for watching!

  • @abujarad60
    @abujarad60 Před 4 lety

    the esp8266 is 3.3v not 5v regulated, connecting the tx of the arduino to rx of the 8266 will burn it right?

    • @datasith
      @datasith  Před 4 lety

      You're right that in principle these operate at two different voltages. The documentation on the ESP8266 indicates that the pins are not 5V-tolerant. However, some online discussions suggest that the pins are indeed 5V-tolerant, so out of laziness I'm going with that :) In my many experiments with it, I've never burned one, but if you wanted to be safe use a level-shifter. Thanks!

  • @TresnaWidiyaman
    @TresnaWidiyaman Před 4 lety

    Its work !
    Other time i try to modify this program, and remove webserver view to be display json data on serial monitor.
    I save the json program in void loop, but i have a error in my program. Nodemcu can't read the json data from arduino.
    Can you help me ?

    • @datasith
      @datasith  Před 4 lety

      Hi, Tresna. I'm glad you're giving the code a try! Unfortunately with almost 20,000 subscribers I can't help everyone individually. If you tell me what sort of errors you're getting I might be able to point you in the right direction. Thanks for watching!

  • @MarianCimpean
    @MarianCimpean Před 4 lety

    Hello. I have one question. I want to make a communication between an arduino uno/mega and nodemcu with esp8266 module with i2c.I saw this tutorial and i want to ask you : can I power up the nodemcu from the arduino? I mean to make a connection between 3.3v arduino's pin and Vin pin from nodemcu.

    • @datasith
      @datasith  Před 4 lety +1

      heya, yes you can, but read in full to know a risk! 1) depending on the NodeMCU board you have, you'll probably need the 5V pin on the Arduino to go into the Vin pin of the NodeMCU. Yes, the ESP8266 is a 3V3 chip, but the NodeMCU board *typically* has a voltage regulator at Vin. 2) where the voltage difference is important is on the SDA and SCL lines. they will be 5V because that's the operating voltage of the Arduino. in theory, the ESP8266 isn't 5V tolerant so you should use a level shifter (e.g., 74LVC245) to convert the 5V down to 3V3. but, in practice, communication works without the level shifter. it's up to you if you want to take the small risk. hth!

    • @MarianCimpean
      @MarianCimpean Před 4 lety

      @@datasith Thank you very much. I also own a level shifter but I wasn't pretty sure if I realy need it.

    • @MarianCimpean
      @MarianCimpean Před 4 lety

      @@datasith and also the board is NODEMCU v3 LoLin

  • @michaelgyimah7646
    @michaelgyimah7646 Před 4 lety

    this video was off great help but instead of sending it to a website can you help be sen it into a database

  • @tapsonkadakure9158
    @tapsonkadakure9158 Před 4 lety

    Great video and its easy to understand, however i ran the code on mega, the url/web request trigures the function handleIndex and data is sent to mega but the esp cannot deserialise the response it says "{"type":"request"}DeserializationJson() failed: IncompleteInput"

    • @datasith
      @datasith  Před 4 lety

      Thanks, I'm glad you liked it. It seems you're getting a bad response from the server. Print it out to the Serial Monitor before trying to deserialize to find out what's wrong. HTH!

  • @donvukovic
    @donvukovic Před 5 lety +1

    At about 2:12 you mention opening a second Arduino IDE instance. How do you do that in Windows 7 ?

    • @datasith
      @datasith  Před 4 lety

      Sorry I don't have a Windows computer at the moment to try it out :(

    • @JuuMtz
      @JuuMtz Před 4 lety

      I inserted the path . For example: “C:\Program Files (x86)\Arduino\arduino.exe”

  • @miladk.2064
    @miladk.2064 Před 4 lety

    I'm having issues getting this to work on my Arduino Nano, ESP-01, and OLED screen. When I run the code with the OLED commented out, the web server loads no problem. However once I uncomment the code for the OLED, the web server does not load up. Also, the OLED may or may not turn on. Any idea what could be going on?

    • @datasith
      @datasith  Před 4 lety

      Make sure you're not writing locking code in your loop function. The server.handleClient() function needs to run relatively fast for the web server to work properly. HTH!

    • @miladk.2064
      @miladk.2064 Před 4 lety

      @@datasith Thanks for your reply. It seems like the issue was with the Arduino Nano not having enough RAM. We ordered the Arduino Every and everything is working fine now.

  • @S0K0N0MI
    @S0K0N0MI Před 4 lety

    What could be the reason for the ESP8266 page being loaded excruciatingly slow?
    And with slow I mean it takes a full minute for it to cough up 3 values. :(

  • @riemanndiy6693
    @riemanndiy6693 Před 4 lety

    Can I ask you if you are using the NodeMCU with Lua or AT commands? Because I followed every step of this video and it is not working for me. Could it be because you are using AT commands? Thanks

    • @datasith
      @datasith  Před 4 lety

      when you flash firmware to the NodeMCU, it wipes out what was previously there. you need a specific firmware to run either Lua or AT commands. so, in my case i'm running custom firmware. where exactly are you getting stuck?

    • @riemanndiy6693
      @riemanndiy6693 Před 4 lety

      @@datasith Well I have tried and now it works! LOL. The only thing that miss and would be awesome, is to add to the web server an autorefresh every x second. How can I do this? Thank You so much,you do a great job!!

    • @cadmarins
      @cadmarins Před 2 lety

      @@datasith basically the custom program runs away from the AT commands right?
      Here AT commands do not respect timeout, it asks for connection, the host does not respond, then it happens that the Arduino program crashes. Terrible. I just want the arduino to send the variables to the esp, and the ESP8266 to handle all the connection request part, if the connection drops, reconnect and so on, in addition to the benefit of freeing a good part of the arduino's RAM. So your video shape solves these problems?

  • @yaomercader3079
    @yaomercader3079 Před 4 lety

    im getting error in my handleIndex why?

  • @tomscietvirs2379
    @tomscietvirs2379 Před 4 lety

    Hello
    will this manual also apply to ESP 12-E?

    • @datasith
      @datasith  Před 4 lety +1

      hi! yes, it will apply to any ESPx chip, even the ESP32 with some minor changes. hth!

  • @sangarmutusamy9801
    @sangarmutusamy9801 Před 3 lety

    Hi, how to send more sensor data (say about 10 data)?

    • @ayushmishra1975
      @ayushmishra1975 Před 2 lety

      Have you done that yet, i
      f yes please send me some information?

  • @liranbar1156
    @liranbar1156 Před 4 lety +1

    And how do I send data from the ESP8266 to the Arduino?

    • @datasith
      @datasith  Před 4 lety

      Exactly the same way, you can switch the read and write, and you'll send data the other way. HTH!

  • @diegomartino
    @diegomartino Před 4 lety

    HI..!! thank for your video.. your channel its great..!! I tested your code and works but when I send requests quickly the deserialization fail and return noMemory and remain blocked. I tested increasing the size of memory from (1024 to 2048) but when I do this its fail directly Im using an arduino Uno and a nodemcu. Its posible solve this problem or I need to use anothe approach to send a request multiples parameters quickly?!

    • @diegomartino
      @diegomartino Před 4 lety

      I solved the problem... this was the memory I asign to doc.. 1024 its a lot.. with 256 works. now the problem its the delay of reaction that its arround one second.

  • @w35l3y
    @w35l3y Před 4 lety

    03:55 What if there are more serial data available? The current loop will overwrite the message and only keep the latest message. Is that expected? Thanks.

    • @datasith
      @datasith  Před 4 lety

      notice that the while() loop is blocking, so as long as the connection doesn't close, the data will be read. thanks for watching the video!

    • @w35l3y
      @w35l3y Před 4 lety

      @@datasith Yes, it will keep overwriting the message because it is using "=" and not "+="
      So the second iteration will overwrite the message stored on the first iteration.

  • @calvin-7540
    @calvin-7540 Před 4 lety

    “ Distance & gas is not declared in this scope “ What can I do? These two variables are written after “double”. I copied the code and it didn't work

    • @datasith
      @datasith  Před 4 lety

      double-check your code. you can check out the original sourced following the link in the description, thanks for watching!

  • @helenapoljak3353
    @helenapoljak3353 Před 4 lety

    I'm getting an InvalidInput error. Do you know what the problem might be? Thanks

    • @datasith
      @datasith  Před 4 lety

      heya helena, it must by a typo on the data that is being sent. if you send me the code i can have a quick look!

    • @helenapoljak3353
      @helenapoljak3353 Před 4 lety

      @@datasith I found a solution. Thanks :)

    • @viktor7425
      @viktor7425 Před rokem

      @@helenapoljak3353 what was the solution?

  • @med6402
    @med6402 Před 5 lety

    i've been waiting for this but how to make the web page refrech automatically every a time chosen variable for example every 5s

    • @datasith
      @datasith  Před 5 lety

      I have other videos showing you how to use websockets and AJAX. You'll need to combine that approach with the one showed in this video.

    • @med6402
      @med6402 Před 5 lety

      @@datasith thank you so much

  • @HamzaHajeir
    @HamzaHajeir Před 5 lety +1

    Nice and Neat!
    and,, Vamos Argentina

  • @LeoL123
    @LeoL123 Před 4 lety

    I hope that you could save the data into a file and store it in spiffs. So the data file can be managed later.

    • @datasith
      @datasith  Před 4 lety

      i have other videos on storing data in SPIFFS (ssid and password). maybe you can re-use the code from there?

    • @LeoL123
      @LeoL123 Před 4 lety

      @@datasith I have watched your video, It is quite straight forward. However, I want to store dynamic data which stored every single minute into spiffs from serial or the other GPIO pins. Managing the files like delete, rename etc, therefore I can utilize 3mb of spiffs instead of using microsd module.

    • @datasith
      @datasith  Před 4 lety

      @@LeoL123, storing the data should also be 'straight forward' using my OTA code. Instead of storing the SSID and password in the setup function, you should move the code that writes to the File System to wherever you're trying to store the data.

  • @sanaullahkayani6481
    @sanaullahkayani6481 Před 4 lety

    Sketch uses 294304 bytes (28%) of program storage space. Maximum is 1044464 bytes.
    Global variables use 27672 bytes (33%) of dynamic memory, leaving 54248 bytes for local variables. Maximum is 81920 bytes.
    esptool.py v2.8
    Serial port COM6
    Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
    File "C:\Users\sunny\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/upload.py", line 65, in
    esptool.main(cmdline)
    File "C:/Users/sunny/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2890, in main
    esp.connect(args.before)
    File "C:/Users/sunny/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 483, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
    esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
    esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
    _
    Sir, the Following error occur while uploading esp_firmware. Please help me how can i resolve it. Thanks

    • @datasith
      @datasith  Před 4 lety +1

      Seems like you're having USB communication problems. This could be due to a bad USB driver, or not selecting the correct port for the ESP8266 board. HTH!

  • @helaliwail6572
    @helaliwail6572 Před 4 lety

    can you please provide the sketch used in the video
    thank you

    • @datasith
      @datasith  Před 4 lety +1

      Did you check the video description? 🙄

    • @helaliwail6572
      @helaliwail6572 Před 4 lety

      @@datasith sorry to bother you but i don't see any link in the video description for the sketch used in this video.
      Thank you

    • @helaliwail6572
      @helaliwail6572 Před 4 lety

      @@datasith sorry i found it thank you. I want to know if is it possible to have some tutorials about tbe nextion HMI screen for arduino.
      Thank you

  • @GersonRicha
    @GersonRicha Před 5 lety +1

    Pretty t-shirt! i have one... hehehehehe

    • @datasith
      @datasith  Před 5 lety

      VAMO' ARGENTINA CARAJOOOOO!!! (lol)

    • @GersonRicha
      @GersonRicha Před 5 lety

      ACROBOTIC 😂😂😂 but i am Brazilian...

    • @datasith
      @datasith  Před 5 lety +1

      @@GersonRicha I imagined being named "Gerson" :) If we face each other in semis and you win (likely) I'm banning you from the channel! (j/k)

  • @MPED05
    @MPED05 Před 4 lety

    It would be great if you would upload the code too.

  • @pushparajbhatta
    @pushparajbhatta Před 4 lety

    Hi ,
    Thank you very much for this. It is really helpful. I am getting the following error:
    ets Jan 8 2013,rst cause:4, boot mode:(3,6)
    wdt reset
    load 0x4010f000, len 1384, room 16
    tail 8
    chksum 0x2d
    csum 0x2d
    v8b899c12
    ~ld
    ______________________________________________
    The rst cause:4 means watchdog reset which is caused due to the while loop in esp code, I tried using delay, yield, and also ESP.wdtDisable();
    but I am getting same error. I am creating server as AsyncWebServer server(80);
    I have also posted the issue here: github.com/esp8266/Arduino/issues/7344

    • @datasith
      @datasith  Před 4 lety

      Hey, Pushpa. Thanks for watching the vid, I'm glad it was helpful. The error is a standard reset as you point out. You can't do too many things in the loop when you're running a server, so you'll need to find a way to execute your tasks differently. You've already tried the easy-fix solutions, so you'll need to attempt to modify your code. HTH!