Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Arnov Sharma
Published © MIT

PICO TEMPERATURE GUN Version 1

Raspberry Pi PICO 2 Powered TEMP GUN based around the GY-906 Infrared Temp Module.

BeginnerFull instructions provided1 hour535
PICO TEMPERATURE GUN Version 1

Things used in this project

Hardware components

Raspberry Pi Pico 2
Raspberry Pi Pico 2
×1
PCBWay GY-9
×1
PCBWay Custom PCB
PCBWay Custom PCB
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

WIRING

Code

code

C/C++
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int buttonPin = 0; // GPIO0 pin for button
const int sensorAddress = 0x5A; // GY-906-BAA I2C address

void setup() {
  Serial.begin(9600);
  pinMode(buttonPin, INPUT_PULLUP);
  Wire.begin();

  // SSD1306 OLED display initialization
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000); // Pause for 2 seconds
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Press button");
  display.display();
}

void loop() {
  int buttonState = digitalRead(buttonPin);
  Serial.print("Button State: ");
  Serial.println(buttonState);

  if (buttonState == LOW) { // Button is pressed when LOW with INPUT_PULLUP
    Serial.println("Button Pressed");
    float temperature = readTemperature();
    Serial.print("Temperature: ");
    Serial.println(temperature);
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("Temp: ");
    display.print(temperature);
    display.print(" C");
    display.display();
  } else {
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("Press button");
    display.display();
  }
  delay(100);
}

float readTemperature() {
  Wire.beginTransmission(sensorAddress);
  Wire.write(0x07);
  Wire.endTransmission(false);
  Wire.requestFrom(sensorAddress, 3);

  int16_t tempData = Wire.read();
  tempData |= Wire.read() << 8;

  float temperature = tempData * 0.02 - 273.15;
  return temperature;
}

Credits

Arnov Sharma
326 projects • 331 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.