How to do serial write using onclick function in html

Like we have onclick= digitalwrite(pin_number,value) is serialWrite(Tx,value) acceptable

Hi,
If you see in bolt.js file https://github.com/Inventrom/bolt-sdcard-files/blob/master/bolt.js.
You will find a function a sendSerialData(). You can call that function on any javascript event.

function sendSerialData(serialdata) {
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && debug == 1) {
			{
				alert(xmlhttp.responseText);
			}

		}
	};
	xmlhttp.open("GET","/serialWrite?data="+serialdata,true);
	xmlhttp.send();
}
1 Like

Hi,

You dont need to specify on which pin you need to send serial data on since there is only one dedicated Tx pin on Bolt. Hence a function like serialWrite(data) would suffice. You can add one of your own by referring to the bolt.js file on bolt.

To view thw contents of the bolt.js file or to download it use the following link and replace ip with your Bolt’s ip address

ip/serveFile?filename=bolt.js

Hope this clarifies your doubts