Vilros Raspberry PI Ult Kit report on installation experiences

I came to know about  technical specifications of raspberry pi i.e, what architecture does it follow,how much memory does it have (512 MB).

Install Raspberry NOOBS to the pi:

NOOBS is a tool in raspberry pi that helps in install of OS in raspberry. What I observed NOOBS is already installed in SD card .

I have inserted the memory card ,HDMI cable,WIFI dongle in to their respective slots.

IMG_20160124_222943

It displayed multiple OS to install. I have installed raspbian OS.

 

Blinking  an LED:

First I tried to blink an led by setting up in a circuit . The breadboard    connections   to correct GPIO header and i used 330 ohms resistor. So that I made a set up without connecting it to HDMI  by supplying a power supply to raspberry pi so that it can blink. BASIC LED BLINK (VIDEO LINK).

single led1

Controlling GPIO Pins from terminal window has been done by using the commands given in user guide.

Python and Io Experiments:

EXPERIMENT 1

GPIO pins can be controlled by using PYTHON programming BLINKING OF LED USING PYTHON (VIDEO LINK).

EXPERIMENT 2

BLINKING OF  TWO LED’S ALTERNATIVELY.

BLINKING WITH TWO LED’S ALTERNATIVELY(VIDEO LINK).

PROGRAM CODE FOR TWO LED’S BLINK (CODE LINK).

CONNECTING PI TO LAPTOP:

I have connected  raspberry pi to laptop using XMING server and PUTTY .

 

laptop connection to raspberry pi

EXPERIMENT 3

TWO LED DIMMING VIDEO LINK  PROGRAM CODE

EXPERIMENT 4

Reading GPIO PIN from PYTHON 3

68891011-e6e3-4dac-bbff-7af5cb517d90

VIDEO LINK

code link

EXPERIMENT 5(BUTTON  INPUT LED DISPLAY)

I have written python code such that when  I press the button the led should turn off.

11911aba-fa14-4e6b-aceb-6f283c01b50a

 

VIDEO LINK

CODE LINK

——————————————————————————————————————————————————————————————————————

 

Tutorial for DHT11 and PI

 

Wiring up DHT11 humidity sensors to raspberry pi has been done using  10k resistor

 

IMG_20160127_090829.jpg

 

Software Install has been done

install library.png

installing library part2.png

 

Testing the Library

I have run the code in example folder using below command

sudo ./AdafruitDHT.py 11 4

Temperature DHT11

 

Connecting to Googles Docs

I have created spreadsheets and got OAuth2 credentials

I made changes to the python code. Here the link for the code.

https://github.com/chandrapavan/Adafruit_Python_DHT.

 

I have run the program using sudo ./google_spreadsheet.py command.

google spreadsheet sheet updated.png

https://docs.google.com/spreadsheets/d/1ZDn_twqBBrALDvuR-a7e2_ExEwrnIPgmy33Lyjvg3x0/edit?usp=sharing

 

Serial Peripheral Interface(SPI):

SPI is  a serial data protocol  that is used by by micro controllers used for short distance communication exchange , primarily in embedded systems.

SPI divides in two catgories

1.MASTER

2.SLAVE

The master is the device that starts the communication. Slave receives the instructions from master.

SPI has four pins

MOSI(Master Output Salve Input) p1-19

MISO(Master Input Slave output). p1-21

SCK(Serial Clock ).p1 23 p1-24 CE0

SS(slave select) P1-25 p1 -26 CE1(Chip enable)

 

363px-SPI_three_slaves.svg

Enabling the SPI on the raspberry pi

Enabiling SPI 1.jpgEnabiling SPI2.jpg

Using SPI from python

Enabiling SPI3

Because of 23k640  SPI memory chip is not their with me i  was not able to do experiment.

I have a plan of connecting LCD display  for showing up temperature and humidity.

Unfortunately  NOKIA LCD display is missing from Arduino kit. I reordered it Once it is reached i will post the experiment video.

——————————————————————————————————————————————————————————————————————
Arduino Programming class effort

Which laptop OS are you testing to program from: Windows 10

What is the PI you are using and which OS is it setup with? raspberry pi and raspbian.

What is the hardware that is needed? oddwires ESP8266,data cable,breadboard.

What is the software that is needed? ARDUINO 1.6.7  compaitable for windows 10.

How do you wire it together?  place the ESP8266 to the breadboard and plug the data cable to the laptop . place the anode of led to the 13 pin and cathode of led to ground.

What is the logical first test?

a. led

VIDEO LINK

 

CODE:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

I faced the problem  while uploading the code. I made change of upload speed  and changed the data cable.

I pressed the reset button and then its working fine now.

Reference https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon

https://www.arduino.cc/en/Guide/HomePage

——————————————————————————————————————————————————————————————————————

Tutorial to program the Arduino:

Flashing LED circuit:

Make a led light  setup connected to the Arduino circuit .

Download the Arduino software IDE from DOWNLOAD LINK respective of your OS of laptop.

Install it in your laptop  and  connect Arduino setup  to laptop using USB cable .

arduino led setup

In the  software IDE file tab we could see preference tab where in Additional bookmark manager slot  paste the link LINK

