Saturday, July 14, 2018

Publish Temperature, Humidity to Twitter using Rasp Pi, NodeRed


Hi,

This is continuation of the posts :

1. Getting started with Raspberry Pi using DHT11 Temperature and Humidity Sensor :

 https://johnsylvester-johnsylvester.blogspot.com/2018/07/getting-started-with-raspberry-pi-dht11.html

2. Publish  Temperature and Humidity to Telegram :

https://johnsylvester-johnsylvester.blogspot.com/2018/07/publish-temperature-humidity-to.html


If you have not completed above two , complete it and then continue this post.

Lets see how to publish the temperature & humidity to Twitter using Raspberry Pi 3 B+

I. Twitter Setup 

a) Login into your twitter account to https://apps.twitter.com








b) Create a new Twitter Application as follows:



 Note down the Consumer Key , Consumer Secret

b) Click "Create my access token "  and generate Access token  , Access Token Secret and note it down.




II. Node Flow Setup 


a)  Get the Node Red flow from "Publish  Temperature and Humidity to Telegram Post :
https://johnsylvester-johnsylvester.blogspot.com/2018/07/publish-temperature-humidity-to.html"

b) Drag and drop "twitter out" from the left palette and complete the Node Red Flow diagram


c) Configure the twitter out node as follows :

1) Click the edit icon 


2) Provide the Consumer Key , Secret , Access Token and Access secret  and click "Done".
 






III. Deploy and test the flow :





Now , you have successfully got the temperature & humidity from DHT11 Sensor published to twitter.

Kindly share your comments to improve my posting.

Thursday, July 12, 2018

Detecting Big & Small Sound using Sound Sensor , Raspberry Pi, Python



Hi,

 I like to share my experience connecting Raspberry Pi , Big & Small Sound Sensor using Python.


Note :
You can use the same circuit , python program for both big and small sound sensors. The process is same for both the sensors 


I.Things Needed :

 1. Raspberry Pi 3 Model B+


 2.  a) Big Sound Sensor


      b) Small Sound Sensor  - KES200

                                   

 3. 3 Female to Female Jumper wires.



II.  Circuit Completion

a) Complete  the circuit has shown below .  




b) When you connect for the first time, you will see two red lights burning


c) Take a screw driver and adjust the screw so that only one light burns and when you knock near the sensor,  second light should blink ( it means sound is detected ).









II.Python Program 

a) Open a Text Editor and give the following program and save it as sound.py :





Python File : 

https://gist.github.com/johnsylvester1/ddf2bd28324e77d6ec0366fb52a012cb


IV. Executing Python program 

a) Open the Terminal using VNC Viewer or Putty / MobaXterm and  give the command

     python sound.py

Big Sound Sensor :

 Now knock near the big sensor







Small Sound Sensor :


Now blow air near  small sound  sensor





Now , you have successfully detected sound using sound sensor ( big and sound ) & Python.


Kindly share your comments to improve my posting.








Publish Temperature, Humidity to Telegram using Rasp Pi, NodeRed


Hi,

In my previous post, I explained how to get temperature, humidity using DHT11 sensor using Node Red, Raspberry Pi . If you have not completed it, request you to refer to the below post : 

https://johnsylvester-johnsylvester.blogspot.com/2018/07/getting-started-with-raspberry-pi-dht11.html

I. Telegram Bot creation and Configuration:

a) Go to Telegram and search for BotFather and give
 
1 )  /newbot
2) Choose a name for your bot, in my case name is johnsylvester
3) Choose Bot name , keep in mind, it should end with "Bot" keyword , in my case it is "JohnSylvesterBot"






b)  You will get a Congratulations message. Save the Bot Token  , it will be required for configuring Node Red Telegram module.


c)  If you like to send messages to groups, you need to enable it as shown below in BotFather

1) /setjoingroups
2) it will ask for bot name : @JohnSylvesterBot
3) Give keyword : Enable , you will get a Success message saying it is enabled.




d) Exit BotFather and search for newly created Bot, in my case, it is johnsylvester bot :



e) Start johnsylvester bot  using /start command:



f) Search for "IDBot"  and start it using /start command.

 1) Give the newly created Bot name : JohnSylvesterBot
 2) Issue /getid to get the Bot id and save it, it will be required for the Node Red Flow.













II. Installing Telegram in Node Red :


a) First install all Telegram Node Red modules going to manage palettes as shown below :

b) Take the Node Red Flow from the earlier post  and complete the Node Red flow as shown below :

https://johnsylvester-johnsylvester.blogspot.com/2018/07/getting-started-with-raspberry-pi-dht11.html


c) Configure the Telegram Sender node with Bot Name and Token saved earlier as follows :



   Click Add and then Done :

d) Give the below coding in the Function node connecting Telegram Sender .Provide the chatId which was saved from IDBot   /getid : 




var msgcontent = msg.payload;

jsonmsg = {};

jsonmsg["chatId"] = "XXXXX";
jsonmsg["type"] = "message";
jsonmsg["content"] = msgcontent;
msg.payload = jsonmsg;
return msg;


Node Red Flow ( chatId masked ): 

