To not miss my updates, remember to check the public account in the upper right corner and set it as a star. Please give me a star!
This is a pen holder made entirely of PCBs and 3D printed parts, which is completely different from traditional pen holders. It has many functions, including temperature and humidity display, an aesthetically pleasing onboard LED light, and a USB port that provides 5V power. Without further ado, let’s watch the video; please understand it by yourself.
Here is the detailed production process. The schematic code and related files can be downloaded at the end of the article.
-
ESP12F Module
-
SSD1306 OLEDAHT10 Sensor
-
5mm Red LED
-
IP5306 Power Management IC
-
1uF 0805 Package Capacitor
-
18650 Lithium Ion Battery Holder
-
3.7V 2900mAh Lithium Ion Battery
-
3D Printed Parts
-
10K Resistor
-
5.6 Ohm 1206 Package Resistor
-
USB Type-C Port
➣ Design Concept
➣ Circuit Diagram PCB Design
➣ ComponentsSoldering
Starting from the front-end temperature/humidity PCB assembly, this requires using two soldering techniques as it involves both SMD and THT components.
1) First, use a solder paste dispenser to apply solder paste on each SMD component pad.
2) Next, we use ESD tweezers to pick up all SMD components and place them in the appropriate positions.
3) Following the pick and place procedure, carefully lift the PCB and place it on the SMT reflow soldering heating plate, which heats the PCB from below to the melting temperature of the solder paste, permanently soldering all components to their pads.
4) We collect all THT components, including the OLED display and AHT10 sensor module, place them on their pads, and then solder the pads with a standard soldering iron.
➣ Programming the Temperature/Humidity Board with NODEMCU
#include <Wire.h>#include <AHTxx.h>
#include <Adafruit_SSD1306.h>#include <Adafruit_GFX.h>
#define OLED_WIDTH 128#define OLED_HEIGHT 64
#define OLED_ADDR 0x3CAdafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);
float ahtValue; //to store T/RH result
AHTxx aht10(AHTXX_ADDRESS_X38, AHT1x_SENSOR); //sensor address, sensor type
void setup(){ #if defined(ESP8266) WiFi.persistent(false); //disable saving wifi config into SDK flash area WiFi.forceSleepBegin(); //disable AP & station by calling "WiFi.mode(WIFI_OFF)" & put modem to sleep #endif
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); display.clearDisplay();
Serial.begin(115200); Serial.println(); while (aht10.begin() != true) //for ESP-01 use aht10.begin(0, 2); { Serial.println(F("AHT1x not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free delay(5000); }
Serial.println(F("AHT10 OK")); //Wire.setClock(400000); //experimental I2C speed! 400KHz, default 100KHz}
void loop(){ /* DEMO - 1, every temperature or humidity call will read 6-bytes over I2C, total 12-bytes */ Serial.println(); Serial.println(F("DEMO 1: read 12-bytes"));
ahtValue = aht10.readTemperature(); //read 6-bytes via I2C, takes 80 milliseconds
display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(30, 0); display.println(F("Temp-"));// Serial.print(F("Temperature...: ")); if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs { display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(35, 25); display.println(ahtValue); display.display();// Serial.print(ahtValue); } else { printStatus(); //print temperature command status
if (aht10.softReset() == true) Serial.println(F("reset success")); //as the last chance to make it alive else Serial.println(F("reset failed")); }
delay(2000); //measurement with high frequency leads to heating of the sensor, see NOTE
ahtalue = aht10.readHumidity(); //read another 6-bytes via I2C, takes 80 milliseconds
display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(30, 0); display.println(F("Humd-"));// Serial.print(F("Humd-")); if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs { display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(35, 25); display.println(ahtValue); display.display(); // Serial.println(F(" +-2%")); } else { printStatus(); //print humidity command status }
delay(2000); //measurement with high frequency leads to heating of the sensor, see NOTE /* DEMO - 2, temperature call will read 6-bytes via I2C, humidity will use same 6-bytes */ Serial.println(); Serial.println(F("DEMO 2: read 6-byte"));
ahtValue = aht10.readTemperature(); //read 6-bytes via I2C, takes 80 milliseconds
Serial.print(F("Temperature: ")); if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs { Serial.print(ahtValue); Serial.println(F(" +-0.3C")); } else { printStatus(); //print temperature command status }
ahtValue = aht10.readHumidity(AHTXX_USE_READ_DATA); //use 6-bytes from temperature reading, takes zero milliseconds!!!
Serial.print(F("Humidity...: ")); if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs { Serial.print(ahtValue); Serial.println(F(" +-2%")); } else { printStatus(); //print temperature command status not humidity!!! RH measurement use same 6-bytes from T measurement }
delay(10000); //recommended polling frequency 8sec..30sec}
void printStatus(){ switch (aht10.getStatus()) { case AHTXX_NO_ERROR: Serial.println(F("no error")); break;
case AHTXX_BUSY_ERROR: Serial.println(F("sensor busy, increase polling time")); break;
case AHTXX_ACK_ERROR: Serial.println(F("sensor didn't return ACK, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)")); break;
case AHTXX_DATA_ERROR: Serial.println(F("received data smaller than expected, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)")); break;
case AHTXX_CRC8_ERROR: Serial.println(F("computed CRC8 not match received CRC8, this feature supported only by AHT2x sensors")); break;
default: Serial.println(F("unknown status")); break; }}
Original link:
https://www.hackster.io/Arnov_Sharma_makes/overengineered-pen-holder-2-0-5c0daf
<<< STM32 Project Summary >>>
<<< Raspberry Pi Project Summary >>>
<<< ESP32 Project Summary >>>
<<< ESP8266 Project Summary >>>
<<< Arduino Project Summary >>>
<<< Darwin Project Sharing Full Series >>>
Leave a Comment
Your email address will not be published. Required fields are marked *