Avatar for user73385

user73385

Member since Feb 2017 • Last active Feb 2018
  • 0 conversations
  • 1 comments

Most recent activity

  • in ESP32
    Avatar for user73385

    I have nearly the exace same problem.
    I have baught and received one of those cheap TTGO ESP32 with OLED and batterypack two days ago.
    I have downloaded 1v95, setup my folders/project and previously with the ESP8622 i had used thingssdk as a toolchain so i could stay in my editor, but that didn't work anymore with the ESP32. So i changed to the IDE, which is ... well it is something, but i prefer sublime and a console. And it seems slower than before. But i can live with that.

    So far the OLED runs without any change to my old code, great! But the DHT22 makes me sad.
    My code is basically that from the OP, i have connected the D-pin from the DHT with D15 on my board, i even threw in a 10kRes.
    but all i get is a checksumError:

    #3987[r1,l1] Object {
      #4008[r1,l2] Name String [1 blocks] "err"    #4007[r1,l1] Bool true
      #4009[r1,l2] Name String [2 blocks] "checksumError"    #3994[r1,l1] Bool false
      #3986[r1,l2] Name String [1 blocks] "raw"    #4005[r2,l1] String [1 blocks] ""
      #4010[r1,l2] Name String [1 blocks] "temp"= int -1
      #4018[r1,l2] Name String [1 blocks] "rh"= int -1
    }
    

    so i guess i managed to damage my DHT or am i missing sth?

    mycode:

    let pin_DHT22 = D15; // D-out DHT22
    const DHT = require('DHT22').connect(pin_DHT22);
    // 
    const intval_temp_measure = 10 * 1000; // every n second
    let intval_temp_measure_id = null;
    //
    const measureInterval = function() {
    	DHT.read(function (a) {
          if(a.err) {
             trace(a); 
          }
    		let temp = a.temp.toString();
    		let rh = a.rh.toString();
    		//if(a.raw.length > 3)
    		  drawMeasurement(temp, rh);
    	});
    };
    // 
    let temps = []; // store temperature data for some time
    // 
    let sig = false; 
    const drawMeasurement = function(temp, rh){
    	// wipe clean
    	OLED.clear();
    	
    	if(temp === undefined) {
    		OLED.setFontBitmap();
    		OLED.setFont8x12();
    		OLED.drawString('Warte auf Daten ...', 1, 1);
    	} else {
    		if(temps.length >= 124) { // we can only draw so much on the x-axis
    			temps.shift(); // remove first entry
    		}
    		temps.push(temp);
    
    		//  draw chart:
    		//  we have: x => 2 -> 126 and y => 22 -> 62
    		for(var t = 0; t < temps.length; t++) {
    			var y = temps[t] + 22 ;
    			var x = t + 2;
    		}
    
    		// OLED.setFontBitmap();
    		// OLED.setFont8x12();
    		// OLED.drawString('Aktuelle Temperatur:', 0, 0);
    		// 
    		OLED.setFontVector(15);
    		OLED.drawString(temp + ' C', 1, 1);
    		//
    		// OLED.setFontBitmap();
    		// OLED.setFont8x12();
    		// OLED.drawString('Luftfeuchtigkeit:', 0, 15);
    		// 
    		OLED.setFontVector(12);
    		OLED.drawString(rh + ' %', 74, 2);
    	}
    	// draw some borders
    	/*
    	________|________
        |                |
    	|                |
    	|________________|
    	*/
    	//            x1  y1  x2  y2
    	OLED.drawLine(64, 0, 64, 21);
    	OLED.drawLine(0, 21, 127, 21);
    
    	OLED.drawLine(0, 21, 0, 64);
    	OLED.drawLine(127, 21, 127, 64);
    	
    	OLED.drawLine(0, 63, 127, 63);
    
    	// refresh
    	OLED.flip();
    	return 'temp.: ' + temp + ' C, hum.: ' + rh + ' %';
    };
    //  ----------------------------------------­--------
    let pin_OLED_SCL = D4; // onboard
    let pin_OLED_SDA = D5; // onboard
    // PRECONF
    I2C1.setup({
    	scl: pin_OLED_SCL,
    	sda: pin_OLED_SDA
    });
    require('Font8x12').add(Graphics);
    let OLED = null;
    // 
    function testOLED(){
        log('writing on OLED');
    	OLED.clear();
    	//OLED.setFontBitmap();
    	OLED.setFont8x12();
     	// write some text
     	OLED.drawString("loading ...", 2, 2);
     	// write to the screen
     	OLED.flip();
    }
    
    function main () {
        log('main started');
    	let OLED_options = {
    		address: 0x3C
    	};
    	OLED = require("SSD1306").connect(I2C1, testOLED, OLED_options);
    	//OLED.off();
        intval_temp_measure_id = setInterval(measureInterval, intval_temp_measure);
        measureInterval();
    }
    
    function init() {
    	//OLED.on();
    	log('program start ...');
        main();
    }
    setTimeout(init, 1500);
    
Actions