Komunikasi arduino to arduino2/14/2022 In the setup() part of the sketch, we can now connect the CC3000 chip to the network −ĬnnectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY) MDNSResponder mdns // Create aREST instance We can then create the CC3000 instance, server and aREST instance −Īdafruit_CC3000_Server restServer(LISTEN_PORT) // DNS responder instance The port to listen for incoming TCP connections #define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, #define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters! WiFi network (change with your settings!) Wi-Fi name and password, and the port for TCP communications (we have used 80 here). You need to define inside the code what is specific to your configuration, i.e. The goal here is to connect to your WiFi network, create a web server, check if there are incoming TCP connections, and then change the state of the relay accordingly. We will first take care of Arduino sketch, and then we will see how to write the server-side code and create a nice interface.įirst, the Arduino sketch. However, for this project, Arduino board will be running a small web server, so we can “listen” for commands coming from the computer. The software for this project is based on the TCP protocol. Let us now control the relay wirelessly using the CC3000 WiFi chip. ![]() ![]() You can just upload it to the board and the relay will switch states every second, and the LED will switch ON and OFF accordingly. You can test the relay with the following sketch − You also have to place the rectifier diode (anode connected to the ground pin) over the pins of the coil to protect your circuit when the relay is switching.Ĭonnect the +5V of Arduino board to the common pin of the relay’s switch.įinally, connect one of the other pin of the switch (usually, the one which is not connected when the relay is off) to the LED in series with the 220 Ohm resistor, and connect the other side of the LED to the ground of Arduino board. Connect the other pin to the ground of Arduino board.First, connect pin number 8 of Arduino board to one pin of the coil.V in is connected to Arduino 5V, and GND to GND.Īfter placing the relay on the breadboard, you can start identifying the two important parts on your relay: the coil part which commands the relay, and the switch part where we will attach the LED.Connect the SPI pins to Arduino board: MOSI, MISO, and CLK to pins 11, 12, and 13, respectively.Connect the IRQ pin of the CC3000 board to pin number 3 of the Arduino board.The hardware configuration for this project is very easy. Procedureįollow the circuit diagram and make the connections as shown in the image given below. We are also going to use the aREST library to send commands to the relay via WiFi. Components Requiredįor this project, you just need the usual Arduino IDE, the Adafruit’s CC3000 library, and the CC3000 MDNS library. A built-in TCP/IP stack with a "BSD socket" interface supports TCP and UDP in both the client and the server mode. It supports 802.11b/g, open/WEP/WPA/WPA2 security, TKIP & AES. It has a proper interrupt system with IRQ pin so you can have asynchronous connections. It uses SPI for communication (not UART!) so you can push data as fast as you want or as slow as you want. The CC3000 WiFi module from Texas Instruments is a small silver package, which finally brings easy-to-use, affordable WiFi functionality to your Arduino projects.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |