Internet of Things
Setting up Raspberry Pi
[MQTT Official Site]http://www.mqttfx.org
Install VNC Server
Running VNCServer at StartupCommand+K
vnc://172.25.0.121:5901Free MQTT Dasboard
http://www.mqtt-dashboard.comMQTT Client: MQTTFx
broker.hivemq.com
brew install mqttfxInstall mosquitto client on rPi
sudo apt-get mosquitto-client
sudo apt-get mosquitto # optionalIn the first terminal run
$ mosquitto_sub -h 127.0.0.1 -t myTopicIn the second terminal run
$ mosquitto_pub -h 172.0.0.1 -t myTopic -m “Hello, world”
Connect to GrovePi
Refer to: Quick Start Guide to the GrovePi.
- Connect the GrovePi to Raspberry Pi
Install the GrovePi repository
1
curl -kL dexterindustries.com/update_grovepi | sudo bash
Check if Raspberrypi has connected to Grovepi
1
sudo i2cdetect -y 1
Example
“Hello, World!” Example: LED Blink
1
2cd /home/pi/Dexter/GrovePi/Software/Python
sudo python grove_led_blink.pyLED Fade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45# fade_led.py
# python fade_led.py
import time
import grovepi
# Connect the Rotary Angle Sensor to analog port A2
potentiometer = 2
# Connect the Grove LED to digital port D5
# SIG,NC,VCC,GND
led = 5
# Digital ports that support Pulse Width Modulation (PWM)
# D3, D5, D6
# Digital ports that do not support PWM
# D2, D4, D7, D8
grovepi.pinMode(led,"OUTPUT")
time.sleep(1)
i = 0
while True:
try:
# Reset
# if i > 255:
# i = 0
# Current brightness
i = grovepi.analogRead(potentiometer) / 4
print (i)
# Give PWM output to LED
grovepi.analogWrite(led,i)
# Increment brightness for next iteration
# i = i + 20
time.sleep(.5)
except KeyboardInterrupt:
grovepi.analogWrite(led,0)
break
except IOError:
print ("Error")LED
CheatSheet
- Logon
1
2ssh pi@ip_addr
# passwd:pi - Reset root passwd
1
sudo passwd root