Components and supplies
Axial Fan, 12 V
NodeMCU ESP8266 Breakout Board
Project description
Code
Gas detector
arduino
1///Arduino Sample Code 2#include <Adafruit_GFX.h> // Include core graphics library for the display 3#include <Adafruit_SSD1306.h> // Include Adafruit_SSD1306 library to drive the display 4#include <Fonts/FreeMonoBold18pt7b.h> // Add a custom font 5#include <Fonts/FreeMono9pt7b.h> // Add a custom font 6 7Adafruit_SSD1306 display(128, 64); //Create display 8 9 10void setup() 11{ 12 Serial.begin(9600); //Set serial baud rate to 9600 bps 13 14 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Initialize display with the I2C address of 0x3C 15 display.clearDisplay(); // Clear the buffer 16 display.setTextColor(WHITE); // Set color of the text 17 18} 19void loop() 20{ 21 double val; 22 val=analogRead(0);//Read Gas value from analog 0; value 0~1023 23 val=(val/1023)*100; 24 Serial.println(val,DEC);//Print the value to serial port 25 delay(300); 26 27 display.clearDisplay(); // Clear the display so we can refresh 28 29 // Print text: 30 display.setFont(&FreeMono9pt7b); 31 display.setCursor(45,20); // (x,y) 32 display.println("GAS"); // Text or value to print 33 34 // Print temperature 35 char string[10]; // Create a character array of 10 characters 36 // Convert float to a string: 37 dtostrf(val, 3, 0, string); // (<variable>,<amount of digits we are going to use>,<amount of decimal digits>,<string name>) 38 39 display.setFont(&FreeMonoBold18pt7b); // Set a custom font 40 display.setCursor(20,50); // (x,y) 41 display.println(string); // Text or value to print 42 display.setCursor(90,50); // (x,y) 43 display.println("%"); // Text or value to print 44 45 46 display.display(); // Print everything we set previously 47 48 49}
Gas detector
arduino
1///Arduino Sample Code 2#include <Adafruit_GFX.h> // Include core 3 graphics library for the display 4#include <Adafruit_SSD1306.h> // Include Adafruit_SSD1306 5 library to drive the display 6#include <Fonts/FreeMonoBold18pt7b.h> // Add a 7 custom font 8#include <Fonts/FreeMono9pt7b.h> // Add a custom font 9 10Adafruit_SSD1306 11 display(128, 64); //Create display 12 13 14void setup() 15{ 16 Serial.begin(9600); 17 //Set serial baud rate to 9600 bps 18 19 display.begin(SSD1306_SWITCHCAPVCC, 20 0x3C); // Initialize display with the I2C address of 0x3C 21 display.clearDisplay(); 22 // Clear the buffer 23 display.setTextColor(WHITE); // Set color of the text 24 25 26} 27void loop() 28{ 29 double val; 30 val=analogRead(0);//Read Gas value 31 from analog 0; value 0~1023 32 val=(val/1023)*100; 33 Serial.println(val,DEC);//Print 34 the value to serial port 35 delay(300); 36 37 display.clearDisplay(); // Clear 38 the display so we can refresh 39 40 // Print text: 41 display.setFont(&FreeMono9pt7b); 42 43 display.setCursor(45,20); // (x,y) 44 display.println("GAS"); // Text or 45 value to print 46 47 // Print temperature 48 char string[10]; // Create a 49 character array of 10 characters 50 // Convert float to a string: 51 dtostrf(val, 52 3, 0, string); // (<variable>,<amount of digits we are going to use>,<amount of 53 decimal digits>,<string name>) 54 55 display.setFont(&FreeMonoBold18pt7b); 56 // Set a custom font 57 display.setCursor(20,50); // (x,y) 58 display.println(string); 59 // Text or value to print 60 display.setCursor(90,50); // (x,y) 61 display.println("%"); 62 // Text or value to print 63 64 65 display.display(); // Print everything 66 we set previously 67 68 69}
Downloadable files
Gas detector circuit
Gas detector circuit
Comments
Only logged in users can leave comments
whitebank
4 Followers
•0 Projects
1
0