Create buzzer sound in plant monitoring system

Basically, I want to integrate both the plant monitoring system and buzzer together.
Can someone guide me on how to get light as a variable and how to configure it so that both can work together?
And how to show both graph and sound stop button for the project.
And I want to get both input and output for the project how to get it?

I suggest you to use VPS and python for using input and output at the same time. Bolt Cloud and the GPIO Input/Output section is for beginners to learn and understand how the module works individually. I have used python on linux to control input and output, and it did work. For help or guidance regarding that, do come forward.

1 Like

By installing the boltiot package in Python, we can use the various libraries such as Sms, Bolt and others. Because through the boltiot python library we can only use GPIO commands, UART commands and Utility functions along with the SMS & Email notifications alert. We have to particularly use the Bolt Cloud platform in order to use the Google-Chart library and thus can use the various charts’ functionalities.

@sroshanahmad, as you are talking about the use of Buzzer along with the LDR project (plant monitoring system), we can do so by writing a python code in UBUNTU. In order to understand the hardware connection for the desired project, we first have to understand the individual hardware configurations for LDR and Buzzer.

Hardware Configuration of Piezo-Buzzer

Hardware Configuration of LDR Sensor

So, the final circuit for LDR with sensor will have the following configuration:


In this case, you have to insert one leg of the LDR into the A0 pin along with the 10k ohm resistor and other leg into the GND pin. For the Buzzer, you have to insert the shorter leg into the GND pin while the longer leg should be inserted in the GPIO 0 pin.

As far as the python file for this is concerned, you must have access to the basic python file, which is in the course itself, in which we can use Z-Score Analysis to detect any anomaly for the data points. So in this project you must be trying to make the buzzer active when the light value crosses the upper and lower bounds which are calculated by the Z-Score analysis.

So in that project, you just have to add few lines in the below section.


In case you want the buzzer to produce sounds in both cases (if new value exceeds / precedes the threshold values), then you have to use either the analogWrite or digitalWrite function to do so. So, in the if and elif part include the statement mybolt.analogWrite(‘0’,‘255’) or mybolt.digitalWrite(‘0’,‘HIGH’)
By this peice of line, you will be notified whenever there is a different behaviour of light falling on the plants.

You also want to show the input values (which is basically the running python file) and the output values (graphs) in a same window. Brother, you can’t do so because altogether it makes no sense. Bolt Coud provides you an environment through which you can directly access the data points which are being fetched directly by the bolt device and thus you can see the inputs and the outputs in the Bolt Cloud Dashboard in the form of Graphs. As you are aware of the fact that when we configure a javaScript file on the cloud, the BOLT platfrom provides us a default UI for each type of graph we selects and also as of now we can’t create a seperate JS & HTML file for a same product. So, in short you can’t apply a STOP button in the BOLT Cloud UI when you are using the graph’s functionality.
But on the other hand, you can add a time delay function for say 10 seconds after the buzzer starts producing the sound. So the final code will look like this:

Note: This is just the different section of the code. So do write the whole program which is available on the course’s dashboard
Hope this helps you :blush::+1:

5 Likes

Since I haven’t reached till the python section,so I tried using Javascript and this is my code incase someone hasn’t reached the python section yet.

setChartLibrary(‘google-chart’);
setChartTitle(‘Light Intensity System’);
setChartType(‘lineGraph’);
setAxisName(‘Time’,‘Light’);
setCrosshair(true);
plotChart(‘time_stamp’,‘light’);

function updates() {
setInterval(function (){
fetch(‘https://cloud.boltiot.com/remote/analogRead?deviceName=BOLT&pin=A0’).then( data => data.json()).then(data => {

     console.log(data);
     let ana_val = data["value"];
    
    if(ana_val<750){
         analogWrite("0","255"); 
    }
    else {
        analogWrite("0","0"); 
    }
    
  });

},2000);
}
document.addEventListener(‘DOMContentLoaded’,function() {
updates();
});
singleButton({
name:“Sound off”,action:“analogWrite”,pin:“0”,value:“0”,bgcolor:“red”,shape:“rectangle”,align:“center”,text_color:“black”
})

1 Like