ข้อมูล
น้ำหนัก
บาร์โค้ด
ลงสินค้า
อัพเดทล่าสุด
รายละเอียดสินค้า

 เซนเซอร์วัดความสว่างของแสง GY-49 MAX44009 digital illuminance light intensity sensor module i2c interface high precision

ติดตั้ง TFT 1.44 Library ก่อนใช้งาน

Features

Wide 0.045 Lux to 188,000 Lux Range
VCC = 1.7V to 3.6V
ICC = 0.65µA Operating Current
-40°C to +85°C Temperature Range
Device Address Options – 1001 010x and 1001 011x

หา I2C ก่อน : SCAN I2C

จอ TFT 1.44 นิ้ว








Code:

/*  
    Arduino with Test GY-49 MAX44009 digital illuminance light
     intensity sensor module i2c interface high precision
    For complete project details, visit:Arduinoshop99
*/

#include  "Adafruit_GFX.h"    // Core graphics library

#include  "Adafruit_ST7735.h" // Hardware-specific library

#include  "SPI.h"

#include "Wire.h"

#define Addr 0x4A

 

//#define TFT_CS     D2  //esp8266

//#define TFT_RST    D3 

//#define TFT_DC     D4

 

#define TFT_CS     10  //nano

#define TFT_RST    9 

#define TFT_DC     8

 

#define BLACK   0x0000

#define RED     0x001F

#define BLUE    0xF800

#define GREEN   0x07E0

#define YELLOW  0x07FF

#define PURPLE  0xF81F

#define CYAN    0xFFE0  

#define WHITE   0xFFFF

 

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

#define TFT_SCLK 13   // set these to be whatever pins you like!

#define TFT_MOSI 11   // set these to be whatever pins you like!

float p = 22/7;

 

void setup(void) {

 

  // Use this initializer if you're using TFT

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK);

 

  print_labels();

  draw_buttons();

  delay(1000);

 

Wire.begin();

// Initialise serial communication

Serial.begin(115200);

Wire.beginTransmission(Addr);

Wire.write(0x02);

Wire.write(0x40);

Wire.endTransmission();

delay(300);

 }

 

void loop() {

 // tft.invertDisplay(false);

 // tft.fillScreen(ST7735_BLACK);

 

unsigned int data[2];

Wire.beginTransmission(Addr);

Wire.write(0x03);

Wire.endTransmission();

 

// Request 2 bytes of data

Wire.requestFrom(Addr, 2);

 

// Read 2 bytes of data luminance msb, luminance lsb

if (Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

 

// tft.print(lum);

}

 // Convert the data to lux

int exponent = (data[0] & 0xF0) >> 4;

int mantissa = ((data[0] & 0x0F) << 4) | (data[1] & 0x0F);

int lum = pow(2, exponent) * mantissa * 0.045;

 

Serial.print("Ambient Light luminance :");

Serial.print(lum);

Serial.println(" lux");

            tft.setTextColor(CYAN);

            tft.setTextSize(3);

            tft.setCursor(20,85);

            tft.print(lum);

 

 delay(1000);

 tft.fillRect(10, 80, 80, 30, BLACK);

 

 // tft.fillScreen(ST7735_BLACK);

delay(500);

//----------------------------

  

  tft.invertDisplay(false);

}

void print_labels(){

// tft.invertDisplay(false);

//  tft.fillScreen(ST7735_BLACK);

 // tft.setTextSize(1);

 

  //ON and OFF labels

  tft.setTextSize(2);

  tft.setTextColor(GREEN);

  tft.setCursor(22,8);

  tft.println("Ambient");

  tft.setCursor(25,28);

  tft.println(" light");

 tft.setCursor(10,48);

  tft.println("luminance");

            tft.setTextColor(CYAN);

            tft.setTextSize(3);

           tft.setCursor(10,55);

         //  tft.print(lum);

  

 tft.setCursor(100,100);

 tft.setTextSize(1);

 tft.setTextColor(YELLOW);

 tft.println("Lux");

 //display.clearDisplay();

 

}

void draw_buttons(){

 
  //Rectangle around counter
  tft.drawLine(8,2,8,120, YELLOW);
  tft.drawLine(120,2,120,120, YELLOW);
  tft.drawLine(8,3,120,3, YELLOW);
  tft.drawLine(8,120,120,120, YELLOW);
  tft.drawLine(8,70,120,70, YELLOW);

 

}




เงื่อนไขอื่นๆ
Tags

วิธีการชำระเงิน

บมจ. ธนาคารกรุงไทย สาขาโรงไฟฟ้าบางปะกง ออมทรัพย์
ธนาคารกรุงเทพ จำกัด (มหาชน) สาขาบิ๊กซี ฉะเชิงเทรา 2 ออมทรัพย์
บมจ. ธนาคารกรุงไทย สาขาบิ๊กซี ฉะเชิงเทรา 2 ออมทรัพย์
พร้อมเพย์ สาขา- -
Scan this!
สนธยา ใจผ่อง
063-xxxxxx-8
Accept All Banks | รับเงินได้จากทุกธนาคาร
พูดคุย-สอบถาม