This Is a normal GPIO Comm. Code
<!doctype html>
BOLT
var r;
function analogRead(pin,element_id)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var obj = JSON.parse(xmlhttp.responseText);
if(obj.success==“1”)
{
document.getElementById(element_id).innerHTML = "Pin Val = "+obj.value;
r=obj.value;
}
else
{
document.getElementById(element_id).innerHTML = "Error = "+xmlhttp.responseText;
}
}
}
xmlhttp.open(“GET”,"/analogRead?pin="+pin,true);
xmlhttp.send();
}
But How TO Read A0 Pin Using UART Command
Dear Dhiraj,
The UART communication is used only for communicating between two different modules or microcontrollers.
Just try and use the GPIO Communication which is specifically made for communications between microcontroller and a sensor.
I have done like this in the link using arduino uno
can I get email alerts when it reaches threshold?
can anyone help me?
Hello Dheeraj,If you directly interface a sensor with only bolt device you need not use UART ,you should use GPIO.You can use UART when there is communication between bolt and any other module such as Arduino.Please check on my project which is similar.https://www.hackster.io/wwwkaushikts/intruder-alert-using-bolt-iot-and-arduino-54a84b
Uart command is used when we use more than one microcontroller other than bolt such as Arduino or rasberry pi. It is a set of rules which is used for exchanging serial data between 2 devices.
UART is used for communicating with other microcontrollers like Arduino whereas GPIO is for communicating with sensors