![]() ![]() ![]() # Return information about disk space as a list (unit included) # Index 0: total disk space # Index 1: used disk space # Index 2: remaining disk space # Index 3: percentage of disk used def getDiskSpace(): p = os.popen(“df -h /”) i = 0 while 1: i = i +1 line = p.readline() if i=2: return(line.split()) #Get external IP def getIP(): data = urllib.urlopen(“”).read() return data def serialClear(): ser.write(“00clr”) def serialWrite(Line1, Line2): serialClear() time.sleep(betWait) ser.write(“00″+Line1) time.sleep(betWait) ser.write(“01″+Line2)ĭef getPID(): pid = os.getpid() return pid time.sleep(3) #wait for arduino to reset LiquidCrystal595 lcd(7,8,9) // datapin, latchpin, clockpin int contrastPin = 6 int brightnessPin = 10 int contrast = 135 int brightness = 255 String input = “” String stringRec = “” String pos = “” int posX = 0 int posY = 0 SerialClear() //clear LCD time.sleep(betWait) //wait a bit for stringRead timeout ser.write(“00″+Line1) //send first line time.sleep(betWait) //wait a bit for stringRead timeout ser.write(“01″+Line2) //send second line This is the python function which sends the strings to the arduino: def serialClear(): The commands to get the Raspberry Pi system info in the python script I found them online at click here The python script is written so that it always adds the coordinates before the string I wrote a function which takes two arguments the first argument is the string that will be displayed at 00 (first line of lcd) and at 01 (second line of lcd) String Format: #String (since this is a 16×2 LCD the first number can range from 0-15 X position and the second number from 0 to 1 Y position) The arduino code listens for any strings coming in through the serial port, removes the first two characters which I chose to be the position where to write the string on the LCD and the rest would be the string to output. This is simple just connect the usb which you use to program the arduino into a free port on the Raspberry PI Step 4: The Code & How it worksĪs you can see in the images and the code I added two more wires from the arduino to the LCD these basically control the LCD contrast instead of using a potentiometer and the screen brightness with PWM. Step 3: Connecting the Arduino to the Raspberry PI ![]() If you connect the arduino in any other way you might need to change a couple of things in the code like the library import, the way the LCD gets initialised, and some commands to print to the LCDmight be different. This is the link to that instructable: click here You can follow the steps and find the full list of parts needed there. The main parts used are the arduino, the LCD, a shift register and an NPN transistor for the LED backlight of the LCD I get commissions for purchases made through links in this table.Now you can connect the arduino to the LCD anyway you prefer but to connect the arduino and the LCD I used a project I found here on instructables which I found to be really helpful it allows you to use a shift register to connect the arduino and the LCD using only 3 wires, but you can always connect the LCD directly to the arduino if you don't need any extra pins on the arduino. The following table gives you an overview of all components and parts that I used for this tutorial, but you only need one Raspberry Pi and one DHT temperature and humidity sensor. If the Raspberry Pi is connected via USB directly to the socket than you can use the power supply via the USB connection to the Raspberry Pi to power both the Pi and the Arduino.In case of you used Arduino Uno we use the DC barrel power jack. Good to know that there are two other possibilities to save the power supply as you can read in the different article about the micro-controller: Arduino Mega, Arduino Uno, Arduino Nano. Also this was my first idea and I tried this possibility, but the power supply of the Raspberry Pi broke down and the Pi shut down. In this case you have to find another power supply for the Arduino because the PC or Laptop is not able to supply both the Raspberry Pi (~ 700mA/5volt) and the Arduino (~ 40-50mA/5volt). The Raspberry Pi is connected via USB to a PC or Laptop.In general we have to differ between two use cases. But in case of the Arduino the USB cable connection is blocked by the connection to the Raspberry Pi. We can power the Raspberry Pi as usual about the micro USB port on the side of the unit. The power supply for the Pi is not restricted by the serial communication. Now let us talk about the power supply for the Raspberry Pi and the Arduino. As mentioned before we use an USB cable for the Arduino to Raspberry Pi communication. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |