![]() # RAM information # Output is in kb, here I convert it in Mb for readability RAM_stats = getRAMinfo() RAM_total = round(int(RAM_stats) / 1000,1) RAM_used = round(int(RAM_stats) / 1000,1) RAM_free = round(int(RAM_stats) / 1000,1) ![]() ![]() While True: # CPU informatiom CPU_temp = getCPUtemperature() CPU_usage = getCPUuse() # 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 If I for example change that sensor data to a static number of any type, the output is consistent.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. but that makes no difference in the integrity. What's perplexing me is that it's getting the data MOST of the time, but every few prints on the Python side it's not correct. I hope this screenshot contains everything to explain what I'm attempting here, and the outputs. In other words, it will Serial.print() just perfect in the IDE, but if I attempt to read from within Python, the sensor value is randomly switching from the correct numbers to totally random numbers. I'm testing some really basic code to send simple sensor data from the Arduino (Uno, Nano) to a Raspberry Pi via USB and using Pyserial (Python3) and in the example here everything ultimately works fine except when the Analog sensor is being read on the other end. My first post here, so please mods move this if I'm not in the right spot!įirstly I realize the scope of this may go beyond Arduino itself, but I figured maybe someone here can help. Hi there, I hope I'm in the right category.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |