Announcement

Collapse
No announcement yet.

Accessing SD card from PHPoC

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing SD card from PHPoC

    I am trying to find out how to access the SD card from a PHP page running on a PHPoC. I have information stored in a txt file on my SD card. I would like to either display what is in the txt file on the PHP page or link to the txt file that is on the SD card. I can do it if the txt file is stored on the PHPoC but I cant figure out how to get PHPoC to connect and read to its built in SD card.

    Alternately if I knew how to write to a txt file stored on the PHPoC would work just as well.

    Any help would be appreciated THANKS!

  • #2
    PHPoC Shield does NOT support to load directly file from SD via HTTP request.

    You can use the alternate method,
    - You can write/upload txt file or any kinds of files on PHPoC Shield though PHPoC Debugger.
    - You can NOT write/upload any kinds of files on PHPoC Shield through Arduino.

    Another way, Arduino reads text file from SD card and send it to Browser via WebSocket.

    Comment


    • #3
      You can also use Arduino to read text file from SD card and print it to Serial. From web browser, you can access a built-in web application, called "Web Serial Monitor", to see the data

      Comment


      • #4
        If I have my data captured as say a string called currentposition, can I send that to a page being hosted by the PHPoC?

        Take remote_Keypad. I enter in a number, this number is written to the SD card, can I also have that number written into a section of the remote_keypad?

        I get the total concept of using the Web Serial Monitor, but i simply dont have the knowledge to say take the remote_keypad and create a box above it that would display what is being shown in the Web Serial Monitor.

        Any assistance would be appreciated.

        Comment


        • #5
          Hi there,

          I see that in remote-keypad, they have the function send_key(key) to send the value to Arduino whenever the input is entered.
          And the variable key there is the value of what was being entered.

          Now, to show that value in remote-keypad window, you need to create an HTML element to display it.
          A text area, an input form, kind of things like this:

          <textarea id="whatever_id" readonly="readonly"></textarea>

          or

          <input id="whatever_id" type="text" readonly="readonly">

          And next, create a function to update the display value of the HTML element above.
          It may look like:

          function showTheKeyPadValueForMe(key)
          {
          var htmlElement = document.getElementById("whatever_id");
          htmlElement.value = key;
          }


          You know, the send_key() function is called when the key is being inputted. So you only need to place your own function side by side with this one.
          It will update the key pad value on input event.

          That's it. Hope it helps.

          Comment


          • Brian Roberts
            Brian Roberts commented
            Editing a comment
            That works great thank you! In my script I use the * to delete and the # for enter. It there a way I can get it to omit these 2 characters when pressed and only display numbers (1 - 10)?

        • #6
          Good to hear!

          The variable key is actually the text value of the inputted keypad. So I think you can add some conditions to avoid displaying "*" and "#".
          For example:

          if ((key != "*" ) && ( key != "#")) {
          showTheKeyPadValueForMe(key);
          }


          Hope it helps, again

          Comment


          • #7
            Ha Awesome!!!!! Based on what is above I had to change it a bit to say what to show. I know there has to be an easier way BUT what works works and you dont mess with what works and you got me going! I had to change it to the following:
            function send_key(key)
            {
            var htmlElement = document.getElementById("whatever_id");

            if(ws && (ws.readyState == 1))
            ws.send(key);

            if ((key != "1" ) && ( key != "2") && ( key != "3") && ( key != "4") && ( key != "5") && ( key != "6") && ( key != "7") && ( key != "8") && ( key != "9") && ( key != "10")) {
            send_Key(key);
            }
            htmlElement.value = key;

            }
            window.onload = init;



            Works great! Can I take the text box "whatever_id" and have it say 4 lines tall displaying the previous 3 entries? On the next entry the top 3 move up one line dropping the oldest?


            Ideally if I could just display the serial_monitor.php on the top of the remote_keypad.php page in one window would solve all my problems. Would that or the above be possible?

            Comment


            • #8
              Yeah friend, I think it is possible to extract the serial monitor to remote keypad window.
              You literally just need to copy the JavaScript part from the serial monitor to the remote keypad, create a corresponding textarea HTML element just like they did in the serial monitor.

              Now you will initialize two different WebSocket clients, and as I see, they use the similar variable and function names for WebSocket in these two projects. So you may need to rename in order to differentiate them, otherwise, of course, it won't work as expected .

              P/S: I am still a little bit confused about your code. Are send_Key() and send_key() different functions? Anyway, the naming rule and the source code are up to you. If you feel it okay, then it is fine ​​​​

              Comment


              • #9
                Ahh.. The K was a typo. It may be ugly and formatted incorrectly but thanks to you it works. Now I will try to clean it up and start a second project of trying to merge the serial monitor and the remote keypad together into 1 page.

                Thank you for your help!!

                Comment


                • #10
                  You are welcome, my friend .

                  Hope to hear good news from you, and surely it will

                  Comment

                  Working...
                  X