-2

I need to create asp.net website (on windows), the website should be installed on a windows computer. The website (installed on windows OS) should be able to control the raspberry pi pins(with raspbian OS installed). I don't know how and where could I start! any hint would be so appreciated.

  • Have you thought about the types of communication needed? And if their is a need for real time data? And what types of information your going to need to transfer to the Pi? And if you need 2 way communication? If you are going for simplicity maybe just setting up a web server will work for you? Maybe even just having it long poll forever? – Mohammad Ali May 5 '16 at 12:23
  • Welcome -- but this is not a discussion forum -- please take the tour again and pay attention to the "Get answers to practical, detailed questions" part. You need to break this project down into smaller tasks and ask more specific questions about the ones you need information on. For example, there is no point making a web site for remote control of the pins until you can control the pins locally, so you might want to start there. – goldilocks May 5 '16 at 12:28
  • Sorry if my question wasn't clear enough, but I know how to control the pins locally. I'm not asking to get full procedure, I just asked about the starting point (I don't know how and where could I start) and I'll proceed on after that... The starting point means the required tools and skills to make the web interface, not the full web interface itself. – Dani May 5 '16 at 12:41
  • raspberrypi.stackexchange.com/users/43607/mohammad-ali all I need is to send commands and control rpi pins. suppose a simple project just lighting a led on or off from internet web based application. – Dani May 5 '16 at 12:43
  • I don't think it's clear enough in the question that the ASP.NET website will be running on a Windows machine. – Virtual Anomaly May 5 '16 at 13:07
1

i dont know windows iot how can help you for this! but if you wann use python and raspbian(or another linux distro) you can create rest api and call this api from your asp.net website to control your rapberry pi by parsing rest api in .net for creating this api you can use flask or another python framework you have a wide choice for your programming language in linux such as python, go, nodejs ,even php ,... and any of them can help you to build your own Rest-api

:)

  • Oh how I missed that! Thanks for your valuable answer. I'll try it. – Dani May 6 '16 at 13:27
2

As indicated by @goldilocks this is a very wide open question, to answer properly much more details are needed.

Like on every small or large project, divide it into development units, each one with it's own testing methods then, connect the pieces together. Think LEGO: you will write some pieces, others you will integrate.

You want to control GPIO pins from another system (ASP.NET IIS web site): Why not locally on the RPi Apache using PHP/Python? There are some examples elsewhere. Will assume the IIS have public access and RPi is on you intranet.

You then need to define a protocol to connect both devices: this can be your own creation or a complex REST/SOAP standard.

Do you need to obtain status from the RPi to show on you ASP.NET page? If yes, the you need to have a method to remote query the RPi from Windows.

The following draft is a very simple protocol, that allows you to send and receive low data volume, allowing the RPi to be local or on the other side of the world, making it a truly IOT.

In a loop, as fast as your requirement, from a few second to hours, the RPi send status to your IIS, posting a web query (using wget) and receiving back data from your server:

wget http://<YourIISServer>/xxx.aspx?status="<RpiStatus>" -o /dev/null -O /tmp/xxx

You then read and parse the /tmp/xxx data received: if you are brave enough, your data can be a bash script to be executed on your RPi.

Will leave the ASP xxx.aspx details for you, just process the form query "status" (data from RPi to Server) and send a reply with your RPi instructions:

To send your data from IIS, on the ASP.NET page Init event add the following (assuming VB.Net):

    Response.Clear()
    Response.Write("<your instruction message to RPi>")
    Response.End()

On your ASP.NET app, you store the RPi instructions elsewhere and you send them back when the RPi poll the server. You can use a simple SQL table to keep track of it.

This is not real time, a very asynchronous process but effective a easy to implement.

2

I do not know what a asp.net website is that you mention in your question's original post, but in the comments section, you describe

"...a simple project just lighting a led on or off from internet..."

I've just spent the day installing a RPi project which is based on just that. After considering many approaches, I finally settled on using Python to write an extremely simple server-client relation (between a desktop PC at home and a RPi at work) using "sockets". I did a good deal of reading, like articles, tutorials, forums, documentation, knowledge bases, retail site's "learn" pages etc. and found PySocks to be the best all-around.

If you just want the essentials (in Python 2.7) for a jumping off point:

(THIS IS THE BARE MINIMUM FOR YOUR SOCKET SERVER - I chose to use UDP instead of TCP because it used less code! This is an echo server - anything it receives from the CLIENT is promptly echoed back)

(set up)

import socket

dgramSock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )

dgramSock.bind( ('', port number) )      <--- please note: two single quotes, NOT one double quote


(body)

incomingMessage, (addr, port) = dgramSock.recvfrom(bufferSIZE)

dgramSock.sendto(incomingMESSAGE, (addr, port))

(NOW FOR THE SOCKET CLIENT)

(set up)

import socket

dgramSock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )


(body)

dgramSock.sendto( message2send, (addr, port number) )

But really, check out the link I gave, it's really very good. I have tested all my code on my LAN here at home and it all works properly. Haven't tested yet over the WAN that separates my home and work, but I'm assured that SOCKETS are real working things actually used on THE internet. Yes, I'm really quite the NOOB, but I can really relate to the way your post went, and how perplexing starting from a dead stop with nothing to push off against can be (or, in my case, ALWAYS IS). And you gotta love those members who have to chime in with their sarcastic comments; they're SOOO helpful.

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.