Raspberry Pi web server using flask to control GPIOs

featured-image-600

Rui Santos from Random Nerd Tutorials writes:

In this project you’ll create a standalone web server with a Raspberry Pi that can toggle two LEDs. You can replace those LEDs with any output (like a relay or a transistor).
In order to create the web server you will be using a Python microframework called Flask.

More details at Random Nerd Tutorials homepage.

Check out the video after the break.

Using BMP180 for temperature, pressure and altitude measurements

BMP180_11

Raj from Embedded Lab has posted a comprehensive tutorial on how to use BMP180 for temperature, pressure, and altitude measurements:

The BMP180 is a new generation digital barometric pressure and temperature sensor from Bosch Sensortec. In this tutorial, we will briefly review this device and describe how to interface it with an Arduino Uno board for measuring the surrounding temperature and pressure. We will also discuss about retrieving the sensor altitude from its pressure readings.

Details at Embedded Lab homepage.

How do I FPGA?

img_20140319_175333-600

TC-Engineering writes:

I’ve been thinking about building stuff with FPGA’s for a while, and usually get turned away because FPGA’s are considerably harder to implement than microcontrollers since they have no on-chip memory. It is necessary to re-program the gates every time they power up, which requires an external flash memory chip. There aren’t great references online for the DIY community, so I figured I’d post how to get this working. Not using dev boards opens a world of opportunities, so I’m a proponent of not using Arduino’s and their FPGA equivalent for too long (sure, they’re good to get started with, but don’t become dependent)
Not wanting to screw up an expensive complex board by being a first-timer at putting an FPGA into a circuit, I figured I’d build a little test board with the cheapest Spartan 6 you can get (about $10), which comes in a solderable TQFP144 package. Sadly, most high end FPGA’s are BGA and therefore quite hard to solder as a DIY project.

More details at TC-Engineering blog.

NFC tags and Android smartphones

I recently brought from Banggood 3 NFC tags, for about 4 euros. Tags are adhesive and round shaped; the package also contains three colored stickers labeled please touch it to cover the tags:

nfc-01

A NFC (Near Field Communication) tag is a passive device (it does not contain batteries or any other power sources) that, when located near to a reader, establishes with it a peer-to-peer communication to change data. A tag contains some read only fields (for example the serial number) and also normally offers some memory locations where the reader can store custom data (read and write).

If your Android smartphone features an NFC reader, you can – thanks to dedicated apps – read and write NFC tags. In this tutorial I’ll show you how it’s possible to configure the smartphone to automatically execute tasks when it scans an NFC tag.

First, install from the Google Play store the free applications NFC Tools e NFC Tasks:

nfc-00

Run NFC Tools (sorry if the screenshots below are in italian!):

rfid-1

Put the tag next to the phone; you’ll hear a beep and NFC Tools will display tag’s information:

rfid-2

Choose the TASKS tab and click on Add actions:

rfid-3

In this example, I’m going to configure my smartphone to run the Waze navigator when I put it near the tag. You can of course configure different actions: the list of the actions supported by the app is very impressive!

Choose Application – Launch app and select the app you want to be launched:

rfid-4

Click on Write and put the tag near the phone:

rfid-5

Wait for the confirmation:

rfid-6

If I glue the tag on my smartphone car mount, I can now automatically launch the navigator app when I put the phone in it:

Connecting Arduino to 3.3V devices

Increasingly you may need to connect to your Arduino devices that operate with 3.3V.

Lowering the integrated circuits’ operating voltage  has in fact several advantages:

  • allows to realize smaller transistors
  • requires a lower heat dissipation
  • allows faster state changes (the voltage difference between a logic state LOW and HIGH is lower)

this is why manufacturers of modules, sensors … are adopting the voltage of 3.3V as the standard.

The problem

Take as a reference an Arduino Uno. The board can be powered in different ways (through the 2.1mm jack, via the USB connector…) but the operation voltage is 5V, supplied by the onboard regulator:

uno-regulator

The board has also a 3.3V regulator (LP2985), you may use to power external devices with that voltage:

uno-regulator2

All the PINs therefore works at 5V: if a digital PIN is configured as output, a logical value 1 (digitalWrite(PIN, HIGH);) corresponds to a voltage of 5V on that PIN.

If instead the PIN is configured as input, a voltage greater than 2.5V on that PIN will be considered as a logical value 1; a voltage lower than 2.5V as a logical value 0.

Let’s now connect to that PIN a corresponding PIN of a device powered at 3.3V:

  • if the Arduino PIN is configured as input (device -> Arduino) there are no problems: when the device wants to send a logic high, it imposes a voltage of 3.3V that is correctly interpreted by Arduino (> 2.5V);
  • if instead the Arduino PIN si configured as output (Arduino -> device), in case of a logic high Arduino imposes a voltage of 5V, that exceeds the working voltage of the device and can thus damage it!

Some devices, while operating at 3.3V, can accept higher voltages on their I/O PINs. Those devices are usually defined 5V tolerant: always check the datasheet!

Solutions

There are several possible solutions to adapt the two operating voltages.

The simplest ones, require only passive components (diodes, resistors…). Le soluzioni più semplici utilizzano soltanto componenti passivi (diodi, resistenze…). These solutions work well from the point of view of the tensions but introduce transients during the transitions of state that do not make them suitable for high-speed communications. Some of these solutions are well described in this blog post and their effects are shown on an oscilloscope.

The solution I adopted and suggest uses a small module, sold by several webshops (for example I got mine from Banggood):

level-1 level-2

This module uses transistors to convert up to 4 signals.

Its use is very simple: first to connect the to HV the higher supply voltage and to LV the lower; then connect the ground (GND). Connect the PINs of the device with higher voltage to the PINs labeled as HVx, while the corresponding PINs of the other device to the PINs labeled as LVx.

For example, to make a serial connection between Arduino and a device working ad 3.3V, the connections are as follows:

level-5

Here’s an example of the use of the module on a breadboard:

level-3 level-4