[{"id":"dd8b2bf2.74c1d8","type":"inject","z":"ca6ebb28.cf4718","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":105,"y":147,"wires":[["d4fc5c1f.04397"]]},{"id":"d4fc5c1f.04397","type":"rpi-dht22","z":"ca6ebb28.cf4718","name":"","topic":"rpi-dht22","dht":"11","pintype":"0","pin":4,"x":354,"y":149,"wires":[["815e3de7.d095"]]},{"id":"815e3de7.d095","type":"function","z":"ca6ebb28.cf4718","name":"function","func":"var temp = msg.payload;\nvar hum  = msg.humidity;\n\nmsg.payload = \"The Temperature at Chennai is : \" + temp + \" C humidity : \"  + hum + \" %\";\n\nreturn msg;","outputs":1,"noerr":0,"x":515,"y":205,"wires":[["9a83148c.58fd18","5bad32f3.17b5ec"]]},{"id":"9a83148c.58fd18","type":"debug","z":"ca6ebb28.cf4718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":752,"y":214,"wires":[]},{"id":"ff2ed10c.1f0da","type":"telegram sender","z":"ca6ebb28.cf4718","name":"","bot":"af6e0a39.4fd4f8","x":798,"y":412,"wires":[[]]},{"id":"5bad32f3.17b5ec","type":"function","z":"ca6ebb28.cf4718","name":"Construct Telegram msg","func":"var msgcontent = msg.payload;\n\njsonmsg = {};\n\njsonmsg[\"chatId\"] = \"XXXXXX\";\njsonmsg[\"type\"] = \"message\";\njsonmsg[\"content\"] = msgcontent;\nmsg.payload = jsonmsg;\nreturn msg;\n","outputs":1,"noerr":0,"x":600,"y":331,"wires":[["ff2ed10c.1f0da"]]},{"id":"af6e0a39.4fd4f8","type":"telegram bot","z":"","botname":"JohnSylvesterBot","usernames":"","chatids":"","baseapiurl":"","pollinterval":"300"}]

III. Deploy & Test the Node Red Flow :

a) Deploy the flow.
b) Click the Inject module.

Output will appear as follows :


Now , you have successfully got the temperature & humidity published to Telegram and debug screen.


Kindly share your comments to improve my posting.

Tuesday, July 10, 2018

Blinking Laser light using KY-008 laser sensor module, Raspberry Pi , Node Red


Hi,

 I like to share my second experience connecting Raspberry Pi , KY008 (Laser  transmitter sensor module ) and Node Red.


I.Things Needed :

 1. Raspberry Pi 3 Model B+


 2. KY008 Laser Transmitter Sensor Module 
         
           


 3. Solderless board

 4. 3 Male to Female Jumper wires.



II.  Circuit Completion

Complete  the circuit has shown below 










III.  Install necessary packages :

a) Download package : http://www.airspayce.com/mikem/bcm2835/bcm2835-1.48.tar.gz
b) tar zxvf bcm2835-1.48.tar.gz
c) Compile process :
         cd bcm2835-1.48
        ./configure
                           
         make

   sudo make check
   sudo make install

d) After completing the installation of the BCM2835 library, we can install the Node-DHT-Sensor library:
                     
 sudo npm install node-dht-sensor
   
IV. Node Red Flow 

a) Start Node Red : sudo node-red-start
b) Drag and drop the nodes as shown below and wire them



c) Configure the nodes as shown below : 

 Inject node :

 Select "String" for  Payload and configure the repeat as "interval" as shown below :


 rpi-dht22  node :




Node Red Flow :

[{"id":"a25a1f7e.a4e56","type":"inject","z":"99f49bf6.8ceb48","name":"On","topic":"","payload":"1","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":115,"y":135,"wires":[["1794f512.51b6fb"]]},{"id":"1794f512.51b6fb","type":"rpi-dht22","z":"99f49bf6.8ceb48","name":"","topic":"rpi-dht22","dht":"11","pintype":"0","pin":4,"x":513,"y":138,"wires":[[]]}]


IV. Executing the Node Red Flow 

 Click Deploy. You can see the laser sensor blinking.







Now , you have successfully got the blinking light using KY008 Sensor.


Kindly share your comments to improve my posting.







Monday, July 9, 2018

Getting Started with Raspberry Pi, DHT11 (Temperature and Humidity Sensor ) using Node Red


Hi,

 I like to share my first experience connecting Raspberry Pi , DHT11 (Temperature/ Humidity Sensor) using Node Red.


I.Things Needed :

 1. Raspberry Pi 3 Model B+


 2. DHT11 Sensor 


 3. Solderless board

 4. 3 Male to Female Jumper wires.



II.  Circuit Completion

Complete  the circuit has shown below 










III.  Install necessary packages :

a) Download package : http://www.airspayce.com/mikem/bcm2835/bcm2835-1.56.tar.gz
b) tar zxvf bcm2835-1.56.tar.gz
c) Compile process :
         cd bcm2835-1.56
        ./configure
                             
         make

   sudo make check
   sudo make install

d) After completing the installation of the BCM2835 library, we can install the Node-DHT-Sensor library:
                     
sudo npm install node-dht-sensor
   
IV. Node Red Flow 

a) Start Node Red : sudo node-red-start
b) Drag and drop the nodes as shown below and wire them



c) Configure the nodes as shown below : 

 Inject node :

 rpi-dht22  node :


 function node :



 
      var temp = msg.payload;
      var hum  = msg.humidity;

      msg.payload = "The Temperature at Chennai is : " + temp + " C humidity : "  + hum + " %";
      return msg;

Node Red Flow :

[{"id":"815e3de7.d095","type":"function","z":"ca6ebb28.cf4718","name":"function","func":"var temp = msg.payload;\nvar hum  = msg.humidity;\n\nmsg.payload = \"The Temperature at Chennai is : \" + temp + \" C humidity : \"  + hum + \" %\";\n\nreturn msg;","outputs":1,"noerr":0,"x":515,"y":205,"wires":[["9a83148c.58fd18"]]}]


IV. Executing the Node Red Flow 

a) Click Deploy
b) Click the Inject node
c) Output will appear in the debug window





Now , you have successfully got the temperature & humidity from DHT11 Sensor.


Kindly share your comments to improve my posting.






Mastering IoT Development

Hi, Before reading this post, I would recommend to read the post : https://johnsylvester-johnsylvester.blogspot.com/2018/09/iot-key-co...