CC3000/Xively Project (DHCP)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
CC3000/Xively Project (DHCP)
I have an Arduino Project I built to monitor three water pumps at my university. I've built and tested it at home where everything works great, and I know the code is good. Now that I've taken the project to my university I'm having WiFi connectivity issues, or I should say DHCP issues. I'll be honest I know next to nothing about networking, and it being at my school without being able to login to a router and sort of see whats going on makes it even harder. My university handles connecting to WiFi by filling out a form with the MAC address of your device. There's no WPA security or any of that it's all based on the MAC address. So I've registered the mac address of my arduino with the school and I can connect to wifi, but when my code gets to requesting DHCP it just waits. My understanding of DHCP is that it's a way of assigning things IP addresses on the network and I don't understand why it's not working? Can anyone help me even begin to trouble shoot?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: CC3000/Xively Project (DHCP)
I think you'll have to contact your network help desk for this.
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
What could it mean that I'm stuck in DHCP? They said I can request a static IP address which I have. And I have seen the forum post on here about static IP address but I'm still not sure what i need to do to get static IP working for me.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: CC3000/Xively Project (DHCP)
If you're stuck in DHCP, it means that either
1) the DHCP server is not responding to you, or
2) you aren't receive the DHCP packets.
The buildtest example shows how to set up a static IP address:
1) the DHCP server is not responding to you, or
2) you aren't receive the DHCP packets.
The buildtest example shows how to set up a static IP address:
Code: Select all
/* Optional: Set a static IP address instead of using DHCP.
Note that the setStaticIPAddress function will save its state
in the CC3000's internal non-volatile memory and the details
will be used the next time the CC3000 connects to a network.
This means you only need to call the function once and the
CC3000 will remember the connection details. To switch back
to using DHCP, call the setDHCP() function (again only needs
to be called once).
*/
/*
uint32_t ipAddress = cc3000.IP2U32(192, 168, 1, 19);
uint32_t netMask = cc3000.IP2U32(255, 255, 255, 0);
uint32_t defaultGateway = cc3000.IP2U32(192, 168, 1, 1);
uint32_t dns = cc3000.IP2U32(8, 8, 4, 4);
if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
Serial.println(F("Failed to set static IP!"));
while(1);
}
*/
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
Okay I've uncommented the static IP portion. Do I need to delete everything regarding DHCP in the code? Or what else is there to do?
Does that bit of code look good?
Code: Select all
uint32_t ipAddress = cc3000.IP2U32(129, 123, 9, 55);
uint32_t netMask = cc3000.IP2U32(255, 255, 240, 0);
uint32_t defaultGateway = cc3000.IP2U32(129, 123, 0, 1);
uint32_t dns = cc3000.IP2U32(129, 123, 0, 1);
if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
Serial.println(F("Failed to set static IP!"));
while(1);
}
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: CC3000/Xively Project (DHCP)
Yes, just comment out the DHCP stuff - that's all you need to do.
Code: Select all
/* Wait for DHCP to complete */
// Serial.println(F("Request DHCP"));
// while (!cc3000.checkDHCP())
// {
// delay(100); // ToDo: Insert a DHCP timeout!
// }
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
Well I've done everything you said about commenting and uncommenting. I asked my university for the IP address, Netmask, Gateway, and DNS which I placed in the code and this is where I'm stuck now. Any ideas? I don't have a lot of confidence with my universities IT department the guy had to go ask about the Netmask and the DNS.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: CC3000/Xively Project (DHCP)
Ah! Your DNS is on a different network. But how did you wind up with a netmask of 255.255.255.0? According to the static IP code you posted here earlier, your netmask should be 255.255.240.0. That's your problem - that's why the DNS is not visible to you.
Did you change your code, or is the CC3000 not accepting 255.255.240.0?
Did you change your code, or is the CC3000 not accepting 255.255.240.0?
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
Yes I'm worried about the netmask I've tried it as both 255.255.240.0 and the 255.255.255.0. The reason I first tried it as the .240 variant was due to my own research. I opened the command prompt on a windows laptop and typed ipconfig to see network settings. I could see that both my windows laptop and Mac computer had a netmask of 255.255.240.0 and they're both successfully on the network. But because I kept having problems I doubted my knowledge and called my universities IT department where someone lazy told me the 255.255.255.0 and i trusted him. Also there is two different DNS they gave me 129.123.0.1 and 129.123.0.2 I've tried both with no difference.
Now that I've tried it with the .240 I get "Couldn't resolve" after "www.adafruit.com->". I can't tell if this is good or bad compared to the .255 I was using, but it seems like the code is executing further with the .240.
Now that I've tried it with the .240 I get "Couldn't resolve" after "www.adafruit.com->". I can't tell if this is good or bad compared to the .255 I was using, but it seems like the code is executing further with the .240.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: CC3000/Xively Project (DHCP)
Yes, you definitely need the 240.
I don't know why it can't resolve www.adafruit.com. It could be an issue with your DNS.
Try some of the other sketches and see if those work for you.
I don't know why it can't resolve www.adafruit.com. It could be an issue with your DNS.
Try some of the other sketches and see if those work for you.
- Franklin97355
- Posts: 23911
- Joined: Mon Apr 21, 2008 2:33 pm
Re: CC3000/Xively Project (DHCP)
Does the university have a firewall or any type of access requirements? Some schools block internet access to unknown devices.
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
I don't know about the firewall. I'm going in to have a sit down with someone who actually knows something in the IT department. The network is unsecured you have to give them your device MAC address to access the network. I've never had a problem with any other device before. From my end there's a website I can go and see what devices I have verified and accepted to the university it shows the correct mac address for the adafruit shield and it has a hostname but I'm not sure what the hostname is?
- mattymatt
- Posts: 10
- Joined: Mon Mar 24, 2014 10:25 pm
Re: CC3000/Xively Project (DHCP)
Well someone who knew what they were doing in the university IT dept. pushed some magic buttons and the original code works now. No static IP or anything needed. Thanks for your guys help!
Please be positive and constructive with your questions and comments.