Can we define input and output pins in code itself iusing python ? for tcs230 sensor

i had written code for reading blue color intensity in the range of 0 -255, using digital pins
always i get value as 1

@swapnithkondapalli

From digital pins, you cannot get/read a varied range (0-255). Which sensor module exactly are you using for this?

im using tcs230 sensor


this my code to read only blue color , so that alret messge could be send to user when he is exposed of more intensity blue light

please suggest me if any improvise neded in my code , i think you got my idea

how do I actually read frequency from tcs320 sensor , I also need to get serial output and if the frequency value exceeds my limit I should get alert SMS

@swapnithkondapalli

There are many errors in the code. I’ll clear a small concept -

  1. Digital signal means 1 and 0. HIGH and LOW signals (either there is a voltage level, or there is not)
  2. Analog signal means range of values 0-255 or 0-1023.

From the GPIO pins(digital), you can write both digital and analog data, but read only digital data.
From analog pin (A0), you can read only analog data (0-1023).

I believe now your doubt should be clear.

Therefore, before writing a python project code directly, go to Bolt Cloud and test your signal from the color sensor.

Then go to https://docs.boltiot.com/docs/python-library and followup with the correct function to do so.

Also, in your code, you have put while("true") which is incorrect.

I want you to go through the sample code provided and make the required changes yourself.

If you face any issue or have any doubt, let me know.

blue


i can’t see my output
if this works i add try catch blok for SMS sending, please suggest me any corrections

@swapnithkondapalli

Your API has been rate limited. You cannot over use the API requests. That means, you cannot use too many Bolt functions, where each makes an API request.
For reference - API access rules

I already mentioned regarding this,

Also, as I can see, you are randomly using serialWrite function here. Why do you need that? Are you doing an UART communication as well?

yes bro, i assumed get continuos reading so, i used while (‘true’) previously , i need to do that

@swapnithkondapalli

Correct syntax is - while (True):

And put proper time duration for the next loop to run. At least of 5-10 seconds. Or you’ll be rate-limited easily.

Other solution, is to get the Bolt Cloud Pro.

image
im I reading the sensor value correctly?
there’s the error that response value is not defined

@swapnithkondapalli

You cannot directly use the functions on the code tab, please follow the procedure for plotting a graph, as given in the training.

I have provided instructions for using the functions on the code tab, which can only be used with HTML function.

To add buttons or use the function with JS extension, below is a sample -

singleButton({name:"Led On", action:"digitalWrite", pin:"0", value:"HIGH"})
singleButton({name:"Led Off", action:"digitalWrite", pin:"0", value:"LOW"})

You can take further reference from - Controlling output devices (with a cloud dashboard)

how could i use digitalRead button tag to read sensor output should i declare a variable to read pin value
if so can i use ‘if’ based on pinvalues

image
im confused , i need set certain pins either high or low to read only blue color ,
i could set them by adding buttons then how do i read sensorout value

@swapnithkondapalli

We shall discuss about this in a zoom meet. Your doubt is unclear and there are a few things you’re confused about. Write a mail to me for the same, and we shall connect over zoom and look at your issue.

Please check if you can get a Cloud Pro account, even if for a month. The amount of API calls you make everytime is really high, for the kind of project you’re building. For this one time zoom session it is not mandatory, but it’ll be helpful for you.

We shall connect for multiple doubt clearing sessions, if you are a Pro user in future.

You can write a mail to akshayan.sinha@boltiot.com