This is an old revision of the document!
For the following applications, you will read data coming from sensors, which means that you will also need to use the Arduino board. As the Raspberry Pi has no ADCs, you cannot read values coming from analog sensors.
As previously stated, the classical Arduino board is basically a micro-controller, which is capable of running one piece of software at once and that has little processing power and no network connectivity. So you will use the board to gather data from the environment and then pass it on to the Raspberry Pi.
The Raspberry Pi is a computer that is capable of processing data and communicating with other smart devices. For instance, you could visualise the temperature on your smart phone.
The two boards need to be connected in order to send data between them. You can connect them via the USB cable and a serial connection will be established between the two. Once this is done, they can exchange data and the Arduino board can be controlled via the Raspberry Pi. This is done by the firmata protocol. The protocol allows the Raspberry Pi to send the Arduino messages in which it requests for a certain action or information and the Arduino will respond accordingly.
In order to implement the protocol, you need to flash the Arduino with the StandardFirmata firmware.
In the Wyliodrin STUDIO interface you have two tabs referring to SOFTWARE and FIRMWARE. So far, you used only the SOFTWARE tab, as you wrote applications for the Raspberry Pi solely. Now, select the FIRMARE tab and there is where you can write code which will be run on the Arduino. In this case, you will import an existing project.
Hit the Show examples button and select Arduino. Then use the Firmata/StandardFirmata example. Now that you have the software to run on the Arduino, once you hit the run button, you will be asked the tyype of the Arduino board and if you want to flash it or not. Select the board you are using and RUN AND FLASH. The StandardFirmata firmware will be deployed on the Arduino.
As you know, any micro-controller, including the Arduino, once flashed, runs the same firmware until another one is uploaded on the board. Thus, you don't have to flash the board each time you run a new Raspberry Pi application. If you are confident that the Arduino is running StandardFirmata, you can skip this step.
In this application, you will build a system to monitor the light level and if there is the case, you will turn on the street lights brighter or dimmer, depending on the amount of light.
You that now have a thermometer can you find something extra to make it more interesting? Try a light sensor.
The photocell works just like a voltage divider, as well (check the Introduction to Electronics chapter for more details). You need to connect it to the Gnd and Vcc and from between the photocell and the resistor to the analog pin of the board. This light sensor has a resistance that varies with the light, the more light there is, the lower the resistance of the photocell. Depending on how you place the sensor you can obtain a pull up or pull down voltage divider.
The new nodes are much simpler. You just add a block to read the analog pin that you use and send it to the chart.