Tag Archives: Lessons

Raspberry Pi Linux LESSON 20: Backing Up Your SD Card and Operating System

It is fairly easy to corrupt your SD card or your operating system on the Raspberry Pi. If this happens, and you do not have a backup, you will likely have to rebuild your system from scratch. Hence, it is important to be diligent in keeping your Pi backed up. In this lesson we show how you can back it up using Windisk32Manager, a free and simple program that will do the trick.

Please note that you can not back the card up by simply using a windows drag and drop of the contents. You actually have to make the disk image as shown in this video.

Raspberry Pi Linux LESSON 1: Introduction to the Pi

If you have followed us through our series of lessons on the Arduino, and then the lessons on using Arduino with Python you have already learned some really cool stuff. You have probably learned so much, in fact, that you are starting to contemplate projects that will stretch the resources available on the arduino. For example, if you decided to add an LCD display to our GPS tracker project, you would probably find that you had run out of memory on the Arduino.

So while we all love, and will continue to love, the Arduino, you do finally reach the point you need a microcontroller with a little more horsepower. This is where the Raspberry Pi comes in. The raspberry pi is about the same size as the arduino, but it has the power of a desktop computer. With the Raspberry Pi, you still have direct access to ports and pins to build your own custom projects, but you have the speed, memory and CPU needed for much more sophisticated projects. The Raspberry Pi runs Linux, which we will have to learn in these lessons. The good news is that when we get the Pi up and running you can write and run python programs on it, and we have already spent quiet a bit of time learning python. So, with your background in Arduino and Python, you will be up and running on the Pi in no time.

To start with you will need to get your gear together. I definitely recommend the Raspberry Pi model 2, as it is the latest and greatest at the time this lesson is being made. You will need the Pi, a power supply, a micro SD card, and a monitor cable. You will also need a monitor, keyboard and mouse, but you probably already have those things laying around. I have found that the best thing is to buy a kit that includes the pi, power supply, micro SD card, monitor cable and USB WIFI adapter. A kit I really like that I think is an excellent value can be found HERE.  Please note that this kit (and most all kits) contain an HDMI to HDMI cable. The output of the Raspberry Pi is HDMI. However, many monitors to not have an HDMI input but want a DVI connector. If your monitor only has DVI input, you will need an additional cable, which you can find HERE. For most people, getting the kit and the cable will be all you need to get started.

If you only have a really old monitor with a VGA input, please note that the HDMI to VGA cables available on amazon do not work. (At least all that I have tried to not work). It is not just a matter of getting  a cable with the right connectors on the end. You have to convert HDMI to analog, which the cable does not do. For the case of making the Pi work with a VGA monitor, I have found the Belkin HDMI to VGA adapter will work with the Pi and you can get it HERE.

Please note that I have found the trickiest part of getting the Pi up and running is getting the right cable for your monitor. Please carefully check what type of monitor you have, and get the right cable.

So, get your gear ordered and in the next lesson we will cover how to get things hooked up and configured.

Python with Arduino LESSON 17: Sending and Receiving Data Over Ethernet

Arduino Ethernet
This circuit contains an Arduino Nano and Pressure Sensor Communicating over Ethernet

In LESSON 16 we showed a simple Client Server model that allows us to send strings between Python running on a PC and the arduino over Ethernet. That lesson simply passed strings back and forth to show a very basic Server on Arduino, and Python acting as the Client. In this lesson we show a more practical example, with the Arduino connected to an Adafruit BMP180 Pressure Sensor. In order to complete this lesson, you will need an Arduino, an Ethernet Shield, and the Pressure Sensor. If you do not have this particular pressure sensor, you can probably follow along in the lesson using whatever sensor you have that is of interest. The video will take you through the tutorial step-by-step, and then the code we developed is shown below.

The key issue in getting this project to work is to get your mac address and IP address from your router or network. If you are at school, simply speak to your network administrator, and he will help you get an IP address for your arduino. If you are at home, you will need to connect to your router from a browser, and configure it to assign an IP address and agree on a mac address for your arduino. Some arduino Ethernet shields have a sticker with a mac address. If your Ethernet shield has a sticker with mac address, use that one. If it does not, you will need to come up with a unique mac address. There are thousands of possible routers and networks out there, so I can not help you with that part. But if you look in the router documentation, you should be able to get the IP address and mac address worked out. The arduino itself does not have a hard wired mac address, but you set the mac address in the arduino software, and the IP address as well. The key thing is that the mac address is unique on your network, and the router and arduino agree on the IP address and mac address. If you have a clearer way to explain this, please leave a comment below.

This is the server side software to run on the arduino. Again, you should use a suitable IP address and mac address for your network. Do not think you can just copy the ones I use in the code below.

Once you have this on your arduino, and the arduino connected to the internet via an Ethernet cable, you can test by opening a command line in Windows. Then ping the address you have assigned to the Arduino. If it pings correctly and you get a reply, you are ready to develop the Python code. The Python will be the client. It will send the requests to the Arduino, and the Arduino will respond with data. Since our circuit can measure pressure or temperature, you can request either of those. When the arduino receives a request for temperature, it will go out, make the temperature measurement and then return the data to Python. Similarly, if you request Pressure the arduino will read the request, will make the Pressure measurement, and then return pressure reading to the client (Python).

 This python code will request Temperature, will then read the response, and then will print the data. It then requests Pressure, reads the response, and then prints it. If you look at our earlier lessons you can see graphical techniques to visually present the data. The hard part is getting the data passed back and forth, which we show how to do in this lesson.

Python with Arduino LESSON 15: Configuring and Using the Xbee Radios

This lesson describes how to program the Xbee Series 1 radios. It will work with either the standard Series 1 (S1) or the Series 1 Pro models. The Pro radios are higher power and will give greater range, but they cost more. The radios are configured using X-CTU software, which can be downloaded here.  The video gives step by step instructions on how to configure and use the radios to communicate wirelessly over the serial port. Lesson 14 gives information on the hardware needed. Lessons 1-13 sill show you how to communicate between Python and Arduino if you need to get caught up on basic serial communication and interfacing arduino and python. The techniques provided in the video above, however, should work for just about any arduino project where you want to communicate between two arduinos, an arduino and PC, or between two PCs.

Python with Arduino Lesson 14: Introduction to Xbee Radios and Wireless Communication

In the video lesson above, we introduce our next series of lessons, which will step you through using Xbee radios to allow your arduino projects to wirelessly communicate with your PC. The good news is that you already know how to communicate between your Arduino and the PC over the serial cable based on our previous lessons. Using Xbee radios is very similar, you just remove the cable. You are still communicating over the serial ports, so the coding remains virtually unchanged . . . you just have to configure and connect the radios. In order to do these lessons, you will need a pair of Series 1 (S1) Xbee Radios (you will need two). If you want longer range, and are willing to pay more, you can get the Seris 1 (S1) Xbee Pro Radios.

To program the radios, you will need a SparkFun USB Explorer.

The final equipment you need will be an Xbee Shield. The shield allows you to plug the Xbee radio into the Arduino.