In the tools tab  select in board type  select( NodeMCU 1.0(ESP-12E Module). GO to board manager and install Esp8266 related packages.

 

In the file tab go for examples tab and select basics category  and blink code

 

void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Make sure you connected led to D7 pin of arduino which is 13 no. we used in program.

Upload it to arduino. See  how the led blinks in the given below video link.

VIDEO LINK

 

FLASHING LED 

 

I just made one change and inbulit led of arduino is blinked.

void setup() {
// initialize digital pin 13 as an output.
pinMode(16, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

VIDEO LINK

 

Temperature/Humidity sensor circuit:

 

Install the  packages of all dht11 in inculde library category of sketch  tab in Arduino software IDE.

arduino setup of temperature and humidity sensor

Below is the  code.

#include “DHT.h”

#define DHTPIN 13 // what digital pin we’re connected to

// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println(“DHTxx test!”);

dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow
sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}

// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);

Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.print(” *C “);
Serial.print(f);
Serial.print(” *F\t”);
Serial.print(“Heat index: “);
Serial.print(hic);
Serial.print(” *C “);
Serial.print(hif);
Serial.println(” *F”);
}

select * from raw_data where 1
select cast(time_exam_began as TIMESTAMP)
from raw_data;

select from_unixtime)

 

After uploading the program to arduino. It displays temperature and humidity details for every two seconds.

VIDEO LINK

Difference setting up and programming interface using two different source ( laptop and pi )

It doesn’t make any difference usually with pi or laptop.

But the installation process for  arduino software IDE in pi is a bit slow when compare to laptop.

 

By using the command  sudo apt-get install arduino

Arduino software IDE gets installed in Raspberry pi.

 

arduino installation in raspberrypi

But after connecting the arduino board to pi and uploading the codeit is popping up an error

IMG-20160208-WA0011

 

pi issue using arduino

I searched in web  to find out the issue  i tried all the options which they mentioned but none worked out.

Different sensor setup we can do with arduino

light sensors
location  gps sensors
magnetic hall effect sensors
switches and buttons
pressure sensors

————————————————————————–

Arduino with multiple leds:

VIDEO LINK

 

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

Most Arduinos have an on-board LED you can control. On the Uno and
Leonardo, it is attached to digital pin 13. If you’re unsure what
pin the on-board LED is connected to on your Arduino model, check
the documentation at http://www.arduino.cc

This example code is in the public domain.

modified 8 May 2014
by Scott Fitzgerald
*/

int ar[] = { 15,12,2,5};
int i = 0;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
for(int i = 0; i < 5 ; i++){
pinMode(ar[i], OUTPUT);
}
}

// the loop function runs over and over again forever
void loop() {
int i;
digitalWrite(15, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
for(i = 1; i < 4 ; i++){
digitalWrite(ar[i], HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ar[i-1], LOW); // turn the LED on (HIGH is the voltage level)
delay(500);
}

digitalWrite(5, LOW);

for(int i=3; i>0 ; i–) {
digitalWrite(ar[i], HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ar[i+1], LOW); // turn the LED on (HIGH is the voltage level)
delay(500);
}

digitalWrite(12, LOW);

}

 

 

BUTTON Test

 

Connect led  anode to pin 13  and cathode to ground.

Connect one end of button to ground.

other end of button to 220 ohms resistor .

Other end of resisitor to Ground.

Video link

 

 

// set pin numbers:
const int buttonPin = 14;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}

 

 

—————————————————————————————————————————————————-

 

WIFI CLIENT FOR PI :

By scanning the  nearby wifi using command

sudo iwlist wlan0 scan

and making changes to the wpa-supplicant file file by using command

sudo pico /etc/wpa_supplicant/wpa_supplicant.conf

By making changes to the  file by giving respective  ssid and psk .

network={
ssid=”ssi_name”
psk=”ssid_password”
key_mgmt=
}

We can connect to the wifi.

—————————————————————————————————————————————————-

Attempt to make Pi as WIFI AP:

We need to install DHCP server  and set up is made by changing dhcpd.conf file 

By making it as authoritative  and adding lines at the end

  1. subnet 192.168.42.0 netmask 255.255.255.0 {
  2. range 192.168.42.10 192.168.42.50;
  3. option broadcastaddress 192.168.42.255;
  4. option routers 192.168.42.1;
  5. defaultleasetime 600;
  6. maxleasetime 7200;
  7. option domainname “local”;
  8. option domainnameservers 8.8.8.8, 8.8.4.4;
  9. }

 

Setup wlan0  for static ip

Edit the interface file by  command sudo nano /etc/network/interfaces

By netmask the ip address we are making ip address of it visible

This can be implemented by  adding following lines

  1. iface wlan0 inet static
  2. address 192.168.42.1
  3. netmask 255.255.255.0

Configure Access Point:

Changing the  hostapd.conf file by using the command

sudo nano /etc/hostapd/hostapd.conf

set ssid and password for that.

and  sudo nano /etc/default/hostapd  file  and add 

DAEMON_CONF=”/etc/hostapd/hostapd.conf”

Setting up NAT will allow multiple clients to connect to the WiFi and have all the data ‘tunneled’ through the single Ethernet IP

 run sudo nano /etc/sysctl.conf

and add net.ipv4.ip_forward=1

and run  sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward

to activate it immediately

wifi signal

Video link

References

https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software

 

I made changes again in  sudo nano /etc/network/interfaces file  removing # infront of auto wlan0 so wifi is working normally.

—————————————————————————————————————————————————-

MQTT for Arduino client and PI Broker

These are the different links of tutorials for MQTT  for arduino and raspberry Pi

https://github.com/ibr-alg/wiselib/wiki/Example-MQTTSN-network-(Raspberry-Pi-and-Arduino)

– An «Internet of Things» demo using Raspberry Pi, Arduino, Minecraft and MQTT

MQTT 101 – How to Get Started with the lightweight IoT Protocol

Linking the ESP8266 to a Raspberry Pi through MQTT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Advertisements
Vilros Raspberry PI Ult Kit report on installation experiences

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s