Cant use value from variable in my code

I want to use the value from my variable associated with A0 pin, which I created while creating the project, elsewhere in my code.

Product Type - Input Device with GPIO
I am using JS for the code.

Also, it would work if I can store the value from the sensor in some another variable so I can use it further in my code.

I used temp = readAnalog(A0), but this variable remains undefined for some unknown reason.
I also used console.log(temp) to see whether or not the value gets stored in temp, but there also it is undefined.

Or is there another function to read an analog sensor value which I am missing out?

Please HELP!!

What platform are you using? Bolt Cloud right? To create a product and write a JS code on it?

Yes, I am using BOLT Cloud.

  1. What is the purpose of reading analog data? To plot a graph?
  2. GPIO pins for analog uses the syntax analogRead('A0')

If you are using boltCommand script in html, then add the script link - https://cloud.boltiot.com/static/js/boltCommands.js

  1. I want to use that data to match with a criteria and based on that, I want to send signals to my digital output pins.

  2. Yes, I used that as well, but not working.

I used digitalWrite(1,“HIGH”) and it does glow my LED connected to pin 1, but I want to use this inside an if statement, for that I want to use tha data from analog input.

Will I have to write this entire code?

Isnt there any way, where I can just use analogRead() to store the value in a variable?

Thanks for the reply, but I read this on BOLT forum that the module has been designed to use input and output both at same time.

Also, do you think, if I use UART instead of GPIO, will just writing analogRead() work?

Bolt Module can surely use both at the same time. I have mentioned, to use python to do it.

When using Bolt cloud, you are restricted to HTML and JS only.

That’s why i gave you a custom script That will do your job. The script includes an IF condition, where crossing the threshold 500 will trigger the pin 1.
But as mentioned, you can try it, I am not sure if it will work.

UART is for serial Read/Write only (uses RX-TX ports). And GPIO is for digital/Analog pins (A0, 0->4 pins)

Go through the module carefully before attempting to make a project. It has mentioned every DOs and DONTs of the module.

When stuck in a project, or have a doubt in any section, Forum Community will help you with it.

Also to mention, dont dexpect others to write you a code for you. When having ideas, try to innovate a solve by writing your own script, while the community will help you with explaining the doubts you mention.

Use your own code with the existing data from the training module. Refer to Project 7 and Project 9 from the IoT and ML Training to trigger a pin when conditions are met.

It is necessary that you go through the module instead of skipping the sessions for the sake of certificate.

Thanks for the reply.

I have not enrolled in any course, just doing it for my curiosity, so there’s no question of me skipping sessions for the SAKE of a certificate.

Thanks for the help by the way, but you could be a little more polite, specially when you know about something more than others, cheers.

In that case, I cannot help you with anything. Student have paid for the course and the module. Nothing comes for free. I cannot provide you with the scripts and codes which we had to pay for. I am not liable to share locked course materials with others.

I have seen many students and members in the forum. Few skip the sessions to get ahead and get a certificate, then come to the forum for a code for their project. And I apologize if any part of my post hurt you or I sound rude.

You can go ahead to the https://www.boltiot.com/projects and build projects similar to them and find out ways to build your own.