ESP8266 code for graphing the ADC

Completed Posted 6 years ago Paid on delivery
Completed Paid on delivery

I need some code to graph the analog to digital pin of the esp8266.

I have some sample code.

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

#include <ESP8266WebServer.h>

#include <ESP8266mDNS.h>

const char *ssid = "YourSSIDHere";

const char *password = "YourPSKHere";

ESP8266WebServer server ( 80 );

const int led = 13;

void handleRoot() {

digitalWrite ( led, 1 );

char temp[400];

int sec = millis() / 1000;

int min = sec / 60;

int hr = min / 60;

snprintf ( temp, 400,

"<html>\

<head>\

<meta http-equiv='refresh' content='5'/>\

<title>ESP8266 Demo</title>\

<style>\

body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\

</style>\

</head>\

<body>\

<h1>Hello from ESP8266!</h1>\

<p>Uptime: %02d:%02d:%02d</p>\

<img src=\"/[login to view URL]\" />\

</body>\

</html>",

hr, min % 60, sec % 60

);

[login to view URL] ( 200, "text/html", temp );

digitalWrite ( led, 0 );

}

void handleNotFound() {

digitalWrite ( led, 1 );

String message = "File Not Found\n\n";

message += "URI: ";

message += [login to view URL]();

message += "\nMethod: ";

message += ( [login to view URL]() == HTTP_GET ) ? "GET" : "POST";

message += "\nArguments: ";

message += [login to view URL]();

message += "\n";

for ( uint8_t i = 0; i < [login to view URL](); i++ ) {

message += " " + [login to view URL] ( i ) + ": " + [login to view URL] ( i ) + "\n";

}

[login to view URL] ( 404, "text/plain", message );

digitalWrite ( led, 0 );

}

void setup ( void ) {

pinMode ( led, OUTPUT );

digitalWrite ( led, 0 );

[login to view URL] ( 115200 );

[login to view URL] ( WIFI_STA );

[login to view URL] ( ssid, password );

[login to view URL] ( "" );

// Wait for connection

while ( [login to view URL]() != WL_CONNECTED ) {

delay ( 500 );

[login to view URL] ( "." );

}

[login to view URL] ( "" );

[login to view URL] ( "Connected to " );

[login to view URL] ( ssid );

[login to view URL] ( "IP address: " );

[login to view URL] ( [login to view URL]() );

if ( [login to view URL] ( "esp8266" ) ) {

[login to view URL] ( "MDNS responder started" );

}

[login to view URL] ( "/", handleRoot );

[login to view URL] ( "/[login to view URL]", drawGraph );

[login to view URL] ( "/inline", []() {

[login to view URL] ( 200, "text/plain", "this works as well" );

} );

[login to view URL] ( handleNotFound );

[login to view URL]();

[login to view URL] ( "HTTP server started" );

}

void loop ( void ) {

[login to view URL]();

}

void drawGraph() {

String out = "";

char temp[100];

out += "<svg xmlns=\"[login to view URL]\" version=\"1.1\" width=\"400\" height=\"150\">\n";

out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";

out += "<g stroke=\"black\">\n";

int y = rand() % 130;

for (int x = 10; x < 390; x+= 10) {

int y2 = rand() % 130;

sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);

out += temp;

y = y2;

}

out += "</g>\n</svg>\n";

[login to view URL] ( 200, "image/svg+xml", out);

}

Arduino C Programming Electrical Engineering Electronics Microcontroller

Project ID: #15595497

About the project

17 proposals Remote project Active 6 years ago

Awarded to:

anhvu100

What's your specific requirement? I compiled your sample code and it is OK although it can be enhanced, for example, using ajax and using WiFi Manager to connect to WiFi. Relevant Skills and Experience ESP8266, HTML, More

$200 USD in 5 days
(26 Reviews)
5.4

17 freelancers are bidding on average $167 for this job

umg536

please ignore the bid amount we will discuss the price later in the chat after we have discussed the project thoroughly Relevant Skills and Experience: . Proposed Milestones: 190 - . Hi robobobo! please inbox me to dis More

$190 USD in 2 days
(45 Reviews)
7.2
mechatronicsengr

Hi I hope you are doing well. I have experience in esp8266 based webserver development. I have understood your project requirements and I can execute it in less possible time. Looking Forward Khawaja

$200 USD in 7 days
(99 Reviews)
7.2
SPARKtechBD

Read and checked your project description. It is not clear that what you want. Please mark your requirements clearly. However, I like to work in this project as I have Arduino experience. Relevant Skills and Experienc More

$250 USD in 7 days
(30 Reviews)
6.3
microembedded

hi i am an electrical engineer. i have vast experience related to esp8266 and its programming. i have done many embedded system projects. Relevant Skills and Experience i have hardware experience with esp8266. let me More

$250 USD in 5 days
(36 Reviews)
6.5
sanja1989

As I understand you need to read signal from ADC, save it and then show as SVG. Do you want to automatically update graph? How much data do you want to show? Relevant Skills and Experience I have experience in coding More

$30 USD in 2 days
(17 Reviews)
5.1
jitendrabaraiya

I can do your job.

$222 USD in 20 days
(11 Reviews)
5.1
sanakashif906

A proposal has not yet been provided

$277 USD in 6 days
(4 Reviews)
2.7
dilshodm

hello, I can help with this project. Can you describe, please, what is the rate of ADC data sampling and what is the timeframe for the data showed on the graphic? I.e. 5 seconds of data.

$166 USD in 7 days
(2 Reviews)
1.5
farispcb

Hi, I have experience with arduino, electronics, developing schematic and developing PCB layout. I worked on projects like a smartHome system. I use Arduino IDE for ESP8266 programming. Faris M. Relevant Skills and Ex More

$177 USD in 4 days
(1 Review)
0.8
EddyMiner

A proposal has not yet been provided

$35 USD in 3 days
(0 Reviews)
0.0
kenzanin

I have esp8266 and iam using it for my work as embedded designer.

$166 USD in 10 days
(0 Reviews)
0.0
MahmoudBahie

Hello Consider it done just tell me what exactly you want to do .

$222 USD in 4 days
(0 Reviews)
0.0