Permalink
Browse files

Ajout de ArduinoAtmogram

  • Loading branch information...
1 parent 9294684 commit bdb734c3c881de2dcffce8a7597bbb18e30c79c0 Florian Lissot committed Jan 27, 2012
Showing with 6,427 additions and 0 deletions.
  1. +40 −0 ArduinoAtmogram/README
  2. BIN ArduinoAtmogram/docs/LCD_preview.jpg
  3. BIN ArduinoAtmogram/docs/poster1.pdf
  4. BIN ArduinoAtmogram/docs/poster2.pdf
  5. BIN ArduinoAtmogram/docs/screen_preview.png
  6. +184 −0 ArduinoAtmogram/src/arduino/ArduinoAtmogram.ino
  7. +150 −0 ArduinoAtmogram/src/arduino/librairies/DHTsensorLibrary/DHT.cpp
  8. +35 −0 ArduinoAtmogram/src/arduino/librairies/DHTsensorLibrary/DHT.h
  9. +3 −0 ArduinoAtmogram/src/arduino/librairies/DHTsensorLibrary/README.txt
  10. +44 −0 ArduinoAtmogram/src/arduino/librairies/DHTsensorLibrary/examples/DHTtester/DHTtester.pde
  11. +349 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Dhcp.cpp
  12. +158 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Dhcp.h
  13. +423 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Dns.cpp
  14. +41 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Dns.h
  15. +95 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Ethernet.cpp
  16. +38 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/Ethernet.h
  17. +165 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetClient.cpp
  18. +37 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetClient.h
  19. +91 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetServer.cpp
  20. +22 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetServer.h
  21. +183 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetUdp.cpp
  22. +98 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/EthernetUdp.h
  23. +222 −0 .../arduino/librairies/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino
  24. +63 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/ChatServer/ChatServer.ino
  25. +53 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino
  26. +80 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino
  27. +76 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/DnsWebClient/DnsWebClient.ino
  28. +144 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/PachubeClient/PachubeClient.ino
  29. +121 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/PachubeClientString/PachubeClientString.ino
  30. +87 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/TelnetClient/TelnetClient.ino
  31. +124 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/TwitterClient/TwitterClient.ino
  32. +118 −0 ...noAtmogram/src/arduino/librairies/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino
  33. +136 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino
  34. +75 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/WebClient/WebClient.ino
  35. +82 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/examples/WebServer/WebServer.ino
  36. +37 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/keywords.txt
  37. +13 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/util.h
  38. +400 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/utility/socket.cpp
  39. +41 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/utility/socket.h
  40. +188 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/utility/w5100.cpp
  41. +397 −0 ArduinoAtmogram/src/arduino/librairies/Ethernet/utility/w5100.h
  42. +215 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/LCD4884.cpp
  43. +43 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/LCD4884.h
  44. +89 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/examples/LCD4884_deux/dfr48841.pde
  45. +23 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/examples/LCD4884_menu/DFrobot_bmp.h
  46. +36 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/examples/LCD4884_menu/DFrobot_chinese.h
  47. +284 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/examples/LCD4884_menu/LCD4884_menu.pde
  48. +112 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/examples/LCD4884_menu/wiring.h
  49. +101 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/font_6x8.h
  50. +141 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/font_big.h
  51. +112 −0 ArduinoAtmogram/src/arduino/librairies/LCD4884/wiring.h
  52. +61 −0 ArduinoAtmogram/src/arduino/librairies/SPI/SPI.cpp
  53. +70 −0 ArduinoAtmogram/src/arduino/librairies/SPI/SPI.h
  54. +143 −0 ...tmogram/src/arduino/librairies/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino
  55. +143 −0 ...iries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.ino
  56. +71 −0 ArduinoAtmogram/src/arduino/librairies/SPI/examples/DigitalPotControl/DigitalPotControl.ino
  57. +36 −0 ArduinoAtmogram/src/arduino/librairies/SPI/keywords.txt
  58. BIN ArduinoAtmogram/src/webserver/chart_bg.jpg
  59. 0 ArduinoAtmogram/src/webserver/data.csv
  60. +118 −0 ArduinoAtmogram/src/webserver/index.php
  61. +16 −0 ArduinoAtmogram/src/webserver/js/jscharts.js
