MCP9700A Sensor & Ethernet
This project consists of reading the temperature by MCP9700A Sensor and view it on a webpage.
Required Components:
Temperature Sensor MCP9700A: Datasheet
RJ45 SI-60002-F: Datasheet
RJ45 SI-60002-F:
This is a RJ45 connector without leds.
You will find wiring diagram in this PAGE or I summarized it in this schematic:
MCP9700A:
You'll find everything for use this Temperature Sensor on my notebook page HERE
I connected the output of this Sensor with the pin p15 of mbed.
Code (with JavaScript):
The first part is to implement an HTTP Server on your mbed. The complete explanation is here: HTTP Server
I used a Static Ip (192.168.1.100 for mbed and 192.168.1.5 for my pc) because I connected the mbed directely to my pc.
#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPServer.h"
DigitalOut led1(LED1, "led1");
DigitalOut led2(LED2, "led2");
DigitalOut led3(LED3, "led3");
DigitalOut led4(LED4, "led4");
LocalFileSystem fs("local");
AnalogIn temp(p15);
EthernetNetIf eth( // Fix Ip
IpAddr(192,168,1,100), //IP Address
IpAddr(255,255,255,0), //Network Mask
IpAddr(192,168,0,1), //Gateway
IpAddr(192,168,0,1) //DNS
);
HTTPServer svr;
int main() {
Base::add_rpc_class<DigitalOut>();
Base::add_rpc_class<AnalogIn>();
printf("Setting up...\n\r"); // setup ip check
EthernetErr ethErr = eth.setup();
printf("\n\r");
if(ethErr)
{
printf("Error %d in setup.\n\r", ethErr);
return -1;
}
printf("Setup OK\n\r"); // setup ip OK
FSHandler::mount("/local", "/"); //Mount /local path on web root path
svr.addHandler<SimpleHandler>("/hello");
svr.addHandler<RPCHandler>("/rpc");
svr.addHandler<FSHandler>("/");
//Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm
svr.bind(80);
printf("Listening...\n\r");
Timer tm;
tm.start();
//Listen indefinitely
while(true)
{
Net::poll();
if(tm.read()>.5)
{
led1=!led1; //Show that we are alive
tm.start();
}
}
return 0;
}
The second part is to implement the html script which shows the temperature value every 10 seconds and plot it in to a graph.
The javascript code is here: Example 3
Output:
To try this out extract the contents of this zip Example Code (htm file and .bin) directly onto mbed, reset and then navigate to http://192.168.1.100/prova.htm.
NB: For load the javascript files is required the internet connection.
Update: implement the Highcharts graph
6 comments on MCP9700A Sensor & Ethernet:
Please log in to post comments.

hi Edoardo, how as i do to off and on the leds Each independent