Community

IoT Python app with a Raspberry Pi and Bluemix

Share this post:

This is an extension/continuation from the blog post on how to create a basic Python webapp. In this tutorial we are going to go through how to integrate a Python Flask webapp in Bluemix with the Internet of Things Foundation in Bluemix with a Raspberry Pi and two sensors on the Raspberry Pi. The tutorial also uses Twilio to interact with the Raspberry Pi.

So what does this look like? Here is a simple architecture diagram.

In the above diagram there is two flows:

  • The first flow involves pressing a HTML button in the Python Flask app in Bluemix to either turn on or off an LED on the Raspberry Pi.
  • The second flow involves pressing a physical button on the breadboard on the Raspberry Pi and using the IoT service in Bluemix and our app in Bluemix it will send a text message of our choosing to a phone number we enter in the Python Flask app in Bluemix using Twilio.

This all took only about 100 lines of code, pretty cool huh?

If you prefer to watch a video of this instead of going through the written steps in this tutorial, check out the video below.

Watch the video (https://www.youtube.com/watch?v=YHDhn5hGnn8)

Setup

There is two parts to setting this up. If we take a look at the architecture diagram above we see that there is a Raspberry Pi piece and then a Bluemix piece. We are going to go through the Raspberry Pi piece first then we will go through the Bluemix piece.

Raspberry Pi Setup Steps

  1. Sign up for a Bluemix account, visit http://bluemix.net in your web browser and click “Sign-up” in the top right. We require a couple bits of information
  2. Wait for an email to arrive, it should only take a couple minutes. There should be a link in the email that says “Click here to complete your registration”, click that. Sign in with the username and password you created from step 1.
  3. Obtain a Raspberry Pi, a bread board, wires, a LED, and a button (your best bet is getting a starter kit such as the Canakit)
  4. Place an LED in the breadboard (place the shorter side to the left)
  5. Place a 220 ohm resistor in the breadboard connecting the short side (the left side of the LED) to the ground rail (the rail with the – sign). Make sure to place the side of the resistor with the red stripes closest to the LED
    NOTE: The way the breadboard works is connections run vertically not horizontally
    resistor
  6. Connect a wire from the ground rail to the GND on the pinout board
    ground
  7. On the right side of the LED, connect a wire to the the port labeled 17.
    NOTE: The way the breadboard works is connections run vertically not horizontally.
  8. Place the button in the breadboard, it takes a bit of force to press it in all the way. It won’t break it.
    button
  9. Connect a wire from the right side of the button to the ground rail.
  10. Connect a wire from the ground rail to a GND port, it doesn’t matter which one it is
  11. Lastly, connect a wire from the left side of the button to GPIO port 18.
  12. Next we need to either use the console for our Raspberry Pi and the terminal application on the device itself or use SSH. I am going to use SSH.
  13. To get the IP address of your Raspberry Pi the easiest thing is to open up the terminal app on the Raspberry Pi, it is under accessories -> Terminal
  14. Type “ifconfig” without the quotes. If you are connected over Ethernet the IP address will be under eth0, if you are connected over wifi, the IP address will be under wlan0
  15. Next we need to ssh into the device.
    —Windows, download Putty and use that to connect to the IP address
    —Mac and Linux, open the Terminal app, type ssh pi@myipaddress where myipaddress is the IP address of the Raspberry Pi, ex. 192.168.1.65
  16. The password is raspberrypi
  17. We need to run some commands to update our Raspberry Pi, run the following. It will ask you to confirm with the “Y” key
    sudo apt-get update
    sudo apt-get upgrade
  18. Next we need to install a helper library for using GPIO
    git clone git://git.drogon.net/wiringPi
    cd wiringPi
    ./build
  19. Next we need to install the IoT library on the Raspberry Pi
    curl -LO https://github.com/ibm-messaging/iot-raspberrypi/releases/download/1.0.2/iot_1.0-1_armhf.deb
    sudo dpkg -i iot_1.0-1_armf.deb
  20. We need to get the device ID of our raspberry Pi do this run the following and save the output
    service iot getdeviceid
    #example output
    The device id is b827eba5b236

    We will want to copy the id b827eba5b236, yours obviously will be different

  21. Open up a web browser and goto bluemix.net, and click on “Catalog” in the top. Scroll down to the very bottom and click “Internet of Things”.
  22. Give the service a name, use iot-python (you must do this exactly or later things won’t work), for App choose “Leave unbound”, click “Create”.
  23. On the left of the next page click “Launch dashboard”.
  24. At the top click on “Devices”.
  25. Click “Add Device”.
  26. For the second field (it says e.g. mydevice type) type in exactly raspberrypi (you need to have it spelled like this or there will be issues). For device ID paste in the device ID we got from step 20, mine is b827ba5b236. Click continue.
  27. On the next page it will show something like below, copy this and switch back to terminal on your Raspberry Pi.
    org=pwftki
    type=raspberrypi
    id=000000000000
    auth-method=token
    auth-token=cXQaGx8o!a9HwxM-ka
  28. Choose your favorite text editor but I am going to use vi. Type the following to open the file we want to edit.
    sudo vi /etc/iotsample-raspberrypi/device.cfg
  29. To paste the text press the “i” key. Then paste the text, this will depend on the OS you are on.
  30. To save the file hit the “Esc” key. Then Type “:wq” and then press “Enter”. That will save the file.
  31. Let’s restart the IoT service on our Raspberry Pi to start sending the data to the IoT service
    sudo service iot restart
  32. Next we need to download the Python code to run on the Raspberry Pi, run the following:
    cd ~
    git clone https://github.com/IBM-Bluemix/python-iot-raspberry-pi.git
    cd python-iot-raspberry-pi
  33. Now we need to install the package manager for Python:
    sudo apt-get install python-pip
    sudo pip install -r requirements.txt
  34. One last bit, we need a config file for our app before we can start it. Lets run the following:
    vi ~/device.cfg
  35. Remember this is vi again, so remember the shortcuts for inserting text and saving it from step 29,30. The contents of the file should look something like below, replacing yourapikey, yourdeviceid, youriotorg, and yourapitoken with the correct values. To generate the API key and token we can get them from going back to the web browser and going to the Internet of Things Foundation. At the top click on API Keys. Click “New API Key”. The values that it gives you will be the values you use for the yourapitoken and yourapikey. yourdeviceid is the value we got from step 20
    youriotorg is from step 27, it is also in your config file; in my case my value is pwftki. Let’s save the file (remember, “Esc”, “:wq”, “Enter”)

    [application]
    org=youriotorg
    id=yourdeviceid
    auth-method=apikey
    auth-key=yourapikey
    auth-token=yourauthtoken
  36. OK, so now we can launch/start the app on the Raspberry Pi. To do that run the following:
    cd ~/python-iot-raspberry-pi
    python client.py

Bluemix App Setup Steps

  1. We will need to install the Cloud Foundry CLI to deploy our app to Bluemix. To do this head over to https://github.com/cloudfoundry/cli/releases. Choose the appropriate installer for your platform, download it and run the installer.
  2. So let’s open up a new terminal Window, we will need to do the rest on our development machine/laptop.
  3. We need to download the Python code for our app. Run the following. If you don’t have git installed follow these instructions here.
    git clone git clone https://github.com/IBM-Bluemix/python-iot-raspberry-pi.git
    cd python-iot-raspberry-pi
  4. In your web browser go back to the tab that you have Bluemix open with. In the top click “Catalog”, scroll down to find “Twilio”. Click on that.
  5. If you already have a Twilio account and want to use that skip to step 6. If you don’t have a Twilio account on the right hand side click “Register at Twilio”.
  6. Twilio will ask you for some information and you will need to verify your phone number. This is important as only numbers verified with the free plan will work with your app. If you want to be able to text any number you need to pay for Twilio, its $1/month/phone number.
  7. Once you are signed up for your account, head to https://www.twilio.com/user/account/voice-messaging. Near the top right there will be a twistie that says “Show API Credentials”, click that. There is two pieces of information here, the Account SID and Auth Token. We will need to copy these back to the Bluemix tab we have open with Twilio.
  8. Paste your Account SID in the field in Bluemix that says Account SID, paste your Auth Token in the Auth Token field.
  9. For the Service name you must type in this exactly iot-twilio
  10. For the App, choose “Leave Unbound”
  11. Click Create.
  12. Switch back to the terminal that you have on your local dev machine, not your Raspberry Pi.
  13. We need to login to Bluemix, to do that, type cf login -a https://api.ng.bluemix.net. It will ask you for your username and password. This is from step 1 in the Raspberry Pi section above.
  14. To deploy our application all we need to do now is type cf push myappname where myapp name is a unique name you choose for your app.
    NOTE: If you get an error mentioning a route is taken, choose a different name and run cf push with a new app name.
  15. It will take about a minute or two to deploy your application but eventually you will get some output that looks like the following:
    requested state: started
    instances: 1/1
    usage: 1G x 1 instances
    urls: testapp-jbs.mybluemix.net
    last uploaded: Fri Jul 31 00:25:17 UTC 2015
    stack: lucid64
    buildpack: SDK for Node.js(TM) (ibm-node.js-0.12.7)

    There is a row that says urls:, copy that URL and paste it into your browser.

If everything went well you should have a page that looks like the following:

An important note here, do not press the button on the Raspberry Pi until you enter a phone number and text message here, if you do the app will crash. If you do this you can restart you app with cf restart myappname, where myappname is the name of the app you chose above.

When you click the “On” button it should turn the light on for you. If you press the “Off” button it should turn the light off.

Feedback

Follow us on Twitter at @IBMBluemix and follow the author of this blog post (Jeff Sloyer, one of our developer advocates) at @jsloyer

Add Comment
42 Comments

Leave a Reply

Your email address will not be published.Required fields are marked *


Jon Hurd

Great instructions. Looking forward to trying this!

Reply

    Jeff Sloyer

    Thanks so much!!! Let me know if you have any issues.

    Reply

Name Steven

Hi, great tutorial and video! I am using Windows 7 and the “cf push” command must be apple ios?

How would a pc user run this command?

Reply

Bryan Boyd

I spent hours searching for an article just like this over the weekend– excellent walkthrough Jeff!

Reply

    Jeff Sloyer

    Thanks Bryan, glad you found it useful!!

    Reply

mario.kam

Are you willing to create some cool tutorial as this one for the LED RGB Matrix pane? Some demo app for sending messages or images to the matrix pane from Bluemix. Thank you!

Reply

    Jeff Sloyer

    Funny that you bring that up…. I’m actually in the process of writing up a blog post a couple videos for that. Only issue is I am traveling the next 2 weeks and I need to record some video with the Raspberry Pi and take some pictures. It probably won’t be up till the week of the 27th….

    Reply

    Jeff Sloyer

    If you follow me on Twitter I’ll send out a tweet once it’s up. My Twitter handle is @jsloyer.

    Reply

      mario.kam

      great! I am looking forward for it! I’ve bought a Matrix Pane inspired by you heh.

      Reply

Bluemix

I want your phone number Jeff!!!!

Reply

Kicke

Hi Jeff, i’m contacting you to ask about an error that I received when run the client.py, could you help me?

~/python-iot-raspberry-pi $ sudo python client.py
client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(17, GPIO.OUT)
Traceback (most recent call last):
File “client.py”, line 23, in
options = ibmiotf.application.ParseConfigFile(“/home/pi/device.cfg”)
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 378, in ParseConfigFile
parms.readfp(f)
File “/usr/lib/python2.7/ConfigParser.py”, line 324, in readfp
self._read(fp, filename)
File “/usr/lib/python2.7/ConfigParser.py”, line 512, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: /home/pi/device.cfg, line: 1
‘org=go69j7n’

Reply

    Kicke

    I solved the issue :), but I have other now,

    sudo python client.py
    client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
    GPIO.setup(17, GPIO.OUT)
    Button Pushed
    Traceback (most recent call last):
    File “client.py”, line 35, in
    client.publishEvent(“raspberrypi”, options[“deviceId”], “input”, myData)
    TypeError: publishEvent() takes at least 6 arguments (5 given)

    Reply

      Mike D

      I’m having the same error
      TypeError: publishEvent() takes at least 6 arguments (5 given)
      is there something that changed in this call. the online documentation says the tutorial is correct

      Can someone at ibm help!

      Reply

        Mike D

        This problem is covered in the IBM board. You now have to specify the message packing.

        Reply

      Julian

      I get the following error when I try to execute “sudo python client.py”:

      client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
      GPIO.setup(17, GPIO.OUT)
      Traceback (most recent call last):
      File “client.py”, line 23, in
      options = ibmiotf.application.ParseConfigFile(“/root/projects/device.cfg”)
      File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 501, in ParseConfigFile
      appType = parms.get(sectionHeader, “type”, “standalone”)
      File “/usr/lib/python2.7/ConfigParser.py”, line 618, in get
      raise NoOptionError(option, section)
      ConfigParser.NoOptionError: No option ‘type’ in section: ‘application’

      I used another location for the device.cfg, but I get the same error, if I use your code and the .cfg in /home/pi/

      Everything else is set up. I got the Server-Side up and running. The last thing missing is the client to establish a connection.

      I get the same error if I use the “Pi” user and put the device.cfg at /home/pi/

      Reply

        Julian

        To solve my error you need to put in “type: yourdevicetype” in the config.cfg in /home/pi.

        Reply

Jerry S

Hi Mike – you have a pointer to the IBM Board you referenced? I’ve been looking for the new docs on the command and can’t seem to find it.

Reply

    Jeff Sloyer

    I updated the code in the Git repo, the 5th argument should be “json”.

    Reply

Yash Vijay

Hey jeff, great work with the tutorial!
I just have a few doubts.
So I’m running windows 7 on the server side, and even after installing git for windows and cloud foundry my ‘cf push’ and ‘cf login’ commands don’t seem to be working on powershell. I’m really new to IoT, so i think I’m making a silly mistake somewhere.
Can you help me out?

Reply

David F

In the example above is Cloud Foundry installed on the raspberry pi?

If so are there any installation instructions?

Reply

Paul

Step 35 is unclear.

device.cfg is blank

Reply

KiranShashi

The client.py on the RPi crashes when I tried it.

pi@raspberrypi ~/python-iot-raspberry-pi $ sudo python client.py
client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(17, GPIO.OUT

== The client crashes here when I click on Turn Light ON==

Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 552, in __bootstrap_inner
self.run()
File “/usr/lib/python2.7/threading.py”, line 505, in run
self.__target(*self.__args, **self.__kwargs)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2287, in _thread_main
self.loop_forever()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1261, in loop_forever
rc = self.loop(timeout, max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 811, in loop
rc = self.loop_read(max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1073, in loop_read
rc = self._packet_read()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1475, in _packet_read
rc = self._packet_handle()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1943, in _packet_handle
return self._handle_publish()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2118, in _handle_publish
self._handle_on_message(message)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2268, in _handle_on_message
t[1](self, self._userdata, message)
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 308, in __onDeviceEvent
if self.deviceEventCallback: self.deviceEventCallback(event)
File “client.py”, line 15, in myCommandCallback
command = cmd.payload[“d”][“command”]
AttributeError: Event instance has no attribute ‘payload’

Reply

narenkrishnan

Great steps.. just a comment on a typo in step 17
sudo-apt-get upgrade

no hyphen after sudo.

Reply

    Dan Kehn

    Thanks, corrected!

    Reply

stavirs

i get this error when i run client.py on Rpi and click on turn light on from the url…

pi@raspberrypi ~/python-iot-raspberry-pi $ sudo python client.py
client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(17, GPIO.OUT
== The client crashes here when I click on Turn Light ON==
Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 552, in __bootstrap_inner
self.run()
File “/usr/lib/python2.7/threading.py”, line 505, in run
self.__target(*self.__args, **self.__kwargs)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2287, in _thread_main
self.loop_forever()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1261, in loop_forever
rc = self.loop(timeout, max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 811, in loop
rc = self.loop_read(max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1073, in loop_read
rc = self._packet_read()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1475, in _packet_read
rc = self._packet_handle()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1943, in _packet_handle
return self._handle_publish()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2118, in _handle_publish
self._handle_on_message(message)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2268, in _handle_on_message
t[1](self, self._userdata, message)
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 308, in __onDeviceEvent
if self.deviceEventCallback: self.deviceEventCallback(event)
File “client.py”, line 15, in myCommandCallback
command = cmd.payload[“d”][“command”]
AttributeError: Event instance has no attribute ‘payload’

Reply

Maxime

Hello!
First of all, impressive tutorial, very clear and effectively written !
Secondly ( 😀 ), I have still one bug to solve..
All of it is working, except, when I click on the “Turn the Led On” on my website, it says “Internal Error 500”.
The strange thing is my LED does turn on (and off, by doing the same to the “LED off” button).
I read the flask and iot python documentation, but can’t find a solution.
My code is mostly exactly the same as yours. By doing some print debugs, the problematic line is the “event.publishEvent”.
Strangely, the event is transfered to the raspberry, but my website still goes on internal error.

Hope you will have a simple answer, and again, nice work 😉

Reply

geekmonster

I have Two Ras Pi’s 2 and a whole bunch of arduino mc’s, do you plan on doing any tuts with RPI’s and Arduino’s connected?

Reply

    geekmonster

    Also do you have any tuts with javascript involved?

    Reply

synx

Please tell me: in “Button Published” What I need to fill?
Thank you!

Reply

Prasanth R

hi jeff,
it is a good tutorial, but i cant follow the steps in the video now, i can’t find the Internet of things in the Bluemix.net catalog, how can i move forward in the process of connecting the device??
please give a reply, thanks in advance

Reply

Nicole Finnie

Hey Jeff,

The /home/pi/device.cfg is missing the device type – otherwise it won’t work (not sure if it’s caused by changes of the IoT platform service)

Here is my example (my device type is raspberrypi defined in Bluemix)

[application]
org=
id=
auth-method=apikey
auth-key=
auth-token=
type=raspberrypi

If type is not defined, you’ll get the following error (mentioned by other contributors above)

File “client.py”, line 24, in
options = ibmiotf.application.ParseConfigFile(“/home/pi/device.cfg”)
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 503, in ParseConfigFile
appType = parms.get(sectionHeader, “type”, “standalone”)
File “/usr/lib/python2.7/ConfigParser.py”, line 618, in get
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option ‘type’ in section: ‘application’

Reply

Nicole Finnie

Incidentally, Gordon didn’t seem to update his WiringPi library for years, and I hit problems linking gpio executable due to unresolved external symbols.
https://github.com/WiringPi/
(a known issue https://github.com/rm-hull/wiringPi/issues/2)

so I found a fork of Gordon’s and the last update was months ago, and I didn’t hit linkage problems with this one.
https://github.com/rm-hull/wiringPi

Reply

Nicole Finnie

Hey Jeff,

want to share some work I did to get your app to work locally, so you don’t need to cf-push to Bluemix for every change. (it takes a long time you know :))

To build a fully local Bluemix environment, I installed the Flask module as well as other modules defined in your requirements.txt locally
1) sudo pip install -r requirements.txt

and then created a JSON file vcap_service.json in python-iot-and modified server.py as follows:

vcapData = os.getenv(“VCAP_SERVICES”)
#run Bluemix app on the local host, vcap_service.json contains the content of your Bluemix VCAP_SERVICES
if vcapData == None and os.path.exists(‘vcap_service.json’) :
with open(‘vcap_service.json’) as vcapServiceFile:
vcap = json.load(vcapServiceFile)
else :
vcap = json.loads(vcapData)

2)make sure to add vcap_service.json to .cfignore and .gitignore

Reply

Nicole Finnie

Update on March 9, it seems the compilation problems are gone, can compile on Raspberry Pi 2 and Pi 3.

git clone git://git.drogon.net/wiringPi

Reply

Souvik Sarkar

LED on/off operation is not working. Below is the stack trace. Please suggest.

2016-03-13T15:00:01.37+0530 [RTR/1] OUT souvikiot.mybluemix.net – [13/03/20
16:09:30:01 +0000] “GET / HTTP/1.1” 200 0 751 “http://souvikiot.mybluemix.net/”
“Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chro
me/48.0.2564.116 Safari/537.36″ 192.155.237.117:40463 x_forwarded_for:”49.207.13
6.134″ x_forwarded_proto:”http” vcap_request_id:9f2af0b2-d1c5-4391-55e8-afb19759
68f9 response_time:0.005322145 app_id:4499b999-047b-4eb9-be09-7e76f164a5c0 x_glo
bal_transaction_id:”808477683″
2016-03-13T15:00:05.66+0530 [App/0] OUT off
2016-03-13T15:00:05.67+0530 [App/0] ERR 198.11.228.42 – – [13/Mar/2016 09:3
0:05] “POST /light/off HTTP/1.1” 302 –
2016-03-13T15:00:05.96+0530 [App/0] ERR 169.54.180.77 – – [13/Mar/2016 09:3
0:05] “GET / HTTP/1.1” 200 –
2016-03-13T15:00:41.66+0530 [App/0] OUT off
2016-03-13T15:00:41.66+0530 [App/0] ERR 75.126.37.74 – – [13/Mar/2016 09:30
:41] “POST /light/off HTTP/1.1” 302 –
2016-03-13T15:00:41.93+0530 [App/0] ERR 169.54.180.77 – – [13/Mar/2016 09:3
0:41] “GET / HTTP/1.1” 200 –
2016-03-13T15:00:42.90+0530 [App/0] OUT off
2016-03-13T15:00:42.91+0530 [App/0] ERR 75.126.52.20 – – [13/Mar/2016 09:30
:42] “POST /light/off HTTP/1.1” 302 –
2016-03-13T15:00:43.16+0530 [App/0] ERR 169.54.180.77 – – [13/Mar/2016 09:3
0:43] “GET / HTTP/1.1” 200 –
2016-03-13T15:05:57.10+0530 [App/0] OUT off
2016-03-13T15:05:57.11+0530 [App/0] ERR 169.55.202.148 – – [13/Mar/2016 09:
35:57] “POST /light/off HTTP/1.1” 302 –
2016-03-13T15:05:57.38+0530 [App/0] ERR 169.55.202.148 – – [13/Mar/2016 09:
35:57] “GET / HTTP/1.1” 200 –
2016-03-13T15:06:02.35+0530 [App/0] OUT on
2016-03-13T15:06:02.35+0530 [App/0] ERR 169.55.202.148 – – [13/Mar/2016 09:
36:02] “POST /light/on HTTP/1.1” 302 –
2016-03-13T15:06:02.62+0530 [App/0] ERR 169.45.162.88 – – [13/Mar/2016 09:3
6:02] “GET / HTTP/1.1” 200 –
2016-03-13T15:06:09.20+0530 [App/0] OUT on
2016-03-13T15:06:09.20+0530 [App/0] ERR 169.55.202.148 – – [13/Mar/2016 09:
36:09] “POST /light/on HTTP/1.1” 302 –
2016-03-13T15:06:09.47+0530 [App/0] ERR 169.45.162.88 – – [13/Mar/2016 09:3
6:09] “GET / HTTP/1.1” 200 –
2016-03-13T15:06:12.03+0530 [App/0] OUT off
2016-03-13T15:06:12.03+0530 [App/0] ERR 169.45.162.88 – – [13/Mar/2016 09:3
6:12] “POST /light/off HTTP/1.1” 302 –
2016-03-13T15:06:12.31+0530 [App/0] ERR 75.126.52.20 – – [13/Mar/2016 09:36
:12] “GET / HTTP/1.1” 200 –

Reply

lnanhkhoa

I have some problems when I run python 2.7. hope you help me soon.
It’s here.
https://drive.google.com/open?id=0B4neqnTcIEmqQm9yM3RQWGF4eXM
Thanks a lot

Reply

    Dan Kehn

    Jeff may answer your question here if it’s specific to his blog post, but generally speaking, I recommend asking your question on Stack Overflow with the #bluemix tag.

    Reply

Sacha Nacar

Forgive me if this has already been said but your command “sudo dpkg -i iot_1.0-1_armf.deb” is missing an “h”. It should be:

“sudo dpkg -i iot_1.0-1_armhf.deb”

Reply

Öeznur

For those who need to enter the “domain”-value in device.cfg


domain=internetofthings.ibmcloud.com

Reply

Joswa

Hi Jeff,

I got the following error when I run ¨python client.py
client.py:9: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(17, GPIO.OUT)
2017-02-21 00:03:31,454 ibmiotf.application.Client CRITICAL Not authorized: (A:se2jab:aaab827ebdb3be3, a-se2jab-9ercfgw1lc, db26f7e4aee1debf87a1499548c6621f)
Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 810, in __bootstrap_inner
self.run()
File “/usr/lib/python2.7/threading.py”, line 763, in run
self.__target(*self.__args, **self.__kwargs)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2580, in _thread_main
self.loop_forever(retry_first_connection=True)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1378, in loop_forever
rc = self.loop(timeout, max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 897, in loop
rc = self.loop_read(max_packets)
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1177, in loop_read
rc = self._packet_read()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 1766, in _packet_read
rc = self._packet_handle()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2245, in _packet_handle
return self._handle_connack()
File “/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py”, line 2306, in _handle_connack
self.on_connect(self, self._userdata, flags_dict, result)
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/application.py”, line 243, in on_connect
self.logAndRaiseException(ConnectionException(“Not authorized: (%s, %s, %s)” % (self.clientId, self.username, self.password)))
File “/usr/local/lib/python2.7/dist-packages/ibmiotf/__init__.py”, line 134, in logAndRaiseException
raise e
ConnectionException: Not authorized: (A:se2jab:aaab827ebdb3be3, a-se2jab-9ercfgw1lc, db26f7e4aee1debf87a1499548c6621f)

2017-02-21 00:03:41,265 ibmiotf.application.Client CRITICAL Operation timed out connecting to the IBM Internet of Things service: se2jab.messaging.internetofthings.ibmcloud.com
Operation timed out connecting to the IBM Internet of Things service: se2jab.messaging.internetofthings.ibmcloud.com

Any idea whatś wrong?

Reply
More Trending Stories

IBM Cloud and F5 Networks Extend Partnership for Highly Available and Scalable Cloud Services

Today’s enterprise IT organizations are forced to confront and evaluate challenges from a broader business perspective unlike ever before. The decisions they make have a direct impact to the top and bottom line, and the demands levied on them to support the company’s mission only grow. IBM Cloud and F5 Networks understand these challenges. Building on a long-standing partnership, over the last several months IBM Cloud and F5 have collaborated on a solution to give IT organizations the flexibility to increase capacity, adapt to change, and stay ahead of evolving business demands.

Continue reading

IBM Bluemix Cloud Platform and Fortinet Extend Partnership for Open and Scalable Cloud Security Services

Fortinet and IBM have been long-standing partners, and today’s announcement marks yet another significant milestone in our joint commitment to lead and accelerate cloud adoption for global enterprises. The latest integration of FortiGate virtual appliances on IBM Cloud for VMware Solutions, available in Q4 through the IBM Cloud portal, brings comprehensive security to workloads on IBM Bluemix with a rich set of virtualized firewall functionality, including security gateway, intrusion prevention, and web application security. The Fortinet solutions also offer offer DevOps extensibility and transparent operational scalability across both public and private clouds.

Continue reading

IBM Cloud private version 2.1 Beta 1 is available

Today IBM is providing a first peek at what is coming in the next major release of IBM Cloud private. IBM Cloud private 2.1 Beta 1 is the first of several beta releases that the development team is delivering leading up to the 2.1 release later this year. This blog describes some of the highlights of this release. If you download it now and give it a spin, we want to hear your feedback on the improvements we made and the direction we're moving in.

Continue reading