Hi, I am new to spark and am coming from an Arduino background. I am having trouble finding what I need in the spark documentation and so am wondering if what I want to do is possible.
I would like to be able to get the spark to scan for nearby wifi networks (SSID, security config) and report its findings so that I can display the list on an LCD screen. Once listed, I would like to allow the user to select a network and enter the pass code for it, then get the core to connect to that network.
I have achieved this on an Arduino Mega with a wifi shield using serially transmitted commands to the wifi shield then reading the result into an array, the LCD stuff is not relevant to this question as I have nailed that already.
However, Iām not sure how the core behaves, maybe I cant talk directly to the wifi chip I donāt know. I was hoping there would be some kind of wrapper class for commands to the core that would expose this functionality to us coders as standard. I had hoped that the core would make it easier to play with the wifi chip that the arduino was. If anyone could expand this for me Iād be most grateful.
I have found similar threads on here but nothing that seemed helpful in regards to this.
Iām building a device that I need to take to different locations and be able to hook up to the wifi in that area.
These spark cores are not simply an arduino with built in wifi are they, or maybe they could be with the correct firmware.
I really need a library that will enable easy access to the wifi chip so I can
connect/disconnect (in code)
list available networks
report signal strength.
Is there any way I can write such a library or that someone out there would be interested enough to consider doing this, is it even technically possible?
I could be mistaken, but Iām fairly certain I once saw a video from @timb in which he had a Core displaying wifi networks on a display. I believe he wrote some sort of sketch for it, of which you should be able to find more info here: https://community.spark.io/t/timbs-project-sprint-list/3075/26
Maybe Timb can elaborate some more, if this is indeed possible(?)
Good luck!
What you want to do is totally possible with the Spark core, but it is not setup to work this way out of the box. One reason for that is that Spark cloud assumes you are WiFi connected so anytime you move away from that notion, you are moving into advanced territory.
The Network class has an RSSI method that @timb put in that does a lot of what you want. If you look at the code here:
you will see that it calls a scan routine in the CC3000 driver to look for WiFi networks and find the one that matches the current SSID and returns the results for that. You can (and Tim has in that other post) use the other networks and RSSI data.
Connecting and disconnecting in code is possible but it is an advanced maneuver since you will have to stop the spark cloud.
One other point, the CC3000 can store up to 7 WiFi profiles and so if you are only ever going to be on 7 or fewer different networks, you can do that more easily.
Wow, that is excellent, I did find it hard to believe that this was not possible. I think that coming from Arduino into this āSpark Cloudā stuff is a bit of a culture shock but with the help of the forum I think I can get into it Thanks guys, your brilliant and your help is valued massively.
I think you must have meant for the delay(5000); to be inside that last curly-brace, right? Maybe thatās the problem?
Otherwise I am not sure why that would fail. It is calling the underlying CC3000 driver function.
Can you say how long it takes to fail? I put your program together with a serial display on a core and it ran for quite a while without problemsāover one-hundred 5 second rounds.
Yeah, trying putting your delay inside the main loop. During development of the RSSI code, I ran it in a continuous loop every 5 seconds and it ran for several days with no issues.
I can try to help you out with undeleting stuff if you need it. I canāt guarantee I can help, but I can dig through old database backups if you tell me when you last saw it / what it was called, etc.
No, nothing is remarkable there. I also used the webIDE for my test.
When it fails, do you get anything other than breathing cyan on the main LED?
Are you in a spot with lots of wireless networks? I have two networks right at hand for my testing and maybe 1 or 2 others that are sometimes in range for the core from the neighbors.
Brilliant, thanks guys. Iām going to implement this but Iām guessing that because Iām going to have to disconnect from the cloud to do it then I will need to get my act together and sort out some kind of IDE locally to program the core rather than using the web IDE. This is something Iād rather be doing anyway but because I only received my cores a week ago Iām still on a bit of a learning curve.