@@ -0,0 +1,40 @@
+** Arduino Atmogram **
+
+
+* Description *
+
+Monitor and display temperature and humidity informations on a LCD screen and log it on a web server.
+
+Look at docs directory to look at preview.
+
+Arduino Uno with:
+ - DHT11 (temperature & humidity sensors);
+ - LCD 4884 screen;
+ - Ethernet shield;
+
+
+* Installation *
+
+Arduino:
+ "ArduinoAtmogram.ino":
+ - Define your sensor type : "#define DHTTYPE DHT11" or DHT22 if you use it and map the PIN;
+ - Set up "IP Arduino" and "IP web server" depending on your config;
+ - Add a gateway and a subnet if you don't post to a local server "Ethernet.begin(mac, ip, gw, sub)";
+
+ "librairies":
+ - Librairies that you need are in librairies directory copy it in Arduino app folder.
+
+Web server:
+ Set up:
+ - Copy content of "webserver" directory to the root of your web server;
+ - Be sure that "data.csv" is readable and writeable ('chmod 777 data.csv');
+
+
+* Enjoy *
+
+We know that our program is not perfect, but it is enough for us.
+
+Fork the project and push me your improvements.
+
+vjo - https://github.com/vjo/
+flissot - https://github.com/flissot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,184 @@
+/*
+ ArduinoAtmogram
+
+ Monitor the temperature and humidity and display the values on the LCD screen.
+ It also POST the values to a web server to log it.
+
+ Build on the top of Web client arduino's example.
+
+ Circuit:
+ * Ethernet shield attached to pins 10, 11, 12, 13
+ * DHT11 (temp & humidity sensors)
+ * LCD4884 shield
+
+ Florian Lissot & Victor Jolissaint
+ @ FabLab Telecom Bretagne 2012.
+ */
+
+#include <SPI.h>
+#include <Ethernet.h>
+#include "LCD4884.h"
+#include "DHT.h"
+
+#define DHTPIN A1 // what pin we're connected to
+#define DHTTYPE DHT11 // DHT 11 : our captor
+
+DHT dht(DHTPIN, DHTTYPE);
+
+// Enter a MAC address for your controller below.
+// Newer Ethernet shields have a MAC address printed on a sticker on the shield
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+IPAddress ip(192,168,0, 2); // IP Arduino
+IPAddress server(192,168,0, 254); // IP web server
+
+// Initialize the Ethernet client library
+// with the IP address and port of the server
+// that you want to connect to (port 80 is default for HTTP):
+EthernetClient client;
+
+void setup() {
+ // start the serial library:
+ Serial.begin(9600);
+ // start the Ethernet connection:
+ Ethernet.begin(mac, ip);
+
+ // Show if the @IP is set
+ // print your local IP address:
+ Serial.print("My IP address: ");
+ ip = Ethernet.localIP();
+ for (byte thisByte = 0; thisByte < 4; thisByte++)
+ {
+ // print the value of each byte of the IP address:
+ Serial.print(ip[thisByte], DEC);
+ Serial.print(".");
+ }
+ Serial.println();
+
+ /* init lcd screen */
+ lcd.LCD_init();
+ lcd.LCD_clear();
+ lcd.LCD_write_string(0, 0, "Florian &", MENU_NORMAL );
+ lcd.LCD_write_string(0, 1, "Victor", MENU_NORMAL );
+ lcd.LCD_write_string(0, 2, "presents:", MENU_NORMAL );
+ lcd.LCD_write_string(0, 3, "", MENU_NORMAL );
+ lcd.LCD_write_string(0, 4, " Arduino", MENU_NORMAL );
+ lcd.LCD_write_string(0, 5, " Atmogram", MENU_NORMAL );
+
+ // LCD blink 3 times
+ lcdBlink(3, 200);
+
+ // Sensors
+ dht.begin();
+
+ // Give the Ethernet shield a second to initialize:
+ delay(1000);
+ Serial.println("ready...");
+}
+
+void loop()
+{
+ // Reading temperature or humidity takes about 250 milliseconds!
+ // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
+ float humi = dht.readHumidity();
+ float temp = dht.readTemperature();
+
+ // Convert int to char
+ char humiBuf[3];
+ char tempBuf[3];
+ sprintf(humiBuf, "%d", (int)humi);
+ sprintf(tempBuf, "%d", (int)temp);
+
+ // Check if returns are valid, if they are NaN (not a number) then something went wrong!
+ if (isnan(temp) || isnan(humi)) {
+ Serial.println("Failed to read from DHT");
+ }
+ else {
+ Serial.print("Humidity: ");
+ Serial.print(humi);
+ Serial.print(" %\t");
+ Serial.print("Temperature: ");
+ Serial.print(temp);
+ Serial.println(" *C");
+ }
+
+ lcd.LCD_clear();
+
+ // int raw = analogRead(8);
+ // int temp = MULTIPLIER * (float) raw;
+ char tempString[6] = "";
+ char humiString[6] = "";
+
+ sprintf(tempString,"%d",(int)temp);
+ sprintf(humiString,"%d",(int)humi);
+
+ // Draw a cloud
+ unsigned char sunnycloudbmp[] =
+ {
+ 0x00,0xE0,0x18,0x0C,0x0C,0x08,0x08,0xD0,0x20,0x10,0x08,0x08,0x08,0x10,0x10,0x30,0x10,0x20,0x24,0x44,0x48,0xB0,0x10,0x13,0x0C,0x08,0x08,0x1C,0x16,0x71,0xA0,0x10,0x18,0x08,0x00,
+ 0x00,0x71,0x9F,0x03,0x02,0x02,0x00,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x08,0x08,0x0F,0x08,0x88,0x88,0x90,0xF0,0x70,0xCC,0x0F,0x19,0x31,0x61,0x01,
+ 0x00,0x00,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x04,0x04,0x0C,0x08,0x08,0x08,0x0C,0x07,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00
+ };
+ lcd.LCD_draw_bmp_pixel(40, 0, sunnycloudbmp, 35,20); // (posi,tion , name, si,ze)
+
+ // Display temp
+ lcd.LCD_write_string(0, 1, "+", MENU_NORMAL);
+ lcd.LCD_write_string_big(6, 0, tempString, MENU_NORMAL);
+ lcd.LCD_write_string(30, 1, "C", MENU_NORMAL);
+
+ // Draw a drop
+ unsigned char dropbmp[] =
+ {
+ 0x00,0x00,0x00,0x80,0x40,0x20,0x18,0x07,0x0C,0x10,0x60,0x80,0x00,0x00,0x00,
+ 0x00,0x00,0x06,0x0B,0x10,0x26,0x28,0x28,0x20,0x20,0x10,0x0F,0x00,0x00,0x00
+ };
+ lcd.LCD_draw_bmp_pixel(32,4, dropbmp, 15,15); // (posi,tion , name, si,ze)
+
+ // Display humidity
+ lcd.LCD_write_string_big(50, 3, humiString, MENU_NORMAL);
+ lcd.LCD_write_string(75, 4, "%", MENU_NORMAL);
+
+ Serial.println("connecting...");
+
+ // If you get a connection, report back via serial:
+ if (client.connect(server, 80)) {
+ Serial.println("connected");
+
+ // Make a HTTP request:
+ char req[80];
+ sprintf(req, "GET /index.php?temp=%s&humi=%s HTTP/1.0", tempBuf, humiBuf);
+
+ //Serial.println(req); // print the request
+
+ client.println(req); //send request
+ client.println();
+ }
+ else {
+ // if you didn't get a connection to the server:
+ Serial.println("connection failed");
+ }
+
+ // if there are incoming bytes available
+ // from the server, read them and print them:
+ if (client.available()) {
+ char c = client.read();
+ Serial.print(c);
+ }
+
+ client.stop(); // if not, it can re-connect anymore
+
+ // Refresh time
+ delay(10000);
+
+ // LCD blink 2 times to notify the refresh
+ lcdBlink(2, 200);
+}
+
+void lcdBlink(int count, int delayMs) {
+ for(int i=0; i< count; i++){
+ lcd.LCD_backlight(1);
+ delay(delayMs);
+ lcd.LCD_backlight(0);
+ delay(delayMs);
+ }
+ lcd.LCD_backlight(1);
+}
@@ -0,0 +1,150 @@
+/* DHT library
+
+MIT license
+written by Adafruit Industries
+*/
+
+#include "DHT.h"
+
+DHT::DHT(uint8_t pin, uint8_t type) {
+ _pin = pin;
+ _type = type;
+ firstreading = true;
+}
+
+void DHT::begin(void) {
+ // set up the pins!
+ pinMode(_pin, INPUT);
+ digitalWrite(_pin, HIGH);
+ _lastreadtime = 0;
+}
+
+float DHT::readTemperature(void) {
+ float f;
+
+ if (read()) {
+ switch (_type) {
+ case DHT11:
+ f = data[2];
+ return f;
+ case DHT22:
+ case DHT21:
+ f = data[2] & 0x7F;
+ f *= 256;
+ f += data[3];
+ f /= 10;
+ if (data[2] & 0x80)
+ f *= -1;
+
+ return f;
+ }
+ }
+ Serial.print("Read fail");
+ return NAN;
+}
+
+float DHT::readHumidity(void) {
+ float f;
+ if (read()) {
+ switch (_type) {
+ case DHT11:
+ f = data[0];
+ return f;
+ case DHT22:
+ case DHT21:
+ f = data[0];
+ f *= 256;
+ f += data[1];
+ f /= 10;
+ return f;
+ }
+ }
+ Serial.print("Read fail");
+ return NAN;
+}
+
+
+boolean DHT::read(void) {
+ uint8_t laststate = HIGH;
+ uint8_t counter = 0;
+ uint8_t j = 0, i;
+ unsigned long currenttime;
+
+ // pull the pin high and wait 250 milliseconds
+ digitalWrite(_pin, HIGH);
+ delay(250);
+
+ currenttime = millis();
+ if (currenttime < _lastreadtime) {
+ // ie there was a rollover
+ _lastreadtime = 0;
+ }
+ if (!firstreading && ((currenttime - _lastreadtime) < 2000)) {
+ return true; // return last correct measurement
+ //delay(2000 - (currenttime - _lastreadtime));
+ }
+ firstreading = false;
+ /*
+ Serial.print("Currtime: "); Serial.print(currenttime);
+ Serial.print(" Lasttime: "); Serial.print(_lastreadtime);
+ */
+ _lastreadtime = millis();
+
+ data[0] = data[1] = data[2] = data[3] = data[4] = 0;
+
+ // now pull it low for ~20 milliseconds
+ pinMode(_pin, OUTPUT);
+ digitalWrite(_pin, LOW);
+ delay(20);
+ cli();
+ digitalWrite(_pin, HIGH);
+ delayMicroseconds(40);
+ pinMode(_pin, INPUT);
+
+ // read in timings
+ for ( i=0; i< MAXTIMINGS; i++) {
+ counter = 0;
+ while (digitalRead(_pin) == laststate) {
+ counter++;
+ delayMicroseconds(1);
+ if (counter == 255) {
+ break;
+ }
+ }
+ laststate = digitalRead(_pin);
+
+ if (counter == 255) break;
+
+ // ignore first 3 transitions
+ if ((i >= 4) && (i%2 == 0)) {
+ // shove each bit into the storage bytes
+ data[j/8] <<= 1;
+ if (counter > 6)
+ data[j/8] |= 1;
+ j++;
+ }
+
+ }
+
+ sei();
+
+ /*
+ Serial.println(j, DEC);
+ Serial.print(data[0], HEX); Serial.print(", ");
+ Serial.print(data[1], HEX); Serial.print(", ");
+ Serial.print(data[2], HEX); Serial.print(", ");
+ Serial.print(data[3], HEX); Serial.print(", ");
+ Serial.print(data[4], HEX); Serial.print(" =? ");
+ Serial.println(data[0] + data[1] + data[2] + data[3], HEX);
+ */
+
+ // check we read 40 bits and that the checksum matches
+ if ((j >= 40) &&
+ (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) {
+ return true;
+ }
+
+
+ return false;
+
+}
Oops, something went wrong.

0 comments on commit bdb734c

Please sign in to comment.