Department of Engineering

IDP Wifi

Wifi introduces several complications, many to do with security and passwords. It's not necessary to use Wifi for the IDP unless you're using the camera, but if you need it, this page (written by Dave Paterson and Tim Love) offers some hints.

Much the simplest approach is to use a peer-to-peer connection from your laptop directly to the Arduino. That's the first option described here. An alternative, outlined later, is to communicate via a CUED network. Various options are available. You'll need to be more computer-literate to use these options.

Whichever option you choose, note that the Arduino can only cope with 2.4GHz communications, so check your laptop settings.

The example code on https://www.arduino.cc/en/Reference/WiFi is useful. The "ScanNetworks" program is a good place to start.

Peer-to-peer with Windows 10

  • From the Arduino IDE File Menu select “Examples -> WiFiNNA -> SimpleWebSeverWiFi”. This leads to the https://www.arduino.cc/en/Tutorial/WiFiNINASimpleWebServerWiFI program.
  • In the arduino_secrets.h file set SECRET_SSID and SECRET_PASS - the pass[word] must be at least 8 characters long. E.g.
    #define SECRET_SSID "daveP"
    #define SECRET_PASS "12345678"
    
  • Connect the Arduino, set the board information and port, then compile and download as normal. The program starts a web server on the Arduino and makes it available
  • On your laptop select "mobile hotspot" and click on the Edit button (see right)
  • Set the "Network name" and "Network password" to be what you set on the Arduino, then save.
  • Switch on the mobile hotspot and wait. After some time the Arduino should connect, with its IP address shown.
  • Copy the IP address of the Arduino into your laptop browser. Your web browser should now connect to the server running on the Arduino. The code on the Arduino is written so that an LED could be controlled, but you could just as easily control the motors to make your laptop or phone into a remote-control for your robot.
    Rather than using a browser, you can run a Python program on your laptop containing lines like
    import requests
    x = requests.get('182.168.137.141',params={"Right":"50","Left":"100"})
    print(x.status_code)
    

CUED networks

There are several wireless networks at CUED. The "CUED Robots" network is available in the EIETL. It can't be accessed from other networks. The EIETL PCs are connected to it. The Arduinos that we know about can also access it using the passphrase on the IDP WiFi moodle page. Note that new Arduino boards might not have been added to the access list. Contact the staff if you think that might be the problem.

There are several options available for 2 computers (the Arduino and your computer in your case) wanting to communicate. All involve using some underlying protocol to exchange text. The provided examples use

  • HTTP - this is the WWW's protocol, which in turn uses TCP. It's used in the web server example. A web-server is started on the Arduino, listening on port 80 for requests. These requests can be sent to the server using a browser (the client, in computer jargon), but they're simple enough to send from a program - they're just text. See the example in the code. You'll need to invent a simple language that the client and server can use to communicate commands and information.
    Information sent this way is reliable (the packets are error-checked) but any client program running on the same network that knows the server address can send requests to the server.
  • Telnet. This is used by the ChatServer example. It uses the underlying TCP (error-checked) layer to transmit and receive text. Again, you'll need to invent a simple language that the client and server can use to communicate commands and information.
  • UDP. This is used by the WiFiSendReceiveUDPString example. It uses the underlying UDP layer, which isn't errorchecked - you'll need to check whether information's been correctly received. It's faster than TCP-based solutions.