Menu
Cart

Adding a CC3000 WiFi Connection to the Garage Door Controller

Using the garage door controller over Serial works fine but it does require a few wires run to a computer in order to work. This tutorial will show how to connect the DF11 CC3000 board and program it to work over WiFi instead to remove the need for the wires running to a computer. 

Configure and Upload Sketch

The DF11 CC3000 module can be connected to the Garage Door Controller on top of the square outline that has a 10 pin connector in it. The CC3000 board will overhang the side of the Garage Door Board a bit after connected which is fine. 

IMAGE OF GARAGE DOOR BOARD WITH CC3000 ON IT

Next, you will need to open the MQTTHub\GarageDoor\Garage_Door_Controller_WIFI example in the Arduino IDE. This example is pretty much the same as the Garage_Door_Controller from the other tutorial except instead of a MQTTSerialPort it uses a MQTTCC3000Port instead.

Before we can upload the sketch to the Garage Door Controller we need to update the wlanConfig and mqttServerConfig objects to point to the correct. First, lets look at the wlanConfig struct: 

Cc3000WlanConfig wlanConfig = {
  "SSID", //ssid to connect to
  "password", // passcode for the wlan
  WLAN_SEC_WPA2 //security type for the wlan
}; 

Replace "SSID" with the name of the wifi network you would like the garage door controller to connect to. Replace "password" with the key used to access the wifi network. The security can be one of the following values: 

WLAN_SEC_UNSEC //use this if the wifi network is unsecured.
WLAN_SEC_WEP 
WLAN_SEC_WPA
WLAN_SEC_WPA2 

Check your router settings to see what type of security your router is using. The default on most newer routers is WPA2. 

Next up we need to update the mqttServerConfig settings:

MqttServerConfig mqttServerConfig = {
  "192.168.1.20", //mqtt server address to connect to
  1883, //mqtt port to connect to 
  "EFM32WG842", //name for this device to send to the server
  "username", // username to access the mqtt server
  "password" // password to access the mqtt server
}; 

If you are using the default settings for Mosquitto then the only parameter you need to change is the mqtt server address. In order to find out the mqtt server address open a terminal on the machine that the mqtt server is running on. 

(Windows)

Type ipconfig into the terminal and you should see something like this:

There will be different adapters depending on what is installed on your machine. The most likely candidate for the IP address that Mosquitto is connected to is the one that starts with 192.168. Type that ip address in for the first parameter for the mqttServerConfig. 

(Linux)

PUT LINUX IP ADDRESS DIRECTIONS HERE

(Mac)

PUT MAC IP ADDRESS DIRECTIONS HERE (SAME AS LINUX?)

Once the wlan and mqtt settings are updated the script is ready to upload to the board but before uploading make sure that the Mosquitto MQTT server is up and running.

After about 5 minutes the board should be connected to the wifi network and messages should start showing up on the Mosquitto console like this:

 

1482885962: Received SUBSCRIBE from EFM32WG842
1482885962:     GDOOR/BOARD/LED_RED/# (QoS 0)
1482885962: EFM32WG842 0 GDOOR/BOARD/LED_RED/#
1482885962: Sending SUBACK to EFM32WG842
1482885962: Received PUBLISH from EFM32WG842 (d0, q0, r0, m0, 'GDOOR/BOARD/LED_RED?/SWITCH', ... (3 bytes))
1482885962: Received SUBSCRIBE from EFM32WG842
1482885962:     GDOOR/BOARD/LED_GREEN/# (QoS 0)
1482885962: EFM32WG842 0 GDOOR/BOARD/LED_GREEN/#
1482885962: Sending SUBACK to EFM32WG842
1482885962: Received PUBLISH from EFM32WG842 (d0, q0, r0, m0, 'GDOOR/BOARD/LED_GREEN?/SWITCH', ... (3 bytes))
1482885962: Received SUBSCRIBE from EFM32WG842
1482885962:     GDOOR/BOARD/LED_BLUE/# (QoS 0)
1482885962: EFM32WG842 0 GDOOR/BOARD/LED_BLUE/#
1482885962: Sending SUBACK to EFM32WG842
1482885962: Received PUBLISH from EFM32WG842 (d0, q0, r0, m0, 'GDOOR/BOARD/LED_BLUE?/SWITCH', ... (3 bytes))

 

Now if you startup the OpenHAB server you should be able to use the garage sitemap from the garage door controller tutorial to control the board over wifi.

If you now disconnect the board from the computer and connect it up to an external power supply (any usb phone charger should work fine) it should connect up to the wifi and messages should show up again on the Mosquitto console. 

Lastly, connect the garage door controller back up to the garage door like in the end of the other tutorial.