3

My project is to use the Raspberry Pi to send data taken from the "micromouse" to the PC.

The micromouse will run in the maze, and then data will be sent to the Raspberry Pi most likely through the serial port to pin 8 & 10 of the GPIO pins. Then that data will be sent to a PC via wirelessly.

How do I send the data via wireless from the Raspberry Pi to the PC, and how do I know that the data is stored in the Raspberry Pi?

  • 1
    possible duplicate of How to communicate between Raspberry Pis using WiFi? – syb0rg Jan 14 '14 at 22:34
  • 1
    This question has already been asked before, as well as a duplicate of this question. Please do some research before asking a question here. That is the point of school work (which is what this looks like it is). – syb0rg Jan 14 '14 at 22:35
  • I'm working on Raspberry to make Energy meter and I also want send all measuring parameter to web. may you help me please? – Faisal Dec 3 '17 at 15:30
4

If both Raspberry Pi and the PC are inside the same Network then you can send data to the PC using a web server,

Start by setting up a simple server based on web.py, which is installed via apt-get

sudo apt-get install python-webpy

Now create a directory to put the code in and create a simple test program

mkdir webpy
cd webpy
nano server.py

Now let's write a test code. write this inside server.py (make sure you are in a root mode)

#!/usr/bin/python
import web

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        return "Hello, world!"

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

Save it and then set it as executable with

chmod +x server.py 

and then run the code

./server.py

you will see something like this showing the server is waiting for a request (pressing Ctrl+C will stop the server)

http://0.0.0.0:8080/

Now from your PC, point your browser at http://ip-address-of-your-pi:8080 and it will show a web page with the content of Hello, world!.

If everything works as intended, you are all good to Go. Replace the content of server.py with the data you need to communicate from Raspberry Pi to the PC.

From your pc, you can read the data using urllib library of Python (the code below is for python 2.x)

import urllib
link = "http://192.168.1.65:8080" # Change this address to your settings
f = urllib.urlopen(link)
myfile = f.read()
date = myfile.split(" ")

You now have the data from your Raspberry Pi into your PC.

| improve this answer | |
  • 2
    I just have to install using sudo apt-get install python-webpy then I just start by keying in mkdir webpy and so on right? ,what do you mean by root mode ? sudo su?Thn My problem is (after keying in ./server.py):Traceback (most recent calls last):File "./server.py",line 15,in <module> app=web.apllication(urls,globals()) attributeerror:'module' object has no attribute 'application'. – Jane Alvord Jan 27 '14 at 3:28
  • The step ./server.py returns: ~/web.py-0.33/webpy $ ./server.py Traceback (most recent call last): File "./server.py", line 2, in <module> import web File "/usr/local/lib/python3.7/dist-packages/web/__init__.py", line 14, in <module> import utils, db, net, wsgi, http, webapi, httpserver, debugerror File "/home/pi/.local/lib/python3.7/site-packages/db/__init__.py", line 69 print "var", var ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("var", var)? But I find no "print". What could be the reason? – Marie. P. Jan 30 at 20:11
  • ...turns out the problem was solved by pip install web.py==0.40.dev0 – Marie. P. Jan 30 at 20:18
  • Is your code python-3-compatible? What do I need to change? I get the error: Traceback (most recent call last): File "./server.py", line 13, in <module> app = web.application(urls, globals()) File "...python3.7/site-packages/web/application.py", line 62, in __init__ self.init_mapping(mapping) File "...python3.7/site-packages/web/application.py", line 130, in init_mapping self.mapping = list(utils.group(mapping, 2)) File "...python3.7/site-packages/web/utils.py", line 531, in group x = list(take(seq, size)) RuntimeError: generator raised StopIteration – Marie. P. Jan 30 at 20:22
0

EWD.js could be a possible solution:

ewdGateway2 includes an entirely WebSocket-based framework known as EWD.js.

enter image description here

https://github.com/robtweed/ewdGateway2

Full Documentation

http://gradvs1.mgateway.com/download/EWDjsMechanics.pdf

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.