Results 1 to 10 of 73

Thread: How to import data from wifi into arduino?

Threaded View

  1. #11
    Kart Driver
    Join Date
    Feb 2016
    Location
    ERR404
    Posts
    77
    Platform
    PS4
    Hi Memoric..

    I'm doing the same thing, and have got the ESP to connect directly to the UDP stream, and recieve packets of size 1367.. So far...


    I've coded the ESP8266 directly (as per Arduino) by installing the ESP8266 Arduino core off Github..

    Sorry if this is sucking eggs, but gotta make sure..

    Type this into Preferences/additional boards manager url's

    http://arduino.esp8266.com/stable/pa...com_index.json

    Then, goto Tools/Boards/Boards manager, and install the ESP8266 generic drivers.. This allows the Arduino IDE to recognise the ESP as a board in its own right..


    I've found a few wiring examples, but have found this to work..

    CH_PD, RST and GPIO2 each pulled to VCC (3v3, NOT 5v) via a 3k3 resistor.

    GPOI 0 plugged directly to GND, THEN power up, for 'Flash' mode.. Programs exactly the same as an UNO, Teensy, etc..
    Remove GPIO 0 from GND after burning.. Mine just floats.. (i.e. connected to nothing)..

    I'm reading the OP thru the serial Monitor at the moment, but plan to send the serial to a Teensy for processing..

    I've now got lost trying to decypher the stream, as most peeps are using 'struct' directly thr C, not 'Arduino C'...


    The code is a hash of 'ESP8266 Wifi scan' and the standard WiFi Libs 'WiFiUDPsendreceivestring'

    //===============================================================
    //= Libraries
    //===============================================================
    // ESP8266 Wifi
    #include <ESP8266WiFi.h>

    // Standard Wifi UDP Lib
    #include <WiFiUdp.h>


    // Data struct for Pcars
    //#include "data_struct.h"
    // Data struct for Pcars
    //#include "data_struct2.h"

    //===============================================================
    //= Setup Definitions
    //===============================================================
    unsigned int localPort = 5606; // Pcars UDP Port on all platforms

    //===============================================================
    //= Storage section
    //===============================================================
    int status = WL_IDLE_STATUS;
    char ssid[] = "S5 Hotspot"; // your network SSID (name)
    char pass[] = "xxxxxxxxxx"; // your network password (use for WPA, or use as key for WEP)

    //char packetBuffer[255]; //buffer to hold incoming packet
    char packetBuffer[1367]; //buffer to hold incoming packet

    //char ReplyBuffer[] = "acknowledged"; // a string to send back - NOT USED

    //===============================================================
    //= Setup objects
    //===============================================================
    WiFiUDP Udp; // Create Udp object

    //===============================================================
    //= Setup
    //===============================================================
    void setup() {
    //Initialize serial and wait for port to open:
    delay(2000);
    Serial.begin(115200);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
    }

    // attempt to connect to Wifi network:
    while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
    }
    Serial.println("Connected to wifi");
    printWifiStatus(); // Just prints connection details

    Serial.println("Starting UDP");
    Udp.begin(localPort);

    }

    //===============================================================
    //= Main Loop
    //===============================================================
    void loop() {

    // if there's data available, read a packet
    int packetSize = Udp.parsePacket();
    if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    Serial.print(remoteIp);
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    // int len = Udp.read(packetBuffer, 255);
    int len = Udp.read(packetBuffer, 1367);
    if (len > 0) packetBuffer[len] = 0;
    Serial.println("Contents:");
    Serial.println(packetBuffer);


    // Dont send a reply to PS4.... !!!
    // send a reply, to the IP address and port that sent us the packet we received
    // Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    // Udp.write(ReplyBuffer);
    // Udp.endPacket();
    }
    }

    //===============================================================
    //= Serial print WiFi details
    //===============================================================
    void printWifiStatus() {
    // print the SSID of the network you're attached to:
    Serial.print("SSID: ");
    Serial.println(WiFi.SSID());
    // print your WiFi shield's IP address:
    IPAddress ip = WiFi.localIP();
    Serial.print("IP Address: ");
    Serial.println(ip);
    // print the received signal strength:
    long rssi = WiFi.RSSI();
    Serial.print("signal strength (RSSI):");
    Serial.print(rssi);
    Serial.println(" dBm");
    }

    // END OF PROGRAM


    Obviously you need to replace my 'S5 Hotspot' and ****** password, with your own..

    Port 5606 is the Pcars port on all platforms..
    Last edited by cyclicscooby; 11-02-2016 at 15:45.
    The following 2 users likes this Post: GForce, memoric77


Similar Threads

  1. [PC/XB1/PS4] vrHive - Dashes/Telemetry/Live Data/Arduino/Client-Server/+more
    By MikeyTT in forum Third-Party Apps & API Discussion
    Replies: 761
    Last Post: 11-10-2019, 11:42
  2. Arduino Dashboard
    By saibot852 in forum General Discussion
    Replies: 219
    Last Post: 04-09-2017, 04:41
  3. Import 3D model in game?
    By choptider in forum PC - Technical Help & Support
    Replies: 4
    Last Post: 25-11-2015, 02:54
  4. Logic3 TopDrive GT racing wheel not detected (Wifi dongle)
    By markieg in forum PC - Technical Help & Support
    Replies: 0
    Last Post: 09-10-2015, 12:12
  5. calling all arduino nuts
    By brooksy in forum General Discussion
    Replies: 2
    Last Post: 25-05-2015, 09:35

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •