I am trying to take a MLX90621 sensor and attach it to the ESP8266 and have the temperatures printed to a web page.
Currently, I have a working program that shows the temperatures from the MLX on the serial port using a Pro-mini. I got the code from here https://github.com/longjos/MLX90621_Arduino_Camera and just took out the code that went to the display. This program works great!
Now I would like to use the ESP8266 Thing and have it post the temperatures to a webpage. I took the code from above and added in code to try and make it work with the ESP8266 but when I compile the code I get the following error.
Arduino: 1.6.5 (Windows 7), Board: "SparkFun ESP8266 Thing, 80 MHz, 115200"
twi.c:25:20: fatal error: avr/io.h: No such file or directory
#include <avr/io.h>
^
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Could someone please explain why I am getting this error? I thought that the wire library supported the Thing.
Thank you for reading and any help you can provide! Please find the code below =)
/*
* This project creates a small thermal camera using the MELEXIS MLX90621
* It prints the temperature in the Serial Monitor in degC (degF)
*
* Adapted by Leah Oty December 3, 2015
* https://github.com/longjos/MLX90621_Arduino_Camera
* Based on https://github.com/robinvanemden/MLX90621_Arduino_Processing
* Wire diagram found on http://www.pavlov.io/2015/05/15/detecting-crying-eyes/
*
* Original work by:
* 2013 by Felix Bonowski
* Based on a forum post by maxbot: http://forum.arduino.cc/index.php/topic,126244.msg949212.html#msg949212
* Adapted by Josh Long (https://github.com/longjos) Oct 2015
* Based on a https://github.com/robinvanemden/MLX90621_Arduino_Processing
* This code is in the public domain.
*/
#include <SPI.h>
#include "ESP8266WiFi.h"
#include <Arduino.h>
#include "Wire.h"
#include "MLX90621.h"
MLX90621 sensor; // create an instance of the Sensor class
const char* ssid = "CrMcH7600";
const char* password = "Rc1716PsK";
// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);
void setup(){
Serial.begin(115200);
delay(10);
sensor.initialise (2); //(A)4 on Mini
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop(){
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
sensor.measure(true); //get new readings from the sensor
sensor.getAmbient();
Serial.println();
Serial.println("Ambient Temp:");
Serial.print(sensor.getAmbient());
Serial.print("(");
Serial.print((sensor.getAmbient())*1.8+32);
TA = (sensor.getAmbient())*1.8+32;
Serial.print(")");
Serial.println();
sensor.getMinTemp();
Serial.println("MinTemp:");
Serial.print(sensor.getMinTemp());
Serial.print("(");
Serial.print((sensor.getMinTemp())*1.8+32);
TMin = (sensor.getMinTemp())*1.8+32;
Serial.print(")");
Serial.println();
sensor.getMaxTemp();
Serial.println("MaxTemp:");
Serial.print(sensor.getMaxTemp());
Serial.print("(");
Serial.print((sensor.getMaxTemp())*1.8+32);
TMax = (sensor.getMaxTemp())*1.8+32;
Serial.print(")");
Serial.println();
for(int y=0;y<4;y++){ //go through all the rows
Serial.println();
for(int x=0;x<16;x++){ //go through all the columns
Serial.print(" ");
Serial.print(sensor.getTemperature(y+x*4));
Serial.print("(");
Serial.print((sensor.getTemperature(y+x*4))*1.8+32);
AllData = (sensor.getTemperature(y+x*4))*1.8+32;
Serial.print(")");
}
}
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\Temperature Readings are: ";
s += " <br>";
s += "Ambient Temp:";
s += TA;
s += " <br>";
s += "MinTemp:";
s += TMin;
s += " <br>";
s += MaxTemp:;
s += TMax;
s += " <br>";
s += "All Data";
s += AllData;
s += "</html>\n";
// Send the response to the client
client.print(s);
}
delay(1);
Serial.println("Client disonnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
};