tsaG
Posts: 80
Joined: Thu Jun 26, 2014 1:30 pm

Sending "realtime" data over Wifi to tablets

Sat Aug 08, 2015 9:33 pm

Hi!

I have a project where im using the Pi to gather data from several Sensors over I2C (one IMU, Eeprom and an Arduino). These information files will be displayed at the Pi on a 3.5" Screen.

The next step is to send this data over a Wifi network, which is hosted by the Pi, to two tablets (android at the moment).

My question is, how do I realize the wifi part?

I had the following ideas:
- create a "website" where this information can be read from.
- "stream" the information over UDP to the broadcast adress (255.255.255xxx) (How?)
- create a MySQL Server where the tablets can connect to and read those values

Which way would be the easiest, prettiest, fastest, resource conserving?

I also have some other devices on my network, I think the broadcast is not the best idea (isnt it?).

thanks!

-Pat

BillStephenson
Posts: 256
Joined: Thu May 17, 2012 1:25 am
Location: SW Missouri Ozarks
Contact: Website

Re: Sending "realtime" data over Wifi to tablets

Sun Aug 23, 2015 8:49 pm

Setting up a web server on the Pi is a good way to do this and there are a bunch on options on how you can do that.

I'll suggest you look into "Web Sockets" to do this. It's pretty close to real time. Here's a video I made that shows a Pi using web sockets to send data over a wifi LAN to another Pi:

https://www.youtube.com/watch?v=2YW6HWJg4f4

And here's the link to the code I used:

http://www.raspberryperl.com/compass/

There are some notes there too that might help you out.

User avatar
DougieLawson
Posts: 39165
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Sending "realtime" data over Wifi to tablets

Sun Aug 23, 2015 8:58 pm

Have a look at MQTT (the IoT protocol) with Mosquitto or RabbitMQ as the broker.

It's designed for one-to-one, one-to-many, many-to-one and many-to-many messaging. Unlike HTTP which is client pull from a server. Mosquitto 1.4 also supports websockets.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

razor
Posts: 13
Joined: Wed Sep 02, 2015 9:17 pm

Re: Sending "realtime" data over Wifi to tablets

Wed Sep 02, 2015 9:29 pm

tsaG wrote:Hi!

I have a project where im using the Pi to gather data from several Sensors over I2C (one IMU, Eeprom and an Arduino). These information files will be displayed at the Pi on a 3.5" Screen.

The next step is to send this data over a Wifi network, which is hosted by the Pi, to two tablets (android at the moment).

My question is, how do I realize the wifi part?

I had the following ideas:
- create a "website" where this information can be read from.
- "stream" the information over UDP to the broadcast adress (255.255.255xxx) (How?)
- create a MySQL Server where the tablets can connect to and read those values


Which way would be the easiest, prettiest, fastest, resource conserving?

I also have some other devices on my network, I think the broadcast is not the best idea (isnt it?).
1. you can use web server and send data thru WebSockets (it's like TCP sockets, but for browsers - so JavaScript can do that on client side)
2. you can 'stream' data using UDP or use TCP connection for streaming, there is no big difference in implementation
3. worst thing :)

which is the best - it depends on your knowledge, programming skills etc., other things/features you want to put in your projects etc.
if you want to use Web Server anyway (for other things), then WebSockets it's good thing (you can use only one component - a web server)
Broadcast is very easy - but it works only in a LAN and it's possible that datagrams will come in different order or even will be lost.

Return to “General programming discussion”