I have in possession an Arduino Yun. Im just trying to connect this device to a WiFi device (OBD II Wi-Fi Data Logger). I have the IP and Port for the device. I saw this example sketch and was wondering how i can modify it to connect to the said device?
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "myNetwork"; // your network SSID (name)
char pass[] = "myPassword"; // your network password
int status = WL_IDLE_STATUS;
char servername[]="google.com"; // remote server we will connect to
WiFiClient client;
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection...");
// if you get a connection, report back via serial:
if (client.connect(servername, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
}
}
void loop() {
}
}
This example assumes I have an SSID and what not. But as far as I can tell the OBD2 device acts as an access point, the only thing I have for it is an IP and Port.....is there more data i need and how might one replace the SSID credential portion of code to connect to an unencrypted device.
RyanKim19:
I saw this example sketch and was wondering how i can modify it to connect to the said device?
How to modify it? Throw it out and start over. The Yun is completely different from a WiFi shield, and that code will simply not work with it.
This example assumes I have an SSID and what not. But as far as I can tell the OBD2 device acts as an access point, the only thing I have for it is an IP and Port.....is there more data i need and how might one replace the SSID credential portion of code to connect to an unencrypted device.
The SSID is the network name of the access point. On the Yun, the sketch couldn't care less about it, all of the WiFi details are handled by the Linux side of the board. If you went through the setup process and connected the Yun's WiFi to the adapter's access point, you're all set to go on that front.
With the Yun, forget about WiFi.h, the WiFi object and the WiFi.begin() call, and the WiFiClient object. None of that is applicable to the Yun.
With the Yun, you want to use the YunClient class. There isn't an official example of how to use it to make an outgoing connection to a specific IP address and port, but it can be done. Here is a simple example of making an outbound network connection.
Let me know if you have any questions.
It's curious... as I'm going back and looking for that example post, I see you have several other threads on this same topic. I'm looking at the Yun forum several times a day, and didn't see them before. I have no idea why they didn't show up as new topics until now...
THank you SHape Shifter, Sorry for my delayed response as I was caught up with some other work I had going. I will try your explanations and venture into it until i hit some road blocks. Thank you for saving me time with my initial wrong assumptions.