/* ////////////////////////////////////////////////////////////////// ARDUINO/Genuino Project "MADIMOD-77110", Environmental Monitoring https://www.changpuak.ch/electronics/Arduino-Madimod-77110-I2C.php Software Version 21.0 25.07.2025 by ALEXANDER SSE FRANK The Serial Parser was written by Christian Monstein, used in "Easy_Diseqc V1.2", Monstein ETH Zurich, 20.06.2018 The Library for the DS18B20 is here : https://github.com/matmunk/DS18B20 Needs also (to be installed) : OneWire.h ////////////////////////////////////////////////////////////////// */ #include #include #include // DISPLAY #define OLED_MOSI 11 #define OLED_CLK 13 #define OLED_DC 9 #define OLED_CS 8 #define OLED_RESET 10 bool OLED_UPSIDE_DOWN = false ; Adafruit_SH1106 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); #if (SH1106_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SH1106.h!"); #endif #include #define LOW_ALARM 20 #define HIGH_ALARM 25 DS18B20 ds(7); uint8_t address[] = {40, 250, 31, 218, 4, 0, 0, 52}; uint8_t selected; int BeepPin = 5 ; bool DEBUG = false ; // SERIAL COMMUNICATION String buffer ; // ///////////////////////////////////////////////////////////////////// // SUBROUTINES SENSOR // ///////////////////////////////////////////////////////////////////// float Messwert = 0.0 ; byte error ; void I2CScan() { byte error, address ; for(address = 1; address < 127; address++ ) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } } void Measure() { // Messwert = ds.getTempC() ; while (ds.selectNext()) { Messwert = ds.getTempC() ; } } // ///////////////////////////////////////////////////////////////////// // SUBROUTINES DISPLAY. // ///////////////////////////////////////////////////////////////////// void UpDateDisplay() { display.clearDisplay() ; display.setTextSize(1) ; display.setTextColor(WHITE) ; display.setCursor(0, 0) ; display.println("MADIMOD-77110-I2C") ; display.drawLine(0, 12, 128, 12, WHITE) ; display.drawLine(0, 63, 128, 63, WHITE) ; display.setCursor(0, 25) ; display.setTextSize(3) ; if(Messwert > 0.0) display.print("+") ; if(Messwert < 0.0) display.print("-") ; if(fabs(Messwert) == 0.0) display.print(" ") ; if(fabs(Messwert) < 10.0) display.print(" ") ; display.print(fabs(Messwert),1) ; display.print(" C") ; // DEGREE CIRCLE display.drawCircle(98, 29, 4, 1); display.drawCircle(98, 29, 3, 1); display.display() ; } // ///////////////////////////////////////////////////////////////////// // SUBROUTINES BEEPER // ///////////////////////////////////////////////////////////////////// const unsigned int BEEPlength = 99 ; void BEEP(unsigned int data) { unsigned int pointer = 0 ; for(int i=31; i>0; i--) { pointer = (1 << i) ; if((pointer & data) > 0) digitalWrite(BeepPin, HIGH) ; else digitalWrite(BeepPin, LOW) ; delay(BEEPlength) ; } digitalWrite(BeepPin, LOW) ; // JUST IN CASE :-) } // ///////////////////////////////////////////////////////////////////// // S E T U P // ///////////////////////////////////////////////////////////////////// void setup() { // START SERIAL COMMUNICATIONS Serial.begin(115200) ; // START WIRE - I2C // Wire.begin() ; // START OLED display.begin(SH1106_SWITCHCAPVCC); if(OLED_UPSIDE_DOWN) display.setRotation(2) ; // 180 degrees // SHOW STARTUP SCREEN display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 0); display.println("MADIMOD-77110-I2C") ; display.drawLine(0, 12, 128, 12, WHITE) ; display.setTextSize(1) ; display.setCursor(0, 20) ; display.println("ARDUINO/GENUINO BASED") ; display.setCursor(0, 32) ; display.println("ENVIRONMENTAL MONITOR") ; display.setCursor(0, 44) ; display.println("(C) WWW.CHANGPUAK.CH") ; display.setCursor(0, 56) ; display.println("BUILT 05.12.2025") ; display.display() ; delay(999) ; // BEEPER BEGIN pinMode(BeepPin, OUTPUT) ; digitalWrite(BeepPin, HIGH) ; delay(999) ; digitalWrite(BeepPin, LOW) ; // CHECK SENSOR } // ///////////////////////////////////////////////////////////////////// // M A I N L O O P // ///////////////////////////////////////////////////////////////////// void loop() { // ///////////////////////////////////////////////////////////////// // CHECK SERIAL PORT if (Serial.available() > 0) // ///////////////////////////////////////////////////////////////// { buffer = Serial.readString() ; // /////////////////////////////////////////////////////// if (buffer.startsWith("*IDN?")) // /////////////////////////////////////////////////////// { Serial.println("MADIMOD-77110-I2C BY CHANGPUAK.CH") ; } else // /////////////////////////////////////////////////////// if (buffer.startsWith("TEMP?")) // /////////////////////////////////////////////////////// { Serial.println(Messwert,3) ; } else // /////////////////////////////////////////////////////// if (buffer.startsWith("HELP")) // /////////////////////////////////////////////////////// { Serial.println("RTFM. TO BE FOUND AT :"); Serial.println("https://www.changpuak.ch/electronics/Arduino-Madimod-77110-I2C.php"); } buffer = "" ; // erase buffer for next command } delay(99) ; Measure() ; UpDateDisplay() ; } // ///////////////////////////////////////////////////////////// // END OF FILE. // /////////////////////////////////////////////////////////////