RaspberryPi to Core data transfer

Hi guys,

I am newbie and i want to connect the raspberry pi via a wifi module to the spark core.
I want to use the spark core to send digital data to the pi via wifi. The pi will be creating the hotspot and it won’t be connected to the internet. I tried to create a hotspot with my phone and then tried tinkering, but it didn’t work. Any suggestions?

When you make your phone a hotspot it’s taking control of the WiFi radio and essentially showing it as off to apps on the phone, which then use 3G/4G to access the internet. This means the Tinker app can’t send the required packets over WiFi that tell the Core which SSID to connect to.

The work around is to either program the WiFi credentials onto the Core over USB or use Tinker on another iPhone/iPad/Android device connected to your phone’s hotspot.

You can also download the SmartConfig java applet from TI to do it with a PC or Mac.

As to your Raspberry Pi question, what sort of data do you want to send and in which direction? Tell us exactly what you want to accomplish in as much detail as possible and we’ll try to help. :smile:

I am going to use a temperature sensor AM2302 which will sense temperature and send it digitally to the spark core.
The spark core should then transfer this data over wifi to the raspberry pi, where the raspberry pi will be acting as the wifi hotspot.
I would like to know, if this transfer can be done without the cloud, as i don’t want to use internet for this.

Right now the Core will not start without a connection to the Cloud. They’re adding a way to bypass this, but there’s no current ETA.

Could i transfer data with the UDP from the spark to the pi? Could i do this by hardcoding the spark with the RPi’s address, and then transfer data by UDP??

I’ve got Apache Tomcat installed using web services. It creates a web service that accepts a JSON string to store in a berkley database. All of it running on a Raspberry pi. You could write the JSON string straight from the core (push) or pull it from another command line program (which I’ve knocked up as well). It all works… I then chart the data using high charts… It’s one solution… there are other approaches of course as well…

1 Like

A version of the cloud that you can run locally is currently in the making. The easiest thing to do right now is to connect both the Raspberry Pi and the :spark: Core to a common hot spot (that is connected to the internet) and then do local communication using TCP/UDP.

Will it be possible to create the Pi as a wifi hotspot and the server and then use a code like the one shown in the ‘local communication’ example.

http://docs.spark.io/#/examples

I’ve not played with Ras Pi myself, but if you can get the Core connect to the internet/ Spark Cloud via it, you can then use the local communication examples!

Hi @leo99,

Right now if both the PI and the Core are online, you can use something like the local communication example to send packets back and forth between the two. I’m hoping to have a version of the local cloud out at the end of the next sprint, it might be rough at first, but will improve over time. :slight_smile:

Using the local cloud you could hit the API of your local server and interact with the core that way as well.

Thanks,
David

Basically, like I said, without an internet connection the Core will not boot right now. Until they add a bypass or release the Local Cloud there’s no way to do this right now.

You must have an internet connection to use the Core right now.

I want to test the local communication on my pc, by first creating a server on my pc and checking if the spark communicates with it. How do i run the sample_server code on my pc, to check if it has established a communication with the spark??

Hey @leo99,

The example server code: https://github.com/spark/local-communication-example/blob/master/simple_server.js is just a little node app. Make sure you have node.js installed (grab it here http://nodejs.org/ ), and then download that code and simply run:

 node simple_server.js

Thanks,
David

were currently working on a project for school in which we are building a smart pillbox. I was wondering if we could use the Spark Core linked to the Rasberry Pi to connect to the internet via wireless. I want to use maybe a R.O.S (Robot Operating System) language to receive and send information from a database or computer to the device and back, as well as to a cloud based server.

hmmm…

Rpi --> Router
Spark Core --> Router

This way? Yeah you can. but you can’t connect to the :spark: core to the internet through the Rpi. I don’t remember Rpi doing tethering.

Just connect both to the same router which has internet.

Then you will automatically be linked to the :spark: cloud and you can use the TCPclients to connect to local/cloud servers as you need :smiley:

Hope this helps!

wait even if the Rpi is hooked directly to the Spark core why won’t it connect if the Spark Core gains connection.

Connect as in how? If you mean the RPi gets internet connection VIA the :spark: core? That’s not going to happen for sure.

The Open Energy Monitor port uses a Pi to extract data from a Spark using UDP. While the Spark needs the cloud to run, all the data exchange between the Spark and the Pi is restricted to the local network (as described by @kennethlimcp above) . Uptime on the Pi is now over a month. The Spark occasionally loses its cloud connection but the whole system recovers without intervention.
The Spark software is quite simple. The Pi python goes on a bit but you can pick out the dozen lines that do the data transfer. All the code is in a Git Hub Gist.

p.s. if you really don’t want to use the cloud and just want a local wireless solution then it looks as though what you would like is Arduino+radio. You may not get the Spark level of community support though. The usual solution is Arduino + Xbee. The Open Energy Monitor Project does a lot with Arduino + RFM12B or take a look at Ciseco’s RFu-328 and their Slice of Radio (a Pi radio board). Once it is set up the system just looks like an Arduino plugged into the serial port of the Pi and you can use off-the shelf Arduino and Pi code and program the 328 over the radio. (I’m not deliberately pushing XBee and Ciseco’s products but pointing out that Sparks very great strengths aren’t appropriate for every project).

2 Likes

Hi @Dom, do you have an example of the code you used to get the Spark to communicate locally to a webserver?

Here it iz, vlvrd :
https://github.com/spark/local-communication-example.