My Raspberry Pi + Arduino Project

Discussion in 'Coding, Scripting & Programming' started by wlanboy, Jan 21, 2014.

  1. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    https://vimeo.com/87249046

    So what did I build?

    My servers <-> Internet <-> Rapsberry Pi <-> Arduino <-> Shiftregister <-> blinking things

    1. Cronjob running a Ruby script
      This script does:
      • Load list of ips and loop through list doing:
      • Ping ip
      • Try to login via ssh (key based)
      • Check if other sessions are open
      • Check if logfiles should be checked (logwatch report with bad words)
      • Save short status to byte array
      • Write this array to the EEPROM (512 bytes!!) of the Arduino (serial)
    2. Loop within Arduino
      • Load array of status bits
      • Loop through array
      • For each item
        Increase counter and refresh digit display (count + 1)
      • Check status of each byte
      • Enable or disable LEDs
    So the digit display is showing which server status is currently displayed (0 to 9 - so 10 servers).

    The 6 LEDs (red/green/red/green/yellow/yellow) do show:

    1. Ping status (red bad / green good)
    2. Service status (red bad / green good) [if every required service is running or not]
    3. Other sessions are open (yellow) [so someone is playing around]
    4. Logstatus (yellow) [Hey I should look at those log files]

    I am still searching for a good 16 bit shift register (maybe the STP16C596A) and I want to add a 4x16 LCD module too.

    The Raspberry Pi is able to handle the stuff too but can only work with 3.3V input/output where the Arduino can handle 5V input/output.

    It is a pain to work with resistors for each single GPIO of the Raspberry Pi:

    5v3v.jpg

    And - of course - you save a lot of energy because the Arduino is more energy efficient.

    I like the idea of separated areas of responsibility:

    Raspberry Pi doing all the network and analysing stuff and Arduino doing all the electro-technics.

    I toy with the idea of buying a USB hub to connect several Arduinos with one Raspberry Pi.

    One Arduino for the LCD/LED stuff

    One Arduino for the temperature/light/movement stuff

    One Arduino for a touch button pad - each button for one action like ssh login and calling scripts, etc.

    Yup your right - I am currently running riot on this electro stuff.

    Edit: Added video link.
     
    Last edited by a moderator: Feb 21, 2014
    vRozenSch00n, MannDude and peterw like this.
  2. peterw

    peterw New Member

    800
    189
    Jun 14, 2013
    Nice setup. How do you even out the pin pulses for the shift register? I use a capacitor for this problem.

    Is everthing going through the shift register or do you connect directly to the leds?

    Are you using /dev/ttyUSB0 for the communication? What library do you using? I use pySerial for the communication with Arduino.
     
  3. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    1. 250 Ohm resistor - lowering the noise.
    2. Only the digit display is controlled through the shift register, LEDs through digital pins.
    3. Yup tty through USB using the serialport gem.
     
    peterw likes this.
  4. BuyCPanel-Kevin

    BuyCPanel-Kevin New Member Verified Provider

    121
    23
    Oct 7, 2013
    That's actually really cool! I might have to set one up for my server to check on it, I'd definitely use an LCD over the LED's though ;)
     
  5. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    You're right but I have to start somewhere.

    What LCD would you suggest?
     
  6. peterw

    peterw New Member

    800
    189
    Jun 14, 2013
    If you want a easy setup take a LCD with Hitachi HD44780 driver. LiquidCrystal.h is badass.


    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    void setup() {
    lcd.begin(16,2);
    }

    void loop() {
    lcd.setCursor(0, 0);
    lcd.print("I like Arduino");
    delay(500);
    lcd.setCursor(0, 1);
    lcd.print("and vpsboard");
    delay(500);

    for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
    lcd.scrollDisplayLeft();
    delay(150);
    }

    for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    lcd.scrollDisplayRight();
    delay(150);
    }

    lcd.clear();
    }

    2.486 Bytes of C magic.
     
    wlanboy likes this.
  7. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    I read about the Hitachi screen too.

    There are quite a lot of libs floating around for that driver but I use the officials ones.
     
  8. peterw

    peterw New Member

    800
    189
    Jun 14, 2013
    I prefer the new LiquidCrystal library: https://bitbucket.org/fmalpartida/new-liquidcrystal/overview

    Code:
    New LiquidCrystal library - LCD Library. This library is a derivative of the original LiquidCrystal Library
     as sourced in the Arduino SDK. The library supports most Hitachi HD44780 based LCDs or compatible. 
    LCDs can now be control via 4, 8, I2C bus expander or a Shift Register Extender.
    
     
    wlanboy likes this.
  9. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
  10. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    Updated post to add video.
     
  11. NodeBytes

    NodeBytes Dedi Addict

    687
    92
    May 15, 2013
    Seems the video was removed from youtube.
     
  12. wlanboy

    wlanboy Content Contributer

    2,126
    1,169
    May 16, 2013
    I am using vimeo and it had to be activated for the media tags.

    Video is now displayed.