Question

I have built some sensors around my Raspberry Pi. With a C++ program, I can read out the SPI bus to get the sensor values. What i want to do now is to publish these values to a simple web page (php, html or whatever). I have installed LAMP on the Pi and successfully published a simple web page in my personal network.

So the 'only thing' that is left is to make a connection between an html page and my C++ program, but I have no idea how to do it. So the question is, am I on the right track, and how can it be done? I am not able to find a 'simple' solution and don't know where to begin.

Was it helpful?

Solution

You need to understand some of HTTP

You could make your C program a web server using some HTTP server library like e.g. libonion, mongoose (as commented by oysteijo), libmicrohttpd etc... (in C++ consider also Wt). Then your application would provide a web page.

You could make your C program a web client using some HTTP client library like libcurl. Then your application would e.g. fill a web form located elsewhere. (your C program could also e.g. be database client and some other Web server would access the same database and display the data).

You could also consider making your C program a CGI or FastCgi application (interacting with a web server like Lighttpd or Apache...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top