Devices & Components
Arduino Nano
Panel Mount Extension Mini B USB Cable - for Nano models with Mini USB
tm1637 4 digit dis play
Waterproof 1-Wire DS18B20 Digital temperature sensor
GX12 Male Female 12 mm 3 Pin Connectors
GX16 Male Female 16mm 2 Pin Connectors
5V One Channel Relay Module
Hardware & Tools
Breadboard wire bundle
Project Breadboard
Software & Tools
Arduino IDE
Project description
Code
Displaying temp on TM1637
cpp
Short sample of code from start of course...
1/*-------------------------------------------------------------- 2 Program: Ajustable Thermostatic Sensor / Relay MCU 3 4 Designed for: AIoT Consulting 5 6 Version: v2 7 8 Description: This C++ code works on the ATmega328P microprocessor in conjunction with a DS18B20 Waterproof Temperature Sensor and a TM1637 Display. 9 There is some intelligence built into the program which triggers a single N/C relay should sensors supply data outside nominal 10 operating parameters determined by Rotary Encoder. 11 12 13 Hardware: - Arduino Nano Microcontoller 14 - DS18B20 Waterproof Temperature Sensor 15 - TM1637 (7) Segment (4) LED Display Board 16 - EC11B Rotary Encoder with momentary push button switch 17 - 2 position toggle switch 18 - breadboard and/or Project Case 19 - Various Connectors and wires 20 21 22 Software: Developed using 2.1.0 IDE software 23 24 Date: 2 August, 2023 25 26 Author: Richard Inniss, http://aiotconsulting.com 27 --------------------------------------------------------------*/ 28 29/********************/ 30/*** HEAD SECTION ***/ 31/********************/ 32 33// Include all required libraries 34#include <OneWire.h> // Needed for DS18B20 Temperature probe 35#include <DallasTemperature.h> // Needed for DS18B20 Temperature probe 36#include <TM1637TinyDisplay.h> // Library needed for the TMP1637 7 segment LED display 37 38// Set values to our named constants 39#define ONE_WIRE_BUS 8 40 41// Create our objects to access the methods in each of one of our libraries 42OneWire myWire(ONE_WIRE_BUS); 43DallasTemperature sensors(&myWire); 44TM1637TinyDisplay display(6, 7); 45 46// Declare our global variables 47float tempCelcius = 0.0; 48 49 50/*********************/ 51/*** SETUP SECTION ***/ 52/*********************/ 53 54void setup() 55{ 56 pinMode(6, OUTPUT); // This is for the CLK Pin of the TM1637 LED Display 57 pinMode(7, OUTPUT); // This is for the DIO Pin of the TN1637 LED Display 58 pinMode(8, INPUT); // This is for our DS18B20 Temperature Probe 59 Serial.begin(9600); // This will enable the serial monitor of our IDE 60 sensors.begin(); // This will enable our DallasTemperature object called sensors 61 display.begin(); 62 display.setBrightness(7,true); 63} 64 65/********************/ 66/*** LOOP SECTION ***/ 67/********************/ 68 69void loop() 70{ 71 // First thing we want to do is get the temperature from the probe 72 sensors.requestTemperatures(); 73 tempCelcius = sensors.getTempCByIndex(0); 74 75 // Second thing we want to do is display the current temperature from the probe on our small LCD 76 display.showNumber(tempCelcius, 1, 3, 0); 77 display.showString("\xB0", 1, 3); 78 79}
Comments
Only logged in users can leave comments