SlideShare a Scribd company logo
1 of 24
PubNub IoT Platform
Python
By ANSHU PANDEY
by ANSHU PANDEY | anshuspandey@gmail.com
Usecases for pubnub
• IoT Secure Messaging
• IoT Device Control
• Message Push Notification
• Home Automation Signalling
• Check this for more details
https://stackoverflow.com/questions/20843632/what-is-advantage-
and-disadvantage-of-using-pubnub-over-amazon-simple-notificati
by ANSHU PANDEY | anshuspandey@gmail.com
Navigate to pubnub.com>> signup for an
account or login with google
by ANSHU PANDEY | anshuspandey@gmail.com
Click on Create NEW APP+
by ANSHU PANDEY | anshuspandey@gmail.com
Create App
by ANSHU PANDEY | anshuspandey@gmail.com
After Creating app, scroll down to dashboard
by ANSHU PANDEY | anshuspandey@gmail.com
Click on your app, you just created, you might see a default keyset,
which can be used to connect to PubNub and you can also create you
own keyset.
by ANSHU PANDEY | anshuspandey@gmail.com
Click on New keyset to create a keyset
by ANSHU PANDEY | anshuspandey@gmail.com
You should be able to get three keys which can be used to connect pubnub
Allow pubnub Blocks as shown in below snapshot
by ANSHU PANDEY | anshuspandey@gmail.com
Navigate to Blocks option from Left Menu & create a block
by ANSHU PANDEY | anshuspandey@gmail.com
Click on create to create event handlers
by ANSHU PANDEY | anshuspandey@gmail.com
Name you handler, select after presence from second option, provide
topic in third option and remember the topic
by ANSHU PANDEY | anshuspandey@gmail.com
The block is currently stopped, click on start block to start the block
by ANSHU PANDEY | anshuspandey@gmail.com
Once the block is running, now you are all set
to communicate via pubnub
by ANSHU PANDEY | anshuspandey@gmail.com
Navigate back to keyinfo to get keys
by ANSHU PANDEY | anshuspandey@gmail.com
Install python package for pubnub
pip install pubnub
by ANSHU PANDEY | anshuspandey@gmail.com
Python code for Configuring PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub, SubscribeListener
from pubnub.enums import PNStatusCategory
pnconfig = PNConfiguration()
pnconfig.publish_key = "pub-c-097ac4e7-23cf-45ee-980f-1775137fdf4e"
pnconfig.subscribe_key = "sub-c-a3cd0700-2bcd-11e7-97de-0619f8945a4f"
pnconfig.secret_key="sec-c-NzJhOGJlZmItNzQ2OC00MmM2LTg3ZjAtNWUxOWE2MjY4NTgx"
pnconfig.uuid="test"
pubnub = PubNub(pnconfig)
by ANSHU PANDEY | anshuspandey@gmail.com
Connecting to broker
my_listener = SubscribeListener()
pubnub.add_listener(my_listener)
pubnub.subscribe().channels('mytopic/new').execute()
my_listener.wait_for_connect()
print('connected')
by ANSHU PANDEY | anshuspandey@gmail.com
pubnub.publish().channel('mytopic/new').message({'fieldA':
'awesome', 'fieldB': 10}).sync()
result = my_listener.wait_for_message_on('mytopic/new')
print(result.message)
by ANSHU PANDEY | anshuspandey@gmail.com
Navigate to debug console from left bottom option
by ANSHU PANDEY | anshuspandey@gmail.com
Enter topic name, UUID as test because in program UUID taken is test,
dnt put any authorization key
by ANSHU PANDEY | anshuspandey@gmail.com
Now send data from pubnub, run your python
code, analyse the messages
by ANSHU PANDEY | anshuspandey@gmail.com
Explore PubNub
by ANSHU PANDEY | anshuspandey@gmail.com
I am Happy to see you on this slide,
Now its your turn to do something exciting with this.
With more Expectation
Anshu Pandey
https://www.linkedin.com/in/anshupandey/
by ANSHU PANDEY | anshuspandey@gmail.com

More Related Content

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Python and pub nub iot cloud by anshu pandey

  • 1. PubNub IoT Platform Python By ANSHU PANDEY by ANSHU PANDEY | anshuspandey@gmail.com
  • 2. Usecases for pubnub • IoT Secure Messaging • IoT Device Control • Message Push Notification • Home Automation Signalling • Check this for more details https://stackoverflow.com/questions/20843632/what-is-advantage- and-disadvantage-of-using-pubnub-over-amazon-simple-notificati by ANSHU PANDEY | anshuspandey@gmail.com
  • 3. Navigate to pubnub.com>> signup for an account or login with google by ANSHU PANDEY | anshuspandey@gmail.com
  • 4. Click on Create NEW APP+ by ANSHU PANDEY | anshuspandey@gmail.com
  • 5. Create App by ANSHU PANDEY | anshuspandey@gmail.com
  • 6. After Creating app, scroll down to dashboard by ANSHU PANDEY | anshuspandey@gmail.com
  • 7. Click on your app, you just created, you might see a default keyset, which can be used to connect to PubNub and you can also create you own keyset. by ANSHU PANDEY | anshuspandey@gmail.com
  • 8. Click on New keyset to create a keyset by ANSHU PANDEY | anshuspandey@gmail.com
  • 9. You should be able to get three keys which can be used to connect pubnub Allow pubnub Blocks as shown in below snapshot by ANSHU PANDEY | anshuspandey@gmail.com
  • 10. Navigate to Blocks option from Left Menu & create a block by ANSHU PANDEY | anshuspandey@gmail.com
  • 11. Click on create to create event handlers by ANSHU PANDEY | anshuspandey@gmail.com
  • 12. Name you handler, select after presence from second option, provide topic in third option and remember the topic by ANSHU PANDEY | anshuspandey@gmail.com
  • 13. The block is currently stopped, click on start block to start the block by ANSHU PANDEY | anshuspandey@gmail.com
  • 14. Once the block is running, now you are all set to communicate via pubnub by ANSHU PANDEY | anshuspandey@gmail.com
  • 15. Navigate back to keyinfo to get keys by ANSHU PANDEY | anshuspandey@gmail.com
  • 16. Install python package for pubnub pip install pubnub by ANSHU PANDEY | anshuspandey@gmail.com
  • 17. Python code for Configuring PubNub from pubnub.pnconfiguration import PNConfiguration from pubnub.pubnub import PubNub, SubscribeListener from pubnub.enums import PNStatusCategory pnconfig = PNConfiguration() pnconfig.publish_key = "pub-c-097ac4e7-23cf-45ee-980f-1775137fdf4e" pnconfig.subscribe_key = "sub-c-a3cd0700-2bcd-11e7-97de-0619f8945a4f" pnconfig.secret_key="sec-c-NzJhOGJlZmItNzQ2OC00MmM2LTg3ZjAtNWUxOWE2MjY4NTgx" pnconfig.uuid="test" pubnub = PubNub(pnconfig) by ANSHU PANDEY | anshuspandey@gmail.com
  • 18. Connecting to broker my_listener = SubscribeListener() pubnub.add_listener(my_listener) pubnub.subscribe().channels('mytopic/new').execute() my_listener.wait_for_connect() print('connected') by ANSHU PANDEY | anshuspandey@gmail.com
  • 19. pubnub.publish().channel('mytopic/new').message({'fieldA': 'awesome', 'fieldB': 10}).sync() result = my_listener.wait_for_message_on('mytopic/new') print(result.message) by ANSHU PANDEY | anshuspandey@gmail.com
  • 20. Navigate to debug console from left bottom option by ANSHU PANDEY | anshuspandey@gmail.com
  • 21. Enter topic name, UUID as test because in program UUID taken is test, dnt put any authorization key by ANSHU PANDEY | anshuspandey@gmail.com
  • 22. Now send data from pubnub, run your python code, analyse the messages by ANSHU PANDEY | anshuspandey@gmail.com
  • 23. Explore PubNub by ANSHU PANDEY | anshuspandey@gmail.com
  • 24. I am Happy to see you on this slide, Now its your turn to do something exciting with this. With more Expectation Anshu Pandey https://www.linkedin.com/in/anshupandey/ by ANSHU PANDEY | anshuspandey@gmail.com