Communicating from an Arduino to an HTML/JavaScript Webpage

Sdílet
Vložit
  • čas přidán 8. 09. 2024

Komentáře • 144

  • @belnoccio
    @belnoccio Před 3 lety +27

    Exactly what I needed for a university project! Clear and simple, nice video!

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

    Was looking for a way to connect an Arduino sensor to a web page. After stumbling through several other videos, you nailed it! Very straightforward explanation. Thank you.

  • @TinyMaths
    @TinyMaths Před 5 měsíci +2

    This is pretty much what I'm looking for; I had no idea how to approach this but you've given me a place to start. Thank you!

  • @mehmetsunguralp5509
    @mehmetsunguralp5509 Před 7 měsíci

    It’s very exciting to see that you can control the opacity of the div by turning a real knob!

  • @shimakeemakenza4469
    @shimakeemakenza4469 Před rokem +3

    Priceless. Thank you for this. Nice and simple but great to build upon. I already know web development and looking into starting learning about micro controllers and stuff. This helps me alot.

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

    I love it how the code on the right in vscode / arduino IDE is so big and easy to read...

  • @richyrose99
    @richyrose99 Před 3 lety +8

    this is one of the best tutorials ive seen, very clear, so thank you and keep up the great work!

  • @humbertoalfaro1721
    @humbertoalfaro1721 Před 2 lety +1

    i like your style in your videos. Debugging picture was cool lol!

    • @codeadamca
      @codeadamca  Před 2 lety +1

      Hah, thanks! Didn't want to bore anyone while I was debugging, sometimes debugging takes longer than expected.

  • @nickstaresinic9933
    @nickstaresinic9933 Před 2 lety +2

    Nice. Very clearly organized and delivered.

  • @ShakilKhatri1
    @ShakilKhatri1 Před 2 lety +1

    Thank you @Adam for this video.

  • @tomjohansson3520
    @tomjohansson3520 Před 2 lety +1

    For sure one of the better videos ive seen! Thanks aot

  • @jhosbenxaviohurtadoherrera524

    Gracias por todo, me has enseñado bastante a solucionar errores que presentaban mis códigos. Un abrazo.

  • @fredrickmwepu3134
    @fredrickmwepu3134 Před 4 měsíci

    Thanks very much. We would like to see more of such videos
    God Bless

  • @chikondikajawo2706
    @chikondikajawo2706 Před 9 měsíci +1

    You saved my project

  • @shettyabhishay
    @shettyabhishay Před 4 měsíci

    Great explainer. However a lot of the code elements need to be updated for the latest node js and libraries. no complaints tho. It was a fun challenge

  • @user-iu9ql6dj4x
    @user-iu9ql6dj4x Před 3 lety +1

    It's really awesome video!Thank you!

  • @lolocomotive8553
    @lolocomotive8553 Před 3 lety +3

    On chrome 89 (released the 31st of August) it's actually possible to use the serial port right from the browser.

    • @codeadamca
      @codeadamca  Před 2 lety

      I will have to look into this! Sounds easier.

  • @gamer-tf2pe
    @gamer-tf2pe Před rokem +1

    Excalty what i was looking for from a month

  • @eduardogomescampos4204

    YOU SAVED MY LIFE, THANK YOU

  • @nicolaslondono8821
    @nicolaslondono8821 Před 3 lety +1

    Thanl you for this video, it helped me a lot

  • @JoaoNascimentoBrito
    @JoaoNascimentoBrito Před rokem +1

    Nice project! 👍

  • @yashaswikulshreshtha1588
    @yashaswikulshreshtha1588 Před 3 lety +6

    We all are struggling to make arduino projects and there are makers of arduino language and hardware, lol I wonder how easy are arduino projects for the makers of arduino.

  • @collinsk8754
    @collinsk8754 Před rokem +1

    Excellent!

  • @dungoxuan906
    @dungoxuan906 Před 3 lety +1

    amazing my friend

  • @shiyenhung2852
    @shiyenhung2852 Před rokem +1

    Thank you very much

  • @Monamona160
    @Monamona160 Před rokem

    greatest tutorial i have ever seen, thank you! one question, how can I affect my sketch instead of the html page?

  • @user-du8dr8dg4b
    @user-du8dr8dg4b Před 10 měsíci +1

    Hi, can you please explain the part at 12:22? where do I find the cdn? Thank you!

  • @MarcelOdT1020
    @MarcelOdT1020 Před 11 měsíci

    with node js how can add my own CSS document to be used for different fonts and colours etc?

  • @davem3953
    @davem3953 Před 2 lety +1

    Thank you.

  • @BGLENN-dp4tx
    @BGLENN-dp4tx Před 2 lety

    Great video. As a "teaching moment", use accurate phraseology for syntax. For example, don't substitute literals like "check to see if different from the last time" for the precise meaning "Not Equal To" when referring to syntax such as: if (a != b) {do something}. Not only is this precise language/syntax but it agrees with language references - none of which have the literal interpretation as a substitute. I don't mean to be critical but to be constructive and improve an already outstanding walk-through video. Thanks.

    • @codeadamca
      @codeadamca  Před 2 lety

      Thanks for the advice! I'll take it!

  • @whatsupyou.4078
    @whatsupyou.4078 Před rokem

    Good job 👍

  • @mache-xw7ox
    @mache-xw7ox Před 3 lety +1

    Just perfect

  • @pasokoner
    @pasokoner Před 2 lety +4

    This is what i did in the first part because i always get an error where something is wrong in the readline class and i also added the path inside the arugement object because
    i also get an error where path is not defined.
    const SerialPort = require("serialport");
    const { ReadlineParser } = require("@serialport/parser-readline");
    const parsers = SerialPort.parsers;
    const parser = new ReadlineParser({ delimeter: "
    " });
    const port = new SerialPort.SerialPort({
    path: "COM9",
    baudRate: 9600,
    dataBits: 8,
    parity: "none",
    stopBits: 1,
    flowControl: false,
    });
    port.pipe(parser);
    parser.on("data", (data) => {
    console.log(data);
    });

    • @codeadamca
      @codeadamca  Před 2 lety

      If you can paste the error here that might help me suggest something.

    • @Sneaadler
      @Sneaadler Před 2 lety

      THANKS!!! i got this error:
      TypeError: Cannot read properties of undefined (reading 'Readline')
      and that fixed it!
      after an hour of debugging you saved me

    • @benjaminhorowitz8912
      @benjaminhorowitz8912 Před 2 lety

      Thank you this helped me too!

    • @David-yi5sq
      @David-yi5sq Před rokem +1

      Thx fixed it for me!

    • @nessaberry5082
      @nessaberry5082 Před 9 měsíci

      How did you fix this error? Can't seem to fix it.

  • @DevsLikeUs
    @DevsLikeUs Před 4 lety

    Great explanation!

  • @adilanizuly5740
    @adilanizuly5740 Před 3 lety +1

    Thank you

  • @eugenionita8702
    @eugenionita8702 Před 4 měsíci

    Hi, You got a subscriber here, I am currently learning to become full stack developer, nice video thank you, I wonder if I can install this node server on my esp8266? I have a setup with 12 max7219 modules in 2 rows, the bottom one it’s made of 8 blue max modules that displays messages and the top one it’s made of 4 green max modules, currently I have a server running on it that I made and I can send data to the esp8266 over WiFi and I can control all the settings I need, but it would be great to make it display the value of analog light sensor also the current data from the esp like temperature and humidity from dth11 or the current date and time from the DS module, good luck and all the best!

  • @PukarShiwakoti
    @PukarShiwakoti Před 8 měsíci +1

    what did you do at 6:06? how to get the json file

  • @domoledlight
    @domoledlight Před 3 lety +1

    Thanks a lot for your good video, I have a question about sub file like css, js how to implement them ?

    • @codeadamca
      @codeadamca  Před 2 lety

      You would add a CSS file to this just like a regular HTML file. Just include it in the HEAD section and any CSS rules in your files using #sample will be applied.

  • @janhavipawar1819
    @janhavipawar1819 Před 3 lety +1

    Did you use a wifi module for this project?
    Also, great video

    • @codeadamca
      @codeadamca  Před 3 lety

      Nope, not with this one. This one just uses a USB cable.

  • @tanaysarkar_2177
    @tanaysarkar_2177 Před 2 lety +1

    What is the use of CDN?
    And how to get the URL??
    Please explain

    • @codeadamca
      @codeadamca  Před rokem +1

      A CDN (stands for Content Delivery Network) is when a service hosts common files for you to reference in your code. This way the files stay up to date and you don't have to store a copy locally. If you just do a Google for the library you are looking to use and the term "CDN" you will likely find something.
      Even Google hosts a lot fo common libraries:
      developers.google.com/speed/libraries

  • @cantcode1001
    @cantcode1001 Před 3 lety +1

    This is all running on a local machine, what about actually sending the data to a linode or similar web server??

    • @codeadamca
      @codeadamca  Před 3 lety +1

      This would require that the Arduino be connected to the internet (likely with using a wifi component). I have not yet set this up, would be a fun challenge!

  • @edsonferraz1
    @edsonferraz1 Před 3 lety +1

    Excellent your vídeo, but the code lines show very small chars, is difficult see

    • @codeadamca
      @codeadamca  Před 3 lety

      Sorry, I know the text is small. The text in my more recent videos is much larger.

    • @edsonferraz1
      @edsonferraz1 Před 3 lety

      @@codeadamca thanks for response, I download the source code in the Github, so is resolved the issue

  • @manischbulls3333
    @manischbulls3333 Před 6 měsíci

    Hey, can you create a tutorial to do the same for the ESP32 microcontroller using Wifi? I am trying to create a react application that can display real-time values using ESP32 and sensors that can be viewed from anywhere in the world.

  • @eltrayector
    @eltrayector Před 3 lety +1

    thank you¡¡¡

  • @damiansimonak7955
    @damiansimonak7955 Před rokem

    Ye it's really helpful video but I couldn't move over this error during start node app.js Error: Cannot find module 'serialport'. I am windows user. (we tried that on MacBook it works great.)

  • @Abc-sl1nf
    @Abc-sl1nf Před 6 měsíci

    Can Arduino IDE read JavaScript? Isn't the js library too big for Arduino?

  • @akintoladavid7604
    @akintoladavid7604 Před rokem

    what if i do not have a potentiometer, and secondly this is a very good video.

  • @enthirteenment
    @enthirteenment Před 3 lety

    Hoping you can make same very helpful video but using windows. Thank You!

    • @codeadamca
      @codeadamca  Před 3 lety

      The process should be identical on Windows. The only difference is when defining the SerialPort variable, the port reference in my video is something like "'/dev/tty.wchusbserialfa1410", on a Windows computer is will be something like "COM4". Here are a few links to help find the port reference on a Widows computer:
      www.arduino.cc/en/Guide/ArduinoUno
      www.mathworks.com/help/supportpkg/arduinoio/ug/find-arduino-port-on-windows-mac-and-linux.html
      If you are having a different issue, let me know, and maybe I can help.

  • @alpstinger5083
    @alpstinger5083 Před 3 lety

    Thanks for this series and this video!!! Just a small question. Can I have a node server and a device say my phone which sends data to the node server then the server sends it to the arduino, Wirelessly. Also is it possible to do the reverse, that is the Arduino sending the data to the server and the server to my phone(via an app), also Wirelessly. Here by wirelessly I mean by usinh wifi or something and NOT THE BLUETOOTH. This maybe a really noob Question, but I am a total beginner in this!!! Would really really be helpful if you reply!

    • @codeadamca
      @codeadamca  Před 3 lety +1

      I have a video on the opposite, communicating from HTML/JavaScript to the Arduino:
      czcams.com/video/hFBFju_ZSYs/video.html
      And yes, the other setup is possible. There are a few things you would have to change. Quite a challenge for a beginner. :)
      1) You would need to switch out all the code that communicates with the Arduino using the SerialPort with code that communicates over wifi.
      2) The computer hosting the Node.js website would need to make the Node.js app available to other computers on the same network.
      3) Then from your phone (as long as it's on the same network as your computer) can open the webpage using your computer's IP address instead of localhost.
      If you want this to work when you are using your phone and you are not on the same network, you would have some additional things to configure.

    • @alpstinger5083
      @alpstinger5083 Před 3 lety

      @@codeadamca Thank you so much man for replying!! I'll definitely try this. Just needed some assurance from a pro that if the set up is possible or not. Thanks again for clearing up. I'll definitely check out your video, and update you, if I am able to make the setup work properly!!

  • @dkaby
    @dkaby Před rokem +1

    is it working on android too?

  • @makingthamilan1592
    @makingthamilan1592 Před rokem

    Any one know how to find the seiralport name because It doesn't shows in my ide

  • @TejasMadhukarShukla
    @TejasMadhukarShukla Před 10 měsíci

    getting error as 'SerialPort is not a constructor'

  • @KratinMourya
    @KratinMourya Před rokem

    node app.js is running in terminal but in webpage it is showing errors related to GET 404 not found, what should i do

  • @mohamedaminejridi8757
    @mohamedaminejridi8757 Před 2 lety

    thank you for the video ,can i ask you how to put this data in table or dashboard

    • @codeadamca
      @codeadamca  Před 2 lety

      I'm not quite sure I understand the questions. It sounds like you would just need to place the HTML element displaying the data inside a table and style like you would a static piece of content.

  • @nurulnajwakhamis2680
    @nurulnajwakhamis2680 Před 2 lety

    Hello. I wanted to ask is it possible to use with Teensy4.0 instead of arduino uno? Thank you

    • @codeadamca
      @codeadamca  Před 2 lety

      I'm not familiar with Teensy4.0. But if it follows the same protocol as the Arduino, it should work fine.

  • @lomovnano711
    @lomovnano711 Před rokem

    Can "Proteus 8 Professional" replace the physical arduino? or not..

    • @codeadamca
      @codeadamca  Před rokem

      I don't see why not. But I don't actually know. Sorry!

  • @callofislam9381
    @callofislam9381 Před rokem

    How can I control arduino and servo motor from a website
    plz plz make a video

  • @ezrakeeps
    @ezrakeeps Před 2 lety

    Am relatively new to arduino?
    Is the node js being hosted in the arduino chip?
    If not... Is it possible?

    • @codeadamca
      @codeadamca  Před 2 lety

      In this video, the Node.js application is being hosted on the laptop. There is a platform called Johnny-Five (johnny-five.io/) that allows you to use JavaScript and Node.js directly with the Arduino.

  • @raffaelecrocco
    @raffaelecrocco Před 3 lety

    Man, what about re-do this beautiful video but zooming on the vs code window? We cant see a flock

    • @codeadamca
      @codeadamca  Před 2 lety

      I know my fonts are small, sorry! Maybe one day I'll get around to a redo. Could also use more recent versions of socket.io, etc...

  • @melissamalengo
    @melissamalengo Před 2 lety

    Adam, could you help me in a project? I have some doubts and you explain very clearly. Congratulations!

    • @codeadamca
      @codeadamca  Před 2 lety

      Possibly.... What did you need help with?

  • @menardcaponpon9152
    @menardcaponpon9152 Před rokem

    i have a question where can i find the cdn url that you copy? btw very nice video

    • @codeadamca
      @codeadamca  Před rokem

      You can get all Socket CDN links from here:
      cdnjs.com/libraries/socket.io

  • @samirakhrif3098
    @samirakhrif3098 Před 2 lety

    Please i want connect with page (camera+button) with ngrok but wen I do I have just des button only not camera why ? If you have a solution

    • @codeadamca
      @codeadamca  Před 2 lety +1

      Sorry, I have not done too much with the Arduino and cameras. I'm just starting to use a few AI cameras and an ESP32 board and the LEGO Spike hub. Maybe I'll have a related video soon!

  • @syaduinotech3681
    @syaduinotech3681 Před 2 lety

    hello sir, can you help the idea for the multiple sensor reading..

    • @codeadamca
      @codeadamca  Před 2 lety +1

      Once you have your second sensor connect to your Arduino (or more), you would just need to pass the data back and forth using JSON. That way you can include as much data as needed.

  • @rakeshmahapatra5456
    @rakeshmahapatra5456 Před 2 lety

    I didn't paste the serial port link but simply write COM4 is it the write way as i use offline editor..
    And sir there is also the readline error..

    • @codeadamca
      @codeadamca  Před rokem

      You can try COM4, if it works go for it! I'm on a Mac, so I need to look up the full port reference using a terminal.

  • @christianpaul3497
    @christianpaul3497 Před rokem

    Hello, does anybody know why I am getting a typeerror when using readline

    • @codeadamca
      @codeadamca  Před rokem

      Can you paste the full error into a comment? Is this error coming from the Arduino?

  • @circfox3372
    @circfox3372 Před rokem

    👍

  • @koukimonsterr
    @koukimonsterr Před 2 lety

    how do we find our 'cdn' in the HTML script

    • @codeadamca
      @codeadamca  Před 2 lety

      If you do a Google for "CDN socket.io" you will find a few options. I believe the CDN provided by socket.io is at:
      cdn.socket.io/

  • @captheobbyist6434
    @captheobbyist6434 Před rokem

    wait this doesn't need any wifi module? i need to make it wireless.

    • @codeadamca
      @codeadamca  Před rokem

      This example is not wireless. The Arduino needs to be connected to the device using a USB cable. It could be switched to wireless with a few modifications.

    • @captheobbyist6434
      @captheobbyist6434 Před rokem +1

      @@codeadamca wow you replied to 2 years old video comment. very cool 👍

  • @minhvokhai3162
    @minhvokhai3162 Před 2 lety

    I'm using PC and i change my SerialPort to 'COM3' and it throw out an error "Error: Cannot find module 'serialport'". Any help? would be much appriciate

    • @minhvokhai3162
      @minhvokhai3162 Před 2 lety

      nvm, i realise that i havent npm install lol

    • @codeadamca
      @codeadamca  Před 2 lety

      Glad you got it to work!

    • @minhvokhai3162
      @minhvokhai3162 Před 2 lety

      @@codeadamca Hey, thanks for the video and the blog, really help me with my University project. Much love

    • @KratinMourya
      @KratinMourya Před rokem

      Hey can you help me? Im also using COM3, do i have to put COM3 in there, as i dont get any strange letters at the port, there is only COM3, im getting error cannot 'Readline'

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

    It would be much better if you increase the font size of your code

    • @codeadamca
      @codeadamca  Před 3 lety

      I know, I have in more recent videos. Thanks!

  • @hridyanshukumar8949
    @hridyanshukumar8949 Před 2 lety

    How do you send data to a server hosted on the internet?

    • @codeadamca
      @codeadamca  Před rokem

      This would be a bit harder. The JavaScript and Node.js portion would remain the same. But you would likely need to add a WiFi component to your Arduino and then communicate with the Node.js server using a method other than Serial.

    • @barkleyvillarin5427
      @barkleyvillarin5427 Před rokem

      Hey Adam. I just want to ask something. Can I still access all the data sent by Arduino to a Server using the webpage/index.html even if I'm away from my Arduino? Is this possible?

  • @sidhomamine1323
    @sidhomamine1323 Před 2 lety

    Ho to communicate arduino and node js with wifi ?? Please i’m stuff

    • @codeadamca
      @codeadamca  Před 2 lety

      I have not done too much with the Arduino and Wifi. You'll need to add a wifi component to your Arduino. Then you'll just need to change the code that sends messages from app.js to the Arduino (port and SerialPort). The socket stuff can stay the same.

  • @OmegaWaffle1235
    @OmegaWaffle1235 Před 3 lety

    .listen is not a function. Any advice?

    • @codeadamca
      @codeadamca  Před 3 lety +1

      Someone else had the same issue, Socket may have changed since I made this video. Try this:
      var io = require('socket.io')(app);

  • @chubamoa3640
    @chubamoa3640 Před 6 měsíci

    Web sockets is way easier than http..in case you want to build a project with it

  • @link5404
    @link5404 Před 2 lety

    can this be updated please

    • @codeadamca
      @codeadamca  Před 2 lety

      It's on the to do list, but it could be a while. Sorry!

  • @fatimatwahab4620
    @fatimatwahab4620 Před rokem

    Can I get the code please

    • @codeadamca
      @codeadamca  Před rokem

      Yep! Here it is on GitHub:
      github.com/codeadamca/arduino...
      For future, there is usually a GiHub link in the video description.

  • @nobodyeverybody8437
    @nobodyeverybody8437 Před rokem

    font size is to small bro (((

    • @codeadamca
      @codeadamca  Před rokem

      Yea I know! In more recent videos the fonts are larger.

  • @lutfiikbalmajid3128
    @lutfiikbalmajid3128 Před 3 lety +1

    please zoom it later

    • @codeadamca
      @codeadamca  Před 2 lety

      Maybe one day I'll get back to fixing some of my older videos, I know the fonts are a small in this one.

  • @lutfiandrii
    @lutfiandrii Před 3 lety

    the text in js file is too small bro..

    • @lutfiandrii
      @lutfiandrii Před 3 lety

      anyway, thanks for greet explanation

    • @codeadamca
      @codeadamca  Před 3 lety

      Yea I know, the text is much larger in more recent videos.

  • @princepr5830
    @princepr5830 Před 3 lety

    I need your help

  • @elmundodelpc971
    @elmundodelpc971 Před 3 lety

    who can see anything?

    • @codeadamca
      @codeadamca  Před 2 lety

      I know, I have increased the font size in more recent videos! Sorry about the font size in this one.

  • @kauac1579
    @kauac1579 Před 2 lety

    gente boa
    aoba

  • @Holagrimola
    @Holagrimola Před 2 lety

    how do I find out my port if I'm running linux?

    • @codeadamca
      @codeadamca  Před 2 lety

      I'm on a Mac. I use this: ls /dev/{tty,cu}.*
      It will list all in use ports. If you can't tell which port is your Arduino from that list. Just remove the Arduino, run the command again, and take note of which port is no longer on the list.