Jump to content

DoubleHP

Members
  • Posts

    46
  • Joined

  • Last visited

Reputation Activity

  1. Like
    DoubleHP got a reaction from atomic77 in OrangePi Zero LTS vs DHT22   
    In case the other website goes down, I will duplicate their original code here. Don't forget to fix your PIN number.
     
    My WiringPi lib is probably https://github.com/zhaolei/WiringOP (not 100% certain).
     
    /* * dht.c: * read temperature and humidity from DHT11 or DHT22 sensor */ #include <wiringPi.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #define MAX_TIMINGS 85 #define DHT_PIN 3 /* GPIO-22 */ int data[5] = { 0, 0, 0, 0, 0 }; void read_dht_data() { uint8_t laststate = HIGH; uint8_t counter = 0; uint8_t j = 0, i; data[0] = data[1] = data[2] = data[3] = data[4] = 0; /* pull pin down for 18 milliseconds */ pinMode( DHT_PIN, OUTPUT ); digitalWrite( DHT_PIN, LOW ); delay( 18 ); /* prepare to read the pin */ pinMode( DHT_PIN, INPUT ); /* detect change and read data */ for ( i = 0; i < MAX_TIMINGS; i++ ) { counter = 0; while ( digitalRead( DHT_PIN ) == laststate ) { counter++; delayMicroseconds( 1 ); if ( counter == 255 ) { break; } } laststate = digitalRead( DHT_PIN ); if ( counter == 255 ) break; /* ignore first 3 transitions */ if ( (i >= 4) && (i % 2 == 0) ) { /* shove each bit into the storage bytes */ data[j / 8] <<= 1; if ( counter > 16 ) data[j / 8] |= 1; j++; } } /* * check we read 40 bits (8bit x 5 ) + verify checksum in the last byte * print it out if data is good */ if ( (j >= 40) && (data[4] == ( (data[0] + data[1] + data[2] + data[3]) & 0xFF) ) ) { float h = (float)((data[0] << 8) + data[1]) / 10; if ( h > 100 ) { h = data[0]; // for DHT11 } float c = (float)(((data[2] & 0x7F) << 8) + data[3]) / 10; if ( c > 125 ) { c = data[2]; // for DHT11 } if ( data[2] & 0x80 ) { c = -c; } float f = c * 1.8f + 32; printf( "Humidity = %.1f %% Temperature = %.1f *C (%.1f *F)\n", h, c, f ); }else { printf( "Data not good, skip\n" ); } } int main( void ) { printf( "Raspberry Pi DHT11/DHT22 temperature/humidity test\n" ); if ( wiringPiSetup() == -1 ) exit( 1 ); while ( 1 ) { read_dht_data(); delay( 2000 ); /* wait 2 seconds before next read */ } return(0); }  
  2. Like
    DoubleHP got a reaction from guidol in Failed to start Load Kernel Modules. xradio_wlan   
    Hello.
     
    Armbian_5.35_Orangepizero_Ubuntu_xenial_default_3.4.113.7z
    Orange Pi Zero 256
     
    I am rading the bootlog via serial console.
     
    [FAILED] Failed to start Load Kernel Modules. See 'systemctl status systemd-modules-load.service' for details.
     
    # systemctl status systemd-modules-load.service â systemd-modules-load.service - Load Kernel Modules Loaded: loaded (/lib/systemd/system/systemd-modules-load.service; static; vendor preset: enabled) Drop-In: /lib/systemd/system/systemd-modules-load.service.d ââ10-timeout.conf Active: failed (Result: exit-code) since Sun 2018-12-30 00:20:40 CET; 3min 8s ago Docs: man:systemd-modules-load.service(8) man:modules-load.d(5) Process: 167 ExecStart=/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE) Main PID: 167 (code=exited, status=1/FAILURE) Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. Warning: systemd-modules-load.service changed on disk. Run 'systemctl daemon-reload' to reload units. # journalctl -f -b _PID=167 -- Logs begin at Sun 2018-12-30 00:20:45 CET. -- Dec 30 00:20:45 opi-06-app-c13 systemd-modules-load[167]: Failed to insert 'xradio_wlan': Connection timed out Dec 30 00:20:45 opi-06-app-c13 systemd-modules-load[167]: Inserted module 'g_serial' Dec 30 00:20:45 opi-06-app-c13 systemd-modules-load[167]: Inserted module 'xradio_wlan' ^C # cat /etc/modules #w1-sunxi #w1-gpio #w1-therm #sunxi-cir xradio_wlan g_serial xradio_wlan  
    If I remove any xradio_wlan, then wlan0 is not available at boot.
     
    Is there a way to fix the boot error message, without loosing wlan0 ?
     
    Obviously, some one is aware of an issue, because some dev has put the same line twice in modules ...
  3. Like
    DoubleHP got a reaction from guidol in OrangePi Zero, mainline kernel, SPI LCD + touchscreen   
    Update:
     
    I have bought
    https://www.fasttech.com/products/0/10020192/5321900-3-5-320-480-tft-lcd-display-touch-board-for
    Sold with the following specs:
    which seems to me very similar to
    https://www.amazon.fr/gp/product/B06X191RX7/ref=oh_aui_detailpage_o02_s00?ie=UTF8&amp;psc=1
     
    I started with image Armbian_5.35_Orangepizero_Ubuntu_xenial_next_4.13.16.img
     
    And then, ran the following commands to get the LCD working on oPi0:

     
    aptitude dist-upgrade vim /root/myili9431.dts # see previous message reboot aptitude install linux-headers-next-sunxi armbian-add-overlay myili9431.dts reboot modprobe fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1  
    and now I have a console in portrait mode.
     
    # cat /root/myili9431.dts /* author: Adrian Brzezinski: adrb at wp.pl, adrian.brzezinski at adrb.pl */ /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target-path = "/aliases"; __overlay__ { spi1 = "/soc/spi@01c69000"; }; }; fragment@1 { target = <&spi1>; __overlay__ { status = "okay"; spidev { compatible = "spidev"; reg = <0>; spi-max-frequency = <50000000>; }; }; }; }; To get X:

     
    # Some of the following packages may be facultative. aptitude install startx xinit x11-xserver-utils xinput-calibrator xinput xserver-xorgxserver-xorg-video-all xterm x11-utils startx # gives a black console # or xinit # gives a white console  
    Mouse does not work very well. Did not try keyboard. No touchpad (I don't need it, so, no time to loose on this).
     
    Rotation of screen works, but produces crappy output.
     
    # Need reboot each time modprobe fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1 rotate=90 modprobe fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1 rotate=180 modprobe fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1 rotate=270 # 90 and 270 produce a rectangle in landscape orientation; unusable in neither console or X. # 180 works fine. Bed time; more tries later.
     
    Some tips to make conf persistent:
    https://kaspars.net/blog/linux/spi-display-orange-pi-zero
  4. Like
    DoubleHP got a reaction from guidol in OrangePi Zero, mainline kernel, SPI LCD + touchscreen   
    In the end, what worked for me:
     
    0: my system: "ARMBIAN 5.35 user-built Debian GNU/Linux 8 (jessie) 4.13.16-sunxi" (called next)
    1: I am not going to try using the touch layer.
    2: wire things as described (with LED directly on 3.3V)
    3: aptitude install linux-headers-next-sunxi
    4: copy the content of "Configuration for the first spi bus" from initial post, except last line about EOF, into /root/myili9431.dts
    5: armbian-add-overlay myili9431.dts
    6: edit /boot/armbianEnv.txt and edit this line (some parts may be useless or overkill) overlays=usbhost2 usbhost3 spi-spidev spidev myili9431 (this appeared to be useless)
    7: reboot
    8: modprobe fbtft_device custom name=fb_ili9341 gpios=dc:3,reset:0,led:6 speed=16000000 busnum=1
    ... and immediately the LCD turned from all white, into classic console (black background with prompt at the top)
     
    Here is my dmesg:
     
    [ 166.951033] fbtft: module is from the staging directory, the quality is unknown, you have been warned. [ 166.962129] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned. [ 166.967576] fbtft_device: GPIOS used by 'fb_ili9341': [ 166.967602] fbtft_device: 'dc' = GPIO3 [ 166.967627] fbtft_device: 'reset' = GPIO0 [ 166.967649] fbtft_device: 'led' = GPIO6 [ 166.967703] spi spi1.0: fb_ili9341 spi1.0 16000kHz 8 bits mode=0x00 [ 166.983929] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned. [ 167.341354] Console: switching to colour frame buffer device 30x40 [ 167.344793] graphics fb0: fb_ili9341 frame buffer, 240x320, 150 KiB video memory, 16 KiB buffer memory, fps=20, spi1.0 at 16 MHz https://kaspars.net/blog/linux/spi-display-orange-pi-zero mentions rotate=90 ... could be usefull for someone
     
    9: xinit worked immediately